# meghashyam0711/rag architecture

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

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

## Overview

GraphRAG Reader is an MCP document-retrieval server. An MCP client submits documents for layout-aware parsing, chunking, entity extraction and resolution, then the engine indexes chunks and graph relations. For questions, the server runs hybrid retrieval inside a self-corrective workflow that grades evidence, retries or abstains, and verifies cited answers; it also exposes graph tracing, table extraction and index status. The README documents these capabilities and major integrations; several subsystem details are unsampled, so their internal links are omitted.

Main entry points: [`src/graphrag/engine.py`](https://github.com/meghashyam0711/rag/blob/main/src/graphrag/engine.py) (GraphRAG Engine), [`src/graphrag/retrieval/hybrid.py`](https://github.com/meghashyam0711/rag/blob/main/src/graphrag/retrieval/hybrid.py) (Hybrid Retrieval), [`src/graphrag/agent/nodes.py`](https://github.com/meghashyam0711/rag/blob/main/src/graphrag/agent/nodes.py) (RAG Nodes), [`src/graphrag/indexing/qdrant_store.py`](https://github.com/meghashyam0711/rag/blob/main/src/graphrag/indexing/qdrant_store.py) (Vector Index)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["MCP Interface"]
  node_mcp_entry["MCP Entrypoint<br/>[mcp_server.py]"]
  node_mcp_server["MCP Tools<br/>[server.py]"]
  node_engine["GraphRAG Engine<br/>[engine.py]"]
end

subgraph group_ingestion["Document Ingestion"]
  node_layout["Layout Parser<br/>[layout_parser.py]"]
  node_chunker["Contextual Chunker<br/>[chunker.py]"]
  node_extractor["Graph Extractor<br/>[graph_extractor.py]"]
  node_resolver["Entity Resolver<br/>[entity_resolver.py]"]
end

subgraph group_stores["Indexes and Retrieval"]
  node_embedder["Text Embeddings<br/>[embeddings.py]"]
  node_vector_store[("Vector Index<br/>[qdrant_store.py]")]
  node_graph_store[("Knowledge Graph<br/>[graph_store.py]")]
  node_retriever["Hybrid Retrieval<br/>[hybrid.py]"]
  node_reranker["Evidence Reranker<br/>[reranker.py]"]
end

subgraph group_answers["Verified Answers"]
  node_workflow["RAG Workflow<br/>[workflow.py]"]
  node_state["Workflow State<br/>[state.py]"]
  node_nodes["RAG Nodes<br/>[nodes.py]"]
  node_sandbox["Math Sandbox<br/>[sandbox.py]"]
  node_llm["Optional LLM<br/>[llm.py]"]
end

subgraph group_contracts["Shared Runtime"]
  node_models["Domain Models<br/>[models.py]"]
  node_config["Runtime Settings<br/>[config.py]"]
end

node_client(("MCP Client"))

node_client -->|"invokes tools"| node_mcp_entry
node_mcp_entry -->|"starts server"| node_mcp_server
node_mcp_server -->|"dispatches requests"| node_engine
node_engine -->|"parses documents"| node_layout
node_engine -->|"chunks blocks"| node_chunker
node_engine -->|"extracts relations"| node_extractor
node_engine -->|"canonicalizes entities"| node_resolver
node_engine -->|"upserts chunks"| node_vector_store
node_engine -->|"upserts graph"| node_graph_store
node_engine -->|"runs questions"| node_workflow
node_engine -->|"retrieves evidence"| node_retriever
node_engine -->|"traces relations"| node_graph_store
node_engine -->|"extracts tables"| node_vector_store
node_engine -->|"uses settings"| node_config
node_retriever -->|"searches vectors"| node_vector_store
node_retriever -->|"traverses graph"| node_graph_store
node_retriever -->|"links mentions"| node_resolver
node_retriever -->|"reranks evidence"| node_reranker
node_vector_store -->|"encodes text"| node_embedder
node_workflow -->|"dispatches steps"| node_nodes
node_workflow -->|"carries state"| node_state
node_nodes -->|"retrieves evidence"| node_retriever
node_nodes -->|"checks calculations"| node_sandbox
node_nodes -.->|"uses optional model"| node_llm

click node_mcp_entry "https://github.com/meghashyam0711/rag/blob/main/mcp_server.py"
click node_mcp_server "https://github.com/meghashyam0711/rag/blob/main/src/graphrag/server.py"
click node_engine "https://github.com/meghashyam0711/rag/blob/main/src/graphrag/engine.py"
click node_layout "https://github.com/meghashyam0711/rag/blob/main/src/graphrag/ingestion/layout_parser.py"
click node_chunker "https://github.com/meghashyam0711/rag/blob/main/src/graphrag/ingestion/chunker.py"
click node_extractor "https://github.com/meghashyam0711/rag/blob/main/src/graphrag/ingestion/graph_extractor.py"
click node_resolver "https://github.com/meghashyam0711/rag/blob/main/src/graphrag/ingestion/entity_resolver.py"
click node_embedder "https://github.com/meghashyam0711/rag/blob/main/src/graphrag/indexing/embeddings.py"
click node_vector_store "https://github.com/meghashyam0711/rag/blob/main/src/graphrag/indexing/qdrant_store.py"
click node_graph_store "https://github.com/meghashyam0711/rag/blob/main/src/graphrag/indexing/graph_store.py"
click node_retriever "https://github.com/meghashyam0711/rag/blob/main/src/graphrag/retrieval/hybrid.py"
click node_reranker "https://github.com/meghashyam0711/rag/blob/main/src/graphrag/retrieval/reranker.py"
click node_workflow "https://github.com/meghashyam0711/rag/blob/main/src/graphrag/agent/workflow.py"
click node_state "https://github.com/meghashyam0711/rag/blob/main/src/graphrag/agent/state.py"
click node_nodes "https://github.com/meghashyam0711/rag/blob/main/src/graphrag/agent/nodes.py"
click node_sandbox "https://github.com/meghashyam0711/rag/blob/main/src/graphrag/agent/sandbox.py"
click node_llm "https://github.com/meghashyam0711/rag/blob/main/src/graphrag/llm.py"
click node_models "https://github.com/meghashyam0711/rag/blob/main/src/graphrag/models.py"
click node_config "https://github.com/meghashyam0711/rag/blob/main/src/graphrag/config.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_mcp_entry,node_mcp_server,node_engine,node_client toneBlue
class node_layout,node_chunker,node_extractor,node_resolver toneAmber
class node_embedder,node_vector_store,node_graph_store,node_retriever,node_reranker toneMint
class node_workflow,node_state,node_nodes,node_sandbox,node_llm toneRose
class node_models,node_config toneIndigo
```

## Components

### MCP Interface

- [MCP Entrypoint](https://github.com/meghashyam0711/rag/blob/main/mcp_server.py): `mcp_server.py`
- [MCP Tools](https://github.com/meghashyam0711/rag/blob/main/src/graphrag/server.py): `src/graphrag/server.py`
- [GraphRAG Engine](https://github.com/meghashyam0711/rag/blob/main/src/graphrag/engine.py): `src/graphrag/engine.py`

### Document Ingestion

- [Layout Parser](https://github.com/meghashyam0711/rag/blob/main/src/graphrag/ingestion/layout_parser.py): `src/graphrag/ingestion/layout_parser.py`
- [Contextual Chunker](https://github.com/meghashyam0711/rag/blob/main/src/graphrag/ingestion/chunker.py): `src/graphrag/ingestion/chunker.py`
- [Graph Extractor](https://github.com/meghashyam0711/rag/blob/main/src/graphrag/ingestion/graph_extractor.py): `src/graphrag/ingestion/graph_extractor.py`
- [Entity Resolver](https://github.com/meghashyam0711/rag/blob/main/src/graphrag/ingestion/entity_resolver.py): `src/graphrag/ingestion/entity_resolver.py`

### Indexes and Retrieval

- [Text Embeddings](https://github.com/meghashyam0711/rag/blob/main/src/graphrag/indexing/embeddings.py): `src/graphrag/indexing/embeddings.py`
- [Vector Index](https://github.com/meghashyam0711/rag/blob/main/src/graphrag/indexing/qdrant_store.py): `src/graphrag/indexing/qdrant_store.py`
- [Knowledge Graph](https://github.com/meghashyam0711/rag/blob/main/src/graphrag/indexing/graph_store.py): `src/graphrag/indexing/graph_store.py`
- [Hybrid Retrieval](https://github.com/meghashyam0711/rag/blob/main/src/graphrag/retrieval/hybrid.py): `src/graphrag/retrieval/hybrid.py`
- [Evidence Reranker](https://github.com/meghashyam0711/rag/blob/main/src/graphrag/retrieval/reranker.py): `src/graphrag/retrieval/reranker.py`

### Verified Answers

- [RAG Workflow](https://github.com/meghashyam0711/rag/blob/main/src/graphrag/agent/workflow.py): `src/graphrag/agent/workflow.py`
- [Workflow State](https://github.com/meghashyam0711/rag/blob/main/src/graphrag/agent/state.py): `src/graphrag/agent/state.py`
- [RAG Nodes](https://github.com/meghashyam0711/rag/blob/main/src/graphrag/agent/nodes.py): `src/graphrag/agent/nodes.py`
- [Math Sandbox](https://github.com/meghashyam0711/rag/blob/main/src/graphrag/agent/sandbox.py): `src/graphrag/agent/sandbox.py`
- [Optional LLM](https://github.com/meghashyam0711/rag/blob/main/src/graphrag/llm.py): `src/graphrag/llm.py`

### Shared Runtime

- [Domain Models](https://github.com/meghashyam0711/rag/blob/main/src/graphrag/models.py): `src/graphrag/models.py`
- [Runtime Settings](https://github.com/meghashyam0711/rag/blob/main/src/graphrag/config.py): `src/graphrag/config.py`

### Other components

- **MCP Client**

## Connections

- MCP Client → MCP Entrypoint: invokes tools (evidence: `README.md`)
- MCP Entrypoint → MCP Tools: starts server (evidence: `mcp_server.py`)
- MCP Tools → GraphRAG Engine: dispatches requests (evidence: `README.md`)
- GraphRAG Engine → Layout Parser: parses documents (evidence: `src/graphrag/engine.py`)
- GraphRAG Engine → Contextual Chunker: chunks blocks (evidence: `src/graphrag/engine.py`)
- GraphRAG Engine → Graph Extractor: extracts relations (evidence: `README.md`)
- GraphRAG Engine → Entity Resolver: canonicalizes entities (evidence: `src/graphrag/engine.py`)
- GraphRAG Engine → Vector Index: upserts chunks (evidence: `src/graphrag/engine.py`)
- GraphRAG Engine → Knowledge Graph: upserts graph (evidence: `src/graphrag/engine.py`)
- GraphRAG Engine → RAG Workflow: runs questions (evidence: `src/graphrag/engine.py`)
- GraphRAG Engine → Hybrid Retrieval: retrieves evidence (evidence: `README.md`)
- GraphRAG Engine → Knowledge Graph: traces relations (evidence: `README.md`)
- GraphRAG Engine → Vector Index: extracts tables (evidence: `README.md`)
- GraphRAG Engine → Runtime Settings: uses settings (evidence: `src/graphrag/engine.py`)
- Hybrid Retrieval → Vector Index: searches vectors (evidence: `README.md`)
- Hybrid Retrieval → Knowledge Graph: traverses graph (evidence: `README.md`)
- Hybrid Retrieval → Entity Resolver: links mentions (evidence: `src/graphrag/retrieval/hybrid.py`)
- Hybrid Retrieval → Evidence Reranker: reranks evidence (evidence: `src/graphrag/retrieval/hybrid.py`)
- Vector Index → Text Embeddings: encodes text (evidence: `src/graphrag/indexing/qdrant_store.py`)
- RAG Workflow → RAG Nodes: dispatches steps (evidence: `src/graphrag/agent/workflow.py`)
- RAG Workflow → Workflow State: carries state (evidence: `src/graphrag/agent/workflow.py`)
- RAG Nodes → Hybrid Retrieval: retrieves evidence (evidence: `src/graphrag/agent/nodes.py`)
- RAG Nodes → Math Sandbox: checks calculations (evidence: `src/graphrag/agent/nodes.py`)
- RAG Nodes → Optional LLM: uses optional model (evidence: `src/graphrag/agent/nodes.py`)
