# sushruth3002/graph-rag architecture

> Architecture diagram of the GitHub repository sushruth3002/graph-rag, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sushruth3002/graph-rag
- Repository: https://github.com/sushruth3002/graph-rag

## Overview

Graph RAG ingests documents, builds a knowledge graph and vector index, then answers user questions through query understanding, retrieval, context assembly, and LLM generation. The README documents the major pipeline stages and retrieval modes; the sampled source confirms the query/retrieval relationship and embedding backends. Some pipeline wiring is documented rather than visible in the excerpts, so edges for those stages reflect README-described data flow.

Main entry points: [`main.py`](https://github.com/sushruth3002/graph-rag/blob/graph-rag/v1/main.py) (Pipeline Runner), [`src/graph_embeddings.py`](https://github.com/sushruth3002/graph-rag/blob/graph-rag/v1/src/graph_embeddings.py) (Graph Embeddings), [`src/retrieval_engine.py`](https://github.com/sushruth3002/graph-rag/blob/graph-rag/v1/src/retrieval_engine.py) (Retrieval Engine), [`src/answer_generator.py`](https://github.com/sushruth3002/graph-rag/blob/graph-rag/v1/src/answer_generator.py) (Answer Generation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingest["Document Processing"]
  node_ingestion["Data Ingestion<br/>[data_ingestion.py]"]
  node_chunking["Chunking<br/>[chunking.py]"]
  node_entities["Entity Extraction"]
  node_relations["Relationship Extraction"]
end

subgraph group_knowledge["Knowledge Indexing"]
  node_builder["Graph Builder<br/>[graph_builder.py]"]
  node_graph_embed["Graph Embeddings"]
end

subgraph group_query["Question Answering"]
  node_main["Pipeline Runner<br/>[main.py]"]
  node_query_processor["Query Processor<br/>[query_processor.py]"]
  node_retrieval["Retrieval Engine"]
  node_context["Context Assembly"]
  node_answer["Answer Generation"]
end

subgraph group_stores["Storage"]
  node_vector_store[("Vector Store<br/>[vector_store.py]")]
  node_redis_store[("Redis Vectors")]
  node_neo4j_store[("Neo4j Store<br/>[neo4j_store.py]")]
  node_hybrid_store["Hybrid Graph Store"]
end

subgraph group_models["Model Services"]
  node_embedding_client["Embedding Client"]
end

node_user(("Questioner"))
node_documents["Source Documents"]
node_llm{{"LLM Service"}}
node_embedding_model{{"Embedding Backend"}}
node_response["Cited Answer"]

node_documents -->|"provides files"| node_main
node_main -->|"loads documents"| node_ingestion
node_ingestion -->|"document text"| node_chunking
node_chunking -->|"text chunks"| node_entities
node_entities -->|"extracted entities"| node_relations
node_relations -->|"extracted relationships"| node_builder
node_builder -->|"persists graph"| node_neo4j_store
node_main -->|"indexes graph"| node_graph_embed
node_graph_embed -->|"reads graph"| node_neo4j_store
node_graph_embed -->|"creates vectors"| node_embedding_client
node_embedding_client -.->|"requests embeddings"| node_embedding_model
node_graph_embed -->|"indexes vectors"| node_vector_store
node_graph_embed -.->|"indexes vectors"| node_redis_store
node_user -->|"asks question"| node_main
node_main -->|"submits query"| node_query_processor
node_main -->|"requests results"| node_retrieval
node_retrieval -->|"parses query"| node_query_processor
node_retrieval -->|"searches vectors"| node_hybrid_store
node_retrieval -->|"traverses graph"| node_neo4j_store
node_hybrid_store -->|"searches vectors"| node_vector_store
node_hybrid_store -.->|"searches vectors"| node_redis_store
node_retrieval -->|"retrieval results"| node_context
node_main -->|"assembles context"| node_context
node_main -->|"requests answer"| node_answer
node_answer -->|"generates response"| node_llm
node_answer -->|"returns cited answer"| node_response
node_main -->|"presents answer"| node_user

click node_main "https://github.com/sushruth3002/graph-rag/blob/graph-rag/v1/main.py"
click node_ingestion "https://github.com/sushruth3002/graph-rag/blob/graph-rag/v1/src/data_ingestion.py"
click node_chunking "https://github.com/sushruth3002/graph-rag/blob/graph-rag/v1/src/chunking.py"
click node_entities "https://github.com/sushruth3002/graph-rag/blob/graph-rag/v1/src/entity_extraction.py"
click node_relations "https://github.com/sushruth3002/graph-rag/blob/graph-rag/v1/src/relationship_extraction.py"
click node_builder "https://github.com/sushruth3002/graph-rag/blob/graph-rag/v1/src/graph_builder.py"
click node_graph_embed "https://github.com/sushruth3002/graph-rag/blob/graph-rag/v1/src/graph_embeddings.py"
click node_embedding_client "https://github.com/sushruth3002/graph-rag/blob/graph-rag/v1/src/embeddings_client.py"
click node_vector_store "https://github.com/sushruth3002/graph-rag/blob/graph-rag/v1/src/vector_store.py"
click node_redis_store "https://github.com/sushruth3002/graph-rag/blob/graph-rag/v1/src/redis_vectorstore.py"
click node_neo4j_store "https://github.com/sushruth3002/graph-rag/blob/graph-rag/v1/src/neo4j_store.py"
click node_hybrid_store "https://github.com/sushruth3002/graph-rag/blob/graph-rag/v1/src/hybrid_graph_store.py"
click node_query_processor "https://github.com/sushruth3002/graph-rag/blob/graph-rag/v1/src/query_processor.py"
click node_retrieval "https://github.com/sushruth3002/graph-rag/blob/graph-rag/v1/src/retrieval_engine.py"
click node_context "https://github.com/sushruth3002/graph-rag/blob/graph-rag/v1/src/context_assembler.py"
click node_answer "https://github.com/sushruth3002/graph-rag/blob/graph-rag/v1/src/answer_generator.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_ingestion,node_chunking,node_entities,node_relations toneBlue
class node_builder,node_graph_embed toneAmber
class node_main,node_query_processor,node_retrieval,node_context,node_answer toneMint
class node_vector_store,node_redis_store,node_neo4j_store,node_hybrid_store toneRose
class node_embedding_client,node_user,node_documents,node_llm,node_embedding_model,node_response toneIndigo
```

## Components

### Document Processing

- [Data Ingestion](https://github.com/sushruth3002/graph-rag/blob/graph-rag/v1/src/data_ingestion.py): `src/data_ingestion.py`
- [Chunking](https://github.com/sushruth3002/graph-rag/blob/graph-rag/v1/src/chunking.py): `src/chunking.py`
- [Entity Extraction](https://github.com/sushruth3002/graph-rag/blob/graph-rag/v1/src/entity_extraction.py): `src/entity_extraction.py`
- [Relationship Extraction](https://github.com/sushruth3002/graph-rag/blob/graph-rag/v1/src/relationship_extraction.py): `src/relationship_extraction.py`

### Knowledge Indexing

- [Graph Builder](https://github.com/sushruth3002/graph-rag/blob/graph-rag/v1/src/graph_builder.py): `src/graph_builder.py`
- [Graph Embeddings](https://github.com/sushruth3002/graph-rag/blob/graph-rag/v1/src/graph_embeddings.py): `src/graph_embeddings.py`

### Question Answering

- [Pipeline Runner](https://github.com/sushruth3002/graph-rag/blob/graph-rag/v1/main.py): `main.py`
- [Query Processor](https://github.com/sushruth3002/graph-rag/blob/graph-rag/v1/src/query_processor.py): `src/query_processor.py`
- [Retrieval Engine](https://github.com/sushruth3002/graph-rag/blob/graph-rag/v1/src/retrieval_engine.py): `src/retrieval_engine.py`
- [Context Assembly](https://github.com/sushruth3002/graph-rag/blob/graph-rag/v1/src/context_assembler.py): `src/context_assembler.py`
- [Answer Generation](https://github.com/sushruth3002/graph-rag/blob/graph-rag/v1/src/answer_generator.py): `src/answer_generator.py`

### Storage

- [Vector Store](https://github.com/sushruth3002/graph-rag/blob/graph-rag/v1/src/vector_store.py): `src/vector_store.py`
- [Redis Vectors](https://github.com/sushruth3002/graph-rag/blob/graph-rag/v1/src/redis_vectorstore.py): `src/redis_vectorstore.py`
- [Neo4j Store](https://github.com/sushruth3002/graph-rag/blob/graph-rag/v1/src/neo4j_store.py): `src/neo4j_store.py`
- [Hybrid Graph Store](https://github.com/sushruth3002/graph-rag/blob/graph-rag/v1/src/hybrid_graph_store.py): `src/hybrid_graph_store.py`

### Model Services

- [Embedding Client](https://github.com/sushruth3002/graph-rag/blob/graph-rag/v1/src/embeddings_client.py): `src/embeddings_client.py`

### Other components

- **Questioner**
- **Source Documents**
- **LLM Service**
- **Embedding Backend**
- **Cited Answer**

## Connections

- Source Documents → Pipeline Runner: provides files
- Pipeline Runner → Data Ingestion: loads documents
- Data Ingestion → Chunking: document text
- Chunking → Entity Extraction: text chunks
- Entity Extraction → Relationship Extraction: extracted entities
- Relationship Extraction → Graph Builder: extracted relationships
- Graph Builder → Neo4j Store: persists graph
- Pipeline Runner → Graph Embeddings: indexes graph
- Graph Embeddings → Neo4j Store: reads graph
- Graph Embeddings → Embedding Client: creates vectors
- Embedding Client → Embedding Backend: requests embeddings
- Graph Embeddings → Vector Store: indexes vectors
- Graph Embeddings → Redis Vectors: indexes vectors
- Questioner → Pipeline Runner: asks question
- Pipeline Runner → Query Processor: submits query
- Pipeline Runner → Retrieval Engine: requests results
- Retrieval Engine → Query Processor: parses query
- Retrieval Engine → Hybrid Graph Store: searches vectors
- Retrieval Engine → Neo4j Store: traverses graph
- Hybrid Graph Store → Vector Store: searches vectors
- Hybrid Graph Store → Redis Vectors: searches vectors
- Retrieval Engine → Context Assembly: retrieval results
- Pipeline Runner → Context Assembly: assembles context
- Pipeline Runner → Answer Generation: requests answer
- Answer Generation → LLM Service: generates response
- Answer Generation → Cited Answer: returns cited answer
- Pipeline Runner → Questioner: presents answer
