Skip to main content
Neo4j is the recommended graph database backend for Graphiti, providing robust, production-ready storage for temporal knowledge graphs.

Installation

Install Graphiti with Neo4j support:

Prerequisites

You need a running Neo4j instance. The simplest way to get started is with Neo4j Desktop. Alternatively, run Neo4j with Docker:

Configuration

Environment Variables

Set up your Neo4j connection credentials:
.env

Basic Setup

Initialize Graphiti with Neo4j using the default driver:

Custom Database Name

By default, Graphiti uses the neo4j database. To use a custom database:

Driver Implementation

The Neo4jDriver (graphiti_core/driver/neo4j_driver.py:60) implements the GraphDriver interface with the following features:
  • Connection Management: Async connection pooling via neo4j.AsyncGraphDatabase
  • Transaction Support: Full ACID transactions with commit/rollback semantics
  • Index Management: Automatic creation of range and fulltext indices
  • Query Execution: Direct Cypher query execution with parameter binding

Connection Parameters

Index Management

Graphiti automatically creates the following indices on initialization:
  • Range Indices: For efficient UUID, group_id, and timestamp lookups
  • Fulltext Indices: For BM25 text search on entity/edge facts and episode content
To rebuild indices:

Health Check

Verify Neo4j connectivity:

Complete Example

Production Considerations

  • Connection Pooling: Neo4j driver automatically manages connection pools
  • Database Selection: Use separate databases for different environments (dev/staging/prod)
  • Backup: Configure regular Neo4j backups for data durability
  • Performance: Monitor query performance and adjust indices as needed
  • Security: Use strong passwords and restrict network access in production