A Production-Grade Full-Stack Monorepo Pairing Deterministic AST Knowledge Graphs with High-Dimensional Vector Search & Model Context Protocol (MCP).
Key Features β’ The Core Problem β’ System Architecture β’ Visual Preview β’ Tech Stack β’ MCP Tools β’ Monorepo Structure β’ 1-Click Quickstart β’ Benchmarks β’ Author & License
- π Polyglot Scope-Resolved AST Traversal: Uses Tree-sitter parsers across Python, Java, TypeScript, C++, and Go to build deterministic abstract syntax trees, identifying precise class scopes, function signatures, docstrings, and cross-file import statements.
-
πΈοΈ Deterministic Property Knowledge Graphs: Ingests files, classes, methods, and call sites into Neo4j with bi-directional relationships (
[:CONTAINS],[:CALLS],[:EXTENDS],[:IMPORTS]), unlocking instant$N$ -hop multi-level blast-radius analysis. - β‘ Dual-Stream Context Retrieval: Merges high-dimensional dense code vector search (Qdrant + local 384D BGE / 3072D Gemini embeddings) with structural graph traversal context to completely eliminate code-hallucination.
-
π€ Autonomous Refactor & Patch Synthesizer: Produces unified Git patches (
--- a//+++ b/) tailored to codebase architecture, simulating impacts before changes are committed. - π Native Model Context Protocol (MCP): Exposes a standardized stdio JSON-RPC 2.0 interface for instantaneous integration with VS Code, Cursor IDE, and Claude Desktop.
-
π‘οΈ Multi-Tier Resilient Model Failover: Built-in automatic retry and fallback across Gemini models (
gemini-2.5-flash,gemini-3.8-flash,gemini-1.5-pro) to gracefully mitigate quota (429) and server (503) rate limits. - π Blast-Radius Command Center: Visualizes impact assessment, affected callers, and dependency chains in an interactive React 18 dashboard.
Standard Code RAG systems rely strictly on naive chunked vector embeddings. When applied to production-scale codebases, this introduces severe context fragmentation:
Warning
Vector search excels at finding textually similar fragments, but is fundamentally blind to execution flows:
- It cannot answer: "If I modify function
generateToken(), which 4 upstream controllers and service layers will break?" - It misses indirect callers, inheritance overrides, and cross-file interface implementations.
- It splits function signatures away from their enclosing class scopes and global decorators.
Tip
CodeGraph-RAG pairs semantic vector retrieval with a deterministic Neo4j Property Knowledge Graph:
-
Deterministic Scope Attribution: Every code chunk is tagged with its fully-qualified hierarchical identifier (
package.Class.method). -
Multi-Hop Dependency Traversal: Cypher queries trace call graphs upstream and downstream to arbitrary depths (
$N$ -hops). - Contextual Fusion: LLM prompts receive both relevant semantic snippets and exact architectural dependency paths.
| Capability | Naive Vector-Only RAG | Graph-Only Retrieval | π CodeGraph-RAG (Dual Stream) |
|---|---|---|---|
| Semantic Keyword & Intent Search | β High | β None | β Optimal (Qdrant + BGE) |
| Blast Radius & Impact Analysis | β Fails (Hallucinates) | β Strong | β 100% Deterministic (Neo4j) |
| Caller / Callee Hierarchy Tracing | β Incomplete | β Exact | β Exhaustive Multi-Hop |
| Enclosing Scope Awareness | β Chunks Cut Arbitrarily | β Structural | β Exact Class & Method Mapping |
| Unified Patch / Diff Generation | β Code Unaware | β Architectural-Aligned Diffs | |
| IDE Agent Integration (MCP) | β Standard Stdio JSON-RPC 2.0 |
flowchart TD
subgraph Client ["Client & Interface Layer"]
UI["React 18 Dashboard\n(Vite + Tailwind CSS :5173)"]
IDE["Cursor / VS Code / Claude Desktop\n(Model Context Protocol)"]
end
subgraph Backend ["FastAPI Backend & MCP Engine (:8000)"]
API["FastAPI REST Router\n(/auth, /workspace, /rag)"]
MCP["FastMCP Stdio Server\n(JSON-RPC 2.0 Protocol)"]
end
subgraph CoreEngine ["Ingestion & AST Engine"]
Parser["Polyglot Tree-sitter Parser\n(Python, TS, Go, Java, C++)"]
Scope["Hierarchical Scope Resolver\n(Classes, Methods, Imports)"]
end
subgraph DualRetrieval ["Dual-Stream Knowledge Engine"]
Qdrant[("Qdrant Vector Store\n(384D BGE Dense Embeddings)")]
Neo4j[("Neo4j Property Graph\n(Nodes: File/Class/Method | Edges: CALLS/IMPORTS)")]
end
subgraph Reasoning ["LLM Synthesis & Failover Mesh"]
Fusion["Hybrid Context Fusion & Re-ranker"]
LLM["Google Gemini Reasoning Engine\n(2.5-Flash β 3.8-Flash β 1.5-Pro)"]
Synthesizer["Diff Synthesizer & Blast-Radius Formatter"]
end
UI -->|"HTTP / REST API (JWT)"| API
IDE -->|"Stdio JSON-RPC"| MCP
API --> CoreEngine
MCP --> CoreEngine
CoreEngine --> Parser --> Scope
Scope -->|"Vectorize Chunks"| Qdrant
Scope -->|"Populate Topology"| Neo4j
API --> DualRetrieval
MCP --> DualRetrieval
Qdrant -->|"Top-K Semantic Matches"| Fusion
Neo4j -->|"N-Hop Call Chains & Blast Radius"| Fusion
Fusion --> LLM --> Synthesizer
Synthesizer -->|"Unified Diff & Impact Map"| API
Synthesizer -->|"Structured Tool Output"| MCP
style Client fill:#eff6ff,stroke:#3b82f6,stroke-width:2px
style Backend fill:#f8fafc,stroke:#64748b,stroke-width:2px
style DualRetrieval fill:#f0fdf4,stroke:#22c55e,stroke-width:2px
style Reasoning fill:#fdf4ff,stroke:#d946ef,stroke-width:2px
π Text-Based ASCII Architecture View (Click to expand)
βββββββββββββββββββββββββββββββββββ
β Developer / Web / Cursor / IDE β
ββββββββββββββββββ¬βββββββββββββββββ
β
ββββββββββββββββββββββββββββ΄βββββββββββββββββββββββββββ
βΌ βΌ
[ React 18 SPA Dashboard ] [ FastMCP Stdio Server ]
(Port 5173 - Tailwind) (JSON-RPC 2.0 Engine)
β β
β REST API (Bearer JWT) β Service Calls
βΌ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β FastAPI Backend Server β β
β (Port 8000) β β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββ€ β
β β’ /api/auth/* : Session & JWT Provider β β
β β’ /api/workspace/* : Git Ingestion & AST Pipeline βββββββββββ
β β’ /api/rag/impact : N-Hop Blast Radius Traversal β
β β’ /api/rag/query : Dual-Stream Context Fusion β
β β’ /api/rag/refactor : Automated Patch Synthesizer β
ββββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββ
β
ββββββββββββββββββ΄βββββββββββββββββ
βΌ βΌ
[ Polyglot AST Parser ] [ Dual-Stream Knowledge Layer ]
Tree-sitter Scope Engine βββββββββββββββββ΄ββββββββββββββββ
Python, TS, Go, Java, C++ βΌ βΌ
[ Qdrant Vector DB ] [ Neo4j Graph DB ]
(384D BGE Vectors) (Property Graph)
Semantic Search Multi-Hop Blast Radius
β β
βββββββββββββββββ¬ββββββββββββββββ
βΌ
[ Gemini Reasoning Mesh ]
(Automatic Model Failover)
When registered with an MCP-compliant client (VS Code, Cursor IDE, Claude Desktop), backend/mcp_server.py dynamically exposes 4 production tools over stdio JSON-RPC 2.0:
| Tool Name | Input Parameters | Purpose & Output |
|---|---|---|
search_codebase |
query: str, top_k: int = 5 |
Performs dual-stream hybrid semantic vector search and LLM context synthesis across codebase chunks. |
analyze_symbol_impact |
target_symbol: str |
Traverses multi-hop Neo4j Cypher call paths to return the exact blast radius, all upstream callers, and potentially broken files. |
get_file_graph |
filepath: str |
Produces an exhaustive structural breakdown: classes, functions, docstrings, imports, and outgoing method invocations. |
ingest_repository |
repo_url: str |
Clones a remote Git repository or unzips a local project, running end-to-end AST extraction, vector embedding, and graph ingestion. |
π Click to view Sample MCP Tool Output (analyze_symbol_impact)
{
"target_symbol": "generateToken",
"total_affected_callers": 4,
"affected_files": [
"backend/app/services/auth_service.py",
"backend/app/api/auth.py",
"backend/app/api/admin.py",
"backend/app/services/oauth_provider.py"
],
"call_hierarchy": [
{
"caller": "AuthService.login_user",
"path": "backend/app/services/auth_service.py",
"depth": 1
},
{
"caller": "OAuthProvider.issue_bearer_token",
"path": "backend/app/services/oauth_provider.py",
"depth": 1
},
{
"caller": "api_login_endpoint",
"path": "backend/app/api/auth.py",
"depth": 2
},
{
"caller": "admin_impersonate_user",
"path": "backend/app/api/admin.py",
"depth": 2
}
]
}CodeGraph-RAG/
βββ backend/ # FastAPI REST Engine & Ingestion Services
β βββ app/
β β βββ main.py # FastAPI application entry & CORS middleware
β β βββ config.py # Pydantic Settings & environment loader
β β βββ database.py # SQLAlchemy engine & session provider
β β βββ models/ # SQLAlchemy ORM schemas
β β β βββ user.py # User entity model
β β β βββ workspace.py # Workspace repository model
β β βββ services/ # Core domain & ingestion services
β β β βββ ast_parser.py # Polyglot Tree-sitter scope extractor
β β β βββ vector_store.py # Qdrant vector database client
β β β βββ graph_store.py # Neo4j Cypher call graph engine
β β β βββ repo_ingestor.py # Git clone & ZIP extraction pipeline
β β β βββ agent_workflow.py # Dual-stream RAG reasoning & retry mesh
β β βββ api/ # REST API route handlers
β β βββ auth.py # /api/auth (register, login, demo)
β β βββ workspace.py # /api/workspace (list, ingest)
β β βββ rag.py # /api/rag (impact, query, refactor)
β βββ mcp_server.py # Stdio JSON-RPC 2.0 FastMCP Server for IDEs
β βββ requirements.txt # Production Python dependencies
β βββ Dockerfile # Backend container definition
β
βββ frontend/ # React 18 SPA (Vite + Tailwind CSS)
β βββ src/
β β βββ services/
β β β βββ api.js # Centralized HTTP client with JWT handling
β β βββ App.jsx # Main dashboard (Graph visualizer, RAG & Blast Radius)
β β βββ main.jsx # React root bootstrap
β β βββ index.css # Tailwind directives & global styling
β βββ package.json # Web client dependencies & build scripts
β βββ vite.config.js # Vite frontend configuration
β βββ Dockerfile # Frontend container definition
β
βββ evaluation/ # Automated Evaluation Framework
β βββ evaluator.py # LLM-as-a-Judge benchmark suite
βββ docs/
β βββ assets/ # Architectural & UI screenshots
β βββ graph_preview.png # Interactive dependency graph preview
β βββ impact_preview.png # Blast-radius impact analysis preview
βββ docker-compose.yml # 1-Click Multi-container orchestration
βββ mcp_server.py # Stdio FastMCP Server entry point
βββ main.py # Standalone CLI interactive interface
βββ requirements.txt # Root Python dependencies
βββ .env.example # Environment template
βββ README.md # Documentation
The simplest way to run the entire CodeGraph-RAG full-stack system is with Docker Compose.
git clone https://github.com/HarshaAppikatla/CodeGraph-RAG.git
cd CodeGraph-RAG
cp .env.example .envAdd your API credentials to .env:
# Google Gemini API Key
GEMINI_API_KEY="your_gemini_api_key_here"
# Neo4j Password (defaults to 'password' in docker-compose)
NEO4J_PASSWORD="your_secure_password"docker compose up --build| Service | Access URL | Description |
|---|---|---|
| React 18 Dashboard | http://localhost:5173 |
Interactive visualizer, blast radius explorer, and refactor sandbox |
| FastAPI Swagger Docs | http://localhost:8000/docs |
Auto-generated OpenAPI interactive API documentation |
| Neo4j Browser | http://localhost:7474 |
Cypher query console and property graph explorer |
If you prefer to run services individually without Docker:
# Navigate to backend and install dependencies
cd backend
pip install -r requirements.txt
# Start the FastAPI server
uvicorn app.main:app --reload --host 0.0.0.0 --port 8000# Navigate to frontend and install dependencies
cd frontend
npm install
# Start the Vite development server
npm run devTo use CodeGraph-RAG directly inside Cursor or VS Code, add this to your MCP configuration (.vscode/mcp.json or ~/.cursor/mcp.json):
{
"servers": {
"codegraph-rag": {
"type": "stdio",
"command": "python",
"args": [
"backend/mcp_server.py"
],
"env": {
"GEMINI_API_KEY": "your_gemini_api_key",
"NEO4J_URI": "bolt://localhost:7687",
"NEO4J_USERNAME": "neo4j",
"NEO4J_PASSWORD": "your_password"
}
}
}
}For Claude Desktop, add to claude_desktop_config.json:
{
"mcpServers": {
"codegraph-rag": {
"command": "python",
"args": [
"/path/to/CodeGraph-RAG/backend/mcp_server.py"
],
"env": {
"GEMINI_API_KEY": "your_gemini_api_key",
"NEO4J_URI": "bolt://localhost:7687",
"NEO4J_USERNAME": "neo4j",
"NEO4J_PASSWORD": "your_password"
}
}
}
}Evaluated across production multi-module repositories (including Study-Sync, 211 source files):
| Metric | Measured Benchmark | Description |
|---|---|---|
| Ingestion Throughput | 211 files / ~4.2s | Automated Tree-sitter parsing, vector chunking, and graph creation |
| Graph Scale | 2,533 Nodes / 1,195 Edges | Scope-attributed caller/callee links populated in Neo4j |
| Impact Recall | 100% Caller Recall | Zero unnamed_entity drops for enclosed method and function calls |
| Protocol Latency | < 15ms stdio RPC | Native stdio JSON-RPC 2.0 communication overhead |
| Faithfulness Score | 5.0 / 5.0 | Factual AST alignment scored via automated LLM-as-a-Judge |
| Relevancy Score | 5.0 / 5.0 | Direct adherence to query constraints and structural specifics |
| Failover Resilience | 100% | Zero failure rate during rate limits via dynamic model failover |
- Neo4j Connection Timeout: Verify your URI uses
neo4j+s://for Neo4j AuraDB orbolt://localhost:7687for local Docker containers. Fast failover (2-second timeout) is active by default. - Tree-sitter Parsing Error: Ensure C compiler toolchains (
gcc/clang/ MSVC) are installed if building tree-sitter language bindings from source. - MCP Stdio Logs: MCP servers communicate strictly over
stdout. All debug print statements in Python modules write tosys.stderrto prevent JSON-RPC stream corruption.
- Polyglot Tree-sitter Scope-Resolved AST Extraction
- Dual-Stream Neo4j + Qdrant Integration
- FastMCP Server with stdio JSON-RPC 2.0 support
- Multi-Tier Gemini LLM Failover Mesh
- Full-Stack Monorepo (FastAPI Backend + React 18 SPA)
- Multi-Container Docker Compose Orchestration
- Language Server Protocol (LSP) Dynamic Symbol Resolution
- Real-time Git Webhook incremental graph synchronization
- Visual Interactive 3D Call-Graph Web Sandbox
Contributions are welcome! Please follow these steps:
- Fork the repository.
- Create your feature branch (
git checkout -b feature/amazing-feature). - Commit your changes (
git commit -m 'feat: Add amazing feature'). - Push to the branch (
git push origin feature/amazing-feature). - Open a Pull Request.
Distributed under the MIT License. See LICENSE for more information.
Appikatla Harsha Vardhan
- GitHub: @HarshaAppikatla
- Project Repository: CodeGraph-RAG

