Skip to content

Storage Overview

GraphRAG.js uses a three-layer storage architecture to handle different aspects of graph RAG:

  • Graph Store - Stores nodes and edges (entities, relationships, communities)
  • Vector Store - Stores embeddings for similarity search
  • Key-Value Store - Stores metadata, chunks, and other document data

Storage Architecture

typescript
const graph = createGraph({
  model: openai("gpt-4o-mini"),
  embedding: openai.embedding("text-embedding-3-small"),
  storage: {
    graph: neo4jGraph({ url: "bolt://localhost:7687", ... }),
    vector: qdrantVector({ url: "http://localhost:6333", ... }),
    kv: redisKV({ host: "localhost", port: 6379 })
  }
});

Each layer can use a different backend, or you can use a unified storage solution.

Available Storage Packages

Graph Stores

PackageDatabaseBest ForStatus
@graphrag-js/memoryIn-memory (Cytoscape)Development, testing
@graphrag-js/neo4jNeo4j + GDSProduction, community detection
@graphrag-js/dozerdbDozerDB (Neo4j-compatible)Open-source production
@graphrag-js/falkordbFalkorDB (Redis-based)Lightweight production

Vector Stores

PackageDatabaseBest ForStatus
@graphrag-js/memoryIn-memory cosineDevelopment, testing
@graphrag-js/qdrantQdrantHigh-performance vector search
@graphrag-js/pgvectorPostgreSQL + pgvectorSQL-based workflows

Key-Value Stores

PackageDatabaseBest ForStatus
@graphrag-js/memoryIn-memory MapDevelopment, testing
@graphrag-js/memoryJSON filesPersistence without DB
@graphrag-js/redisRedisProduction KV storage

Quick Comparison

Development & Testing

Recommended: Use @graphrag-js/memory for all three layers.

typescript
import { memoryGraph, memoryVector, memoryKV } from '@graphrag-js/memory';

const graph = createGraph({
  // ... model config
  storage: {
    graph: memoryGraph,
    vector: memoryVector,
    kv: memoryKV,
  }
});

Production

Option 1: Specialized Stack

typescript
import { neo4jGraph } from '@graphrag-js/neo4j';
import { qdrantVector } from '@graphrag-js/qdrant';
import { redisKV } from '@graphrag-js/redis';

const graph = createGraph({
  // ... model config
  storage: {
    graph: neo4jGraph({ url: "bolt://localhost:7687", ... }),
    vector: qdrantVector({ url: "http://localhost:6333", ... }),
    kv: redisKV({ host: "localhost", port: 6379 })
  }
});

Option 2: PostgreSQL-Only Stack

typescript
import { pgVector } from '@graphrag-js/pgvector';
import { memoryGraph } from '@graphrag-js/memory';
// Note: Use pgvector for vectors, memory for graph until pg graph store is implemented

const graph = createGraph({
  // ... model config
  storage: {
    graph: memoryGraph, // or neo4j/falkordb
    vector: pgVector({ host: "localhost", database: "graphrag", ... }),
    kv: memoryKV, // or redis
  }
});

Option 3: Redis-Based Stack

typescript
import { falkorGraph } from '@graphrag-js/falkordb';
import { redisKV } from '@graphrag-js/redis';
import { memoryVector } from '@graphrag-js/memory';

const graph = createGraph({
  // ... model config
  storage: {
    graph: falkorGraph({ host: "localhost", port: 6379 }),
    vector: memoryVector, // or qdrant/pgvector
    kv: redisKV({ host: "localhost", port: 6379 })
  }
});

Storage Requirements by Algorithm

Different algorithms have different storage requirements:

Similarity Graph

  • Graph Store: Optional (stores similarity edges)
  • Vector Store: Required (primary data structure)
  • KV Store: Required (chunk metadata)

LightRAG

  • Graph Store: Required (entities + relations)
  • Vector Store: Required (dual vectors for entities and relations)
  • KV Store: Required (chunk metadata)

Microsoft GraphRAG

  • Graph Store: Required (entities, relations, communities)
  • Vector Store: Required (entity and chunk vectors)
  • KV Store: Required (chunks, community reports)

Fast GraphRAG

  • Graph Store: Required (entities + relations for PageRank)
  • Vector Store: Required (entity vectors)
  • KV Store: Required (chunk metadata)

AWS GraphRAG

  • Graph Store: Required (hierarchical fact graph)
  • Vector Store: Required (chunk and statement vectors)
  • KV Store: Required (chunks, statements, facts)

Performance Considerations

Latency

StorageVector SearchGraph TraversalKV Lookup
Memory< 1ms< 1ms< 1ms
Neo4jN/A10-50msN/A
Qdrant5-20msN/AN/A
pgvector10-30msN/AN/A
FalkorDBN/A5-15msN/A
RedisN/AN/A1-5ms

Scalability

StorageMax Nodes/VectorsHorizontal Scaling
MemoryLimited by RAMNo
Neo4jBillionsYes (Enterprise)
QdrantBillionsYes
pgvectorMillionsYes (with sharding)
FalkorDBMillionsYes (via Redis cluster)
RedisBillions (keys)Yes (cluster mode)

Cost

StorageHosting CostLicense
MemoryFreeMIT
Neo4jMedium-HighCommunity (GPL) / Enterprise
QdrantLow-MediumApache 2.0
pgvectorLowPostgreSQL License
FalkorDBLowSSPL / Commercial
RedisLow-MediumRSALv2 / Commercial

Namespace Isolation

All storage backends support namespace isolation for multi-tenancy:

typescript
// Each namespace gets its own isolated storage
const graph1 = createGraph({
  namespace: "tenant-1",
  storage: { ... }
});

const graph2 = createGraph({
  namespace: "tenant-2",
  storage: { ... }
});

How namespaces are implemented:

  • Memory: Separate in-memory instances
  • Neo4j: Label-based isolation (namespace__tenant-1)
  • DozerDB: Label-based isolation (namespace__tenant-1)
  • Qdrant: Collection prefixes (namespace_tenant-1_index)
  • pgvector: Table prefixes (namespace_tenant_1_index)
  • FalkorDB: Graph name prefixes
  • Redis: Key prefixes (namespace:tenant-1:key)

Migration & Persistence

Development to Production

typescript
// Step 1: Export from memory storage
const data = await graph.export('json');

// Step 2: Initialize production storage
const prodGraph = createGraph({
  storage: {
    graph: neo4jGraph({ ... }),
    vector: qdrantVector({ ... }),
    kv: redisKV({ ... })
  }
});

// Step 3: Import data
await prodGraph.import(data);

Backup Strategies

Each storage backend has its own backup approach:

  • Memory: Use export() to save to JSON
  • Neo4j: Use neo4j-admin dump or GDS backup
  • Qdrant: Use collection snapshots
  • pgvector: Use pg_dump
  • FalkorDB: Use Redis RDB/AOF persistence
  • Redis: Use RDB snapshots or AOF logs

Next Steps

External Resources

Released under the Elastic License 2.0.