Back to articles

GraphRAG Architecture

Choosing the storage layer for a ContextGraph

GraphRAG needs more than a place to put nodes and edges. The storage layer shapes how you model identity, traverse relationships, explain retrieval, operate updates, and keep graph evidence consistent with the rest of the system.

Once entity extraction and taxonomy start producing canonical nodes, the next question is where those nodes should live. Neo4j and Azure Cosmos DB for Apache Gremlin are common options. Amazon Neptune, ArangoDB, PostgreSQL-based approaches, and search or vector stores with lightweight adjacency tables are also worth considering depending on the product shape.

The decision should not start with vendor preference. It should start with graph behavior. Do you need deep traversals, relationship-heavy queries, graph algorithms, multi-region managed scale, RDF semantics, document-plus-graph storage, or just enough edges to expand retrieval candidates before reranking?

Purpose-built graph database

Best when relationships are the core data model. Neo4j and Neptune fit here: graph queries, traversals, and path reasoning are first-class concerns.

Cloud database with graph API

Best when managed scale and platform integration matter. Azure Cosmos DB for Apache Gremlin stores graph data through Cosmos DB's distributed service model.

The fundamental difference

The biggest split is between a graph-native engine and a distributed database that exposes a graph traversal API. A graph-native database is optimized around nodes, relationships, indexes, path patterns, and graph query planning. A distributed database with a graph API is optimized around partitioning, global availability, throughput management, and operational integration.

That distinction affects how a ContextGraph behaves. Graph-native systems tend to feel natural when you ask questions like "what path connects this incident to this customer impact?" Distributed graph APIs tend to be attractive when your priority is managed cloud scale, regional replication, and predictable service operations.

Graph storage decision tree
flowchart TD
    Start["What does ContextGraph need most?"] --> Deep{"Deep traversals, paths, graph debugging?"}
    Deep -- "Yes" --> Neo4j["Neo4j"]
    Deep -- "No" --> Azure{"Azure managed scale and platform fit?"}
    Azure -- "Yes" --> Cosmos["Azure Cosmos DB for Apache Gremlin"]
    Azure -- "No" --> Aws{"AWS-first or RDF/SPARQL pressure?"}
    Aws -- "Yes" --> Neptune["Amazon Neptune"]
    Aws -- "No" --> Multi{"Need document and graph in one store?"}
    Multi -- "Yes" --> Arango["ArangoDB"]
    Multi -- "No" --> Shallow{"Small, shallow, app-coupled graph?"}
    Shallow -- "Yes" --> Postgres["PostgreSQL graph-shaped tables"]
    Shallow -- "No" --> Revisit["Prototype query patterns before choosing"]
01

Model the retrieval question

Decide whether queries need shallow expansion, multi-hop paths, graph algorithms, temporal edges, provenance walks, or permission-aware traversal.

02

Pick the graph contract

Choose property graph, RDF, document-plus-edge, or relational adjacency based on the query patterns the application must support.

03

Evaluate operations

Compare backup, scaling, cloud fit, data residency, developer skills, observability, migration paths, and how aliases and merge history are stored.

Neo4j

Neo4j is the most direct choice when the application thinks in graph patterns. Its Cypher query language is declarative and graph-oriented, which makes questions about paths, neighborhoods, labels, relationship types, and variable-length traversals readable to engineers. For ContextGraph work, that readability matters: retrieval explanations and debugging often need humans to inspect why a path was followed.

Neo4j is strong when you expect rich graph modeling, graph algorithms, manual graph inspection, and iterative schema evolution. It is a good fit for canonical entity graphs, knowledge graphs, dependency maps, identity resolution, and retrieval debugging tools where relationships are not incidental metadata.

The tradeoff is operational gravity. You are committing to a specialized graph platform. That can be exactly right, but it means thinking about hosting, AuraDB or self-managed operations, query tuning, import workflows, security boundaries, and how the graph syncs with source-of-truth systems.

Azure Cosmos DB for Apache Gremlin

Azure Cosmos DB for Apache Gremlin is Azure's managed graph database option built around the Apache TinkerPop Gremlin traversal language. It is attractive when the application is already Azure-native and needs a managed service with Cosmos DB's operational model: throughput provisioning, global distribution patterns, and cloud platform integration.

The mental model is different from Neo4j. Gremlin is a traversal language: you describe how to move through the graph step by step. That can be powerful, but it is often less approachable than Cypher for product engineers reading retrieval logic. In return, you get a graph API on a distributed cloud database rather than a graph-specialized product standing apart from the rest of the Azure architecture.

Cosmos DB for Gremlin is a good candidate when graph traversals are important but not the only thing the organization optimizes for. It is less ideal if the product needs heavy graph algorithms, deep exploratory graph analytics, or a Cypher-first graph development workflow.

Amazon Neptune

Amazon Neptune is AWS's managed graph database. It supports property graph work through Gremlin and openCypher, and RDF work through SPARQL. That makes it relevant when the system has both knowledge graph and application graph pressures, or when an AWS-centered architecture wants a managed graph engine without operating Neo4j directly.

Neptune is worth considering if your graph may evolve toward semantic-web style RDF data, standards-driven knowledge representation, or multiple graph query languages. The tradeoff is that the surrounding architecture and developer experience are AWS shaped. For an Azure-heavy environment, that cost may outweigh the feature fit.

ArangoDB

ArangoDB is a native multi-model database: document, key-value, and graph data live in one platform and can be queried together. That is useful when ContextGraph nodes have rich JSON documents attached and the product does not want a separate document store beside the graph.

The advantage is consolidation. You can store entity records, metadata, and edges in one system. The risk is choosing a multi-model database when the graph workload eventually becomes deep enough that a graph-specialist engine would have been a better long-term fit.

Neo4j

Graph-first, Cypher-first, excellent for path reasoning, graph debugging, knowledge graph modeling, and teams that want expressive graph queries.

Azure Cosmos DB Gremlin

Managed Azure graph API, Gremlin traversal model, useful when global cloud operations and Azure integration matter more than graph-specialist ergonomics.

Amazon Neptune

Managed AWS graph database with Gremlin, openCypher, and SPARQL support. Strong when AWS fit or RDF knowledge graph needs are part of the decision.

ArangoDB

Multi-model document and graph store. Strong when entity documents and graph edges should live together, weaker if you need the deepest graph specialization.

PostgreSQL plus graph-shaped tables

A dedicated graph database is not mandatory for the first version. If your graph is mostly canonical entities, aliases, source documents, and one or two-hop expansion, PostgreSQL tables can be enough: entities, aliases, relations, evidence_spans, and merge_events. Recursive queries or application-side traversal can support early retrieval.

This approach is boring in a useful way. It keeps transactions, migrations, permissions, and operational tooling close to the rest of the app. The limit appears when graph traversal becomes a core query workload. At that point, recursive SQL and hand-rolled traversal logic can become harder to understand than a proper graph query.

Vector stores are not graph stores

Vector databases are good at similarity search. They are not a replacement for graph identity, aliases, edge provenance, canonical merge history, or relationship traversal. A GraphRAG stack can use a vector store for passage candidates and a graph store for connected evidence. The two systems answer different questions.

The common hybrid pattern is simple: vector search finds semantically close chunks, the graph expands around recognized entities, filters remove unauthorized evidence, and a reranker chooses the final context. Storage should make that loop easy to explain and debug.

Decision example

ContextGraph needs to connect Content Discovery AI, its aliases, runbooks, repositories, incidents, owning teams, and downstream services. Retrieval usually expands two hops, but product debugging needs readable path explanations.

Neo4j: best graph ergonomics Cosmos Gremlin: best Azure-managed fit Neptune: best AWS/RDF fit PostgreSQL: best early operational simplicity

How to choose for ContextGraph

Choose Neo4j when graph behavior is central to the product experience: rich paths, graph debugging, canonical identity inspection, relationship-heavy queries, and developer-friendly graph modeling. Choose Azure Cosmos DB for Apache Gremlin when the team wants managed Azure operations and the graph access pattern is mostly controlled traversal at cloud scale.

Choose Neptune when the organization is AWS-first or when RDF/SPARQL support matters alongside property graph queries. Choose ArangoDB when the strongest pressure is storing documents and graph edges together in one multi-model database. Start with PostgreSQL when the graph is still small, shallow, and tightly coupled to the app's transactional model.

The most important design rule is portability of meaning. Keep canonical IDs, aliases, merge events, edge provenance, and source document references explicit in your application model. If those concepts are clean, you can change the backing graph technology later with much less pain.

An error has occurred. This application may no longer respond until reloaded. Reload 🗙