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 theneo4j 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
| Parameter | Type | Default | Description |
|---|---|---|---|
uri | str | Required | Bolt connection URI (e.g., bolt://localhost:7687) |
user | str | Required | Neo4j username |
password | str | Required | Neo4j password |
database | str | "neo4j" | Database name to connect to |
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
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