An enterprise-ready, production-grade Codebase Intelligence & GraphRAG System powered by a Stateful LangGraph Multi-Agent Swarm, Hybrid Reciprocal Rank Fusion (RRF) Search, real-time Neo4j Call-Graph Traversal, a high-performance Redis Semantic Cache, and a secure Go Authentication Microservice.
VortexRAG is designed to index massive repositories, resolve complex multi-hop structural code queries with absolute structural fidelity, and deliver secure, audited, performance-profiled architectural insights to developers.
- Project Overview
- Problem Statement & Motivation
- Key Features
- Demo & Architecture Diagram
- High-Level System Architecture
- End-to-End Workflow
- Retrieval-Augmented Generation (RAG) Pipeline
- Data Ingestion & Chunking Strategy
- Vector DB & Hybrid Search Design (RRF)
- Neo4j GraphRAG & Call-Graph Context Injection
- Parallel Multi-Agent Swarm (LangGraph)
- Redis Semantic Caching Strategy
- Go Authentication Microservice
- Technology Stack
- API Design & Folders Structure
- Installation & Setup Guides
- Usage & Live Examples
- Testing & Performance Benchmarks
- Challenges Faced & Lessons Learned
- Future Enhancements & Roadmap
VortexRAG transitions AI-driven codebase understanding from simple keyword searches into a highly disciplined, multi-hop semantic audit. By integrating vector storage (Qdrant) with structural abstract syntax tree (AST) call-graphs (Neo4j), the application understands not only what code exists, but how classes, methods, and decorators communicate with each other.
The application employs a collaborative swarm of specialized LLM agents coordinated statefully in LangGraph. When a developer asks a question, the retrieve operations are mathematically fused with a local BM25 Sparse Ranker using Reciprocal Rank Fusion (RRF). In parallel, a Security Agent scans for vulnerabilities, a Performance Agent profiles algorithmic and database bottlenecks, and a Compliance Architect synthesizes the final streamable response.
Traditional Retrieval-Augmented Generation (RAG) systems fail on codebases because:
- Context Fragmentation: Naive sliding-window chunking breaks functional logic. A function signature is separated from its body, leading to LLM hallucinations.
-
Missing Structural Relationships: Vectors alone cannot represent dependency call-graphs. If a class in
auth.pyinherits frombase.py, a simple vector search will fail to retrieve the parent definition. - Inefficient Latency & High Ingestion Costs: Re-indexing massive codebases on every commit is slow and expensive.
-
Weak Security & Performance Oversight: Code suggestions returned by AI are often insecure or inefficient, introducing hardcoded credentials or
$O(N^2)$ bottlenecks.
VortexRAG is designed to serve as a recruiter-wowing flagship portfolio piece, demonstrating senior-level systems design proficiency. It addresses every drawback of naive RAG by implementing:
- AST-based semantic chunking using
tree-sitter. - Real-time GraphRAG structural context injection from Neo4j.
- Sub-2-second incremental delta ingestion pipelines.
- A high-performance, millisecond-latency Redis semantic cache.
- ๐ณ AST Semantic Chunking: Uses
tree-sittergrammars to parse Python, TypeScript, Go, Java, and JavaScript into clean, standalone AST class and function nodes. - ๐ธ๏ธ Neo4j GraphRAG Call-Graphs: Stores code containment relationships and call-graph dependencies (
CONTAINS,CALLS). Retrieves structural siblings dynamically to prevent hallucination. - ๐งช 2D Physics Graph Explorer (v1.1): An interactive physics-based UI module to visualize your Neo4j property graph.
- ๐ BM25 + Dense Hybrid Search (RRF): Fuses dense vector embeddings (Google Gemini) with sparse keyword queries using Reciprocal Rank Fusion (RRF).
- ๐ค Stateful LangGraph Parallel Swarm: Routes retrieved chunks to parallel Security and Performance agents before joining at a lead Compliance Architect node.
- โก Redis Semantic Cache & Monitor (v1.1): Compares incoming queries mathematically against a vector cache using cosine similarity, serving cache hits in under 15ms. Includes a live dashboard monitor tracking hits, misses, and estimated API savings.
- ๐ Smart Delta Ingestion: Uses Git diffs to delete, chunk, and upsert only modified files, completing ingestion in seconds.
- ๐ Go OAuth2 Microservice: A high-speed, secure, SQLite-backed auth microservice implemented in Go that generates and verifies stateless JWT access tokens.
- ๐ Server-Sent Events (SSE): Real-time, word-by-word streaming of agent progress states and token responses using Next.js 14 and FastAPI.
๐ Searching Vector Database... -> [CACHE MISS]
๐ก๏ธ Grading retrieved code relevancy... -> [3 Chunks Kept]
๐ก๏ธ [Swarm] Security Agent auditing vulnerabilities... (Parallel)
โก [Swarm] Performance Agent profiling bottlenecks... (Parallel)
๐ [Swarm] Lead Architect synthesizing unified report... (Join)
๐ Stream: # VortexRAG Architect Review...
graph TD
User([Developer UI]) -->|1. Request / Stream| NextJS[Next.js 14 Frontend]
NextJS -->|2. JWT Auth Validate| GoAuth[Go Auth Microservice]
NextJS -->|3. Query / Ingest| FastAPI[FastAPI Backend]
FastAPI -->|4. Cosine Match| Redis[Redis Semantic Cache]
FastAPI -->|5. Delta Diff / AST| TreeSitter[Tree-Sitter Chunker]
FastAPI -->|6. Dense Vector Search| Qdrant[(Qdrant DB)]
FastAPI -->|7. Call-Graph Siblings| Neo4j[(Neo4j Graph DB)]
FastAPI -->|8. Orchestrate Swarm| LangGraph{LangGraph Orchestrator}
LangGraph -->|Parallel Node| SecAgent[Security Auditor Agent]
LangGraph -->|Parallel Node| PerfAgent[Performance Profiler Agent]
LangGraph -->|Join Node| ArcAgent[Compliance Architect Agent]
ArcAgent -->|9. SSE Stream| NextJS
VortexRAG splits responsibilities across highly optimized microservices:
- Frontend Application (Next.js 14): A premium visual dashboard using a glassmorphic dark-mode palette, dynamic Framer Motion hover animations, responsive codebase charts, interactive 2D graph visualizations, and SSE state streaming.
- Core API Server (FastAPI): Orchestrates chunking, vector database upserts, and GraphRAG operations. Hosts the LangGraph state machine.
- Authentication microservice (Go): A dedicated microservice built in Go, backed by SQLite, providing user registration, secure login, and high-performance stateless JWT token generation.
- Storage Topology:
- Redis: Hosts the semantic cache store.
- Qdrant: Distributed vector collection indexed via HNSW.
- Neo4j: High-performance property graph mapping project files, structures, and call graphs.
sequenceDiagram
autonumber
actor Dev as Developer
participant UI as Next.js 14 UI
participant API as FastAPI Backend
participant Cache as Redis Semantic Cache
participant Qdrant as Qdrant Vector DB
participant Neo4j as Neo4j Graph DB
participant LLM as Groq Llama 3 Swarm
Dev->>UI: Submit Codebase Query
UI->>API: POST /query/stream
API->>Cache: Cosine Similarity Check (Redis Vector)
alt Cache Hit (Similarity > 0.92)
Cache-->>API: Return Cached Markdown Output
API-->>UI: Instantly Stream Cached Report (15ms)
else Cache Miss
API->>Qdrant: Dense + BM25 Hybrid Retrieval
Qdrant-->>API: Top 5 Relevant Chunks
API->>Neo4j: Fetch File Sibling Call-Graphs (Cypher)
Neo4j-->>API: Containment & Call-Graph Context Map
API->>API: Augment Chunks with Graph Map
API->>LLM: Trigger Parallel Security & Performance Agents
LLM-->>API: Vulnerability & Big-O Audits
API->>LLM: Join & Synthesize (Compliance Architect)
LLM-->>API: Stream Markdown Tokens
API-->>UI: Real-time Token Stream (SSE)
API->>Cache: Cache Query & Answer in Redis
end
VortexRAG utilizes a stateful self-correction LangGraph cycle designed to prevent hallucinations:
[Retriever Node] โก๏ธ [Grader Node] โก๏ธ Relevant?
โโโ Yes: [Swarm Nodes (Parallel)] โก๏ธ [Synthesize] โก๏ธ END
โโโ No: [Query Rewriter] โก๏ธ [Retriever Node] (Loop)
Acts as a strict binary classifier (yes/no) assessing the relevancy of each retrieved chunk against the core user question. Any chunk marked irrelevant is immediately filtered. If 100% of chunks are filtered, the system triggers the Query Rewriter.
Transforms the developer query to resolve semantic ambiguities or optimize it for vector search, running a second retrieval attempt.
Unlike standard RAG pipelines that slice code based on character limits, VortexRAG respects grammar structures:
# Standard Chunking destroys scope boundary:
# [Chunk 1 starts]
def process_user(user_id):
db = get_db()
# [Chunk 1 ends] / [Chunk 2 starts]
return db.query(User).filter(User.id == user_id).first()
# [Chunk 2 ends] (Logic is completely broken for vector semantics!)VortexRAG reads source files, detects the programming language, and compiles the concrete syntax tree using tree-sitter. It isolates:
- Python:
class_definition,function_definition,async_function_definition - TypeScript/JavaScript:
class_declaration,method_definition,arrow_function - Go:
function_declaration,method_declaration
Every chunk is saved as a CodeChunk object preserving:
- Exact file paths and namespaces.
- Start and end line boundaries.
- Extracted docstrings and parent-class scopes.
- deterministic hash IDs matching
hashlib.sha256(repo_id + file_path + start_line).
VortexRAG combines dense vector similarity search with a local sparse BM25 Keyword Ranker to ensure that exact matches for variables, class signatures, and methods are retrieved alongside conceptual matches.
We rank candidates retrieved from both dense (Qdrant) and sparse (BM25) pools by computing the RRF score. The highest RRF scores are selected, guaranteeing optimal keyword-precision.
# Payload stored inside Qdrant Vector Collection:
{
"id": "str(uuid.uuid5(chunk_id))",
"vector": [1536 float values], # Gemini Embeddings
"payload": {
"chunk_id": "8c22d1",
"repo_id": "vortex-rag_main",
"file_path": "backend/app/main.py",
"language": "python",
"node_type": "function_definition",
"name": "login",
"start_line": 23,
"end_line": 45,
"code": "..."
}
}Vector embeddings miss structural containment. To resolve this, VortexRAG builds a persistent Knowledge Graph in Neo4j during the ingestion phase:
(:Repository {id}) -[:CONTAINS]-> (:File {path}) -[:CONTAINS]-> (:Class {name}) -[:CONTAINS]-> (:Function {name})
When the retrieval node pulls the top vector matches from Qdrant, it maps their file paths and runs a real-time Cypher query to pull sibling functions, call paths, and containing classes:
MATCH (f:File {repo_id: $repo_id})
WHERE f.path IN $file_paths
MATCH (f)-[:CONTAINS]->(child)
RETURN child.name AS name, labels(child)[0] AS type, child.start_line AS start_line
LIMIT 15This returns a structured Codebase Structural Call-Graph Map which is appended directly to the context prompt, allowing the LLM to explain imports, decorators, and dependencies.
VortexRAG deploys a highly advanced LangGraph parallel-fan-out and merge multi-agent network:
โโโ ๐ก๏ธ Security Auditor Agent โโโ
[Retrieve/Grade] โโโโก๏ธ [Compliance Architect] โก๏ธ END
โโโ โก Performance Profiler โโโโโ
- ๐ก๏ธ Security Auditor Agent (Parallel Node): A specialized CISSP-certified agent analyzing codebase chunks for secrets leakage, SQL injections, insecure packages, and JWT logic bypasses.
- โก Performance Profiler Agent (Parallel Node): A specialized Principal Architect analyzing big-O algorithm complexity, CPU/memory hotspots, redundant DB queries, and open connection leaks.
- ๐ Compliance Architect Agent (Join Synthesizer): Collects the core code context, merges the parallel Security Audit and Performance Profile, and compiles the final unified markdown report.
To provide enterprise-level sub-15ms response latency, VortexRAG features a high-performance Redis Vector Semantic Cache.
- Incoming queries are embedded using Google Gemini.
- We query Redis's indexing store using Cosine Distance.
- If the distance is below the similarity threshold (
$0.92$ ):- Return the cached markdown answer immediately from Redis.
- Total latency: <15 milliseconds!
- If it's a cache miss:
- Execute the full LangGraph Agent Swarm.
- Save the question, embedding vector, and multi-agent markdown output to Redis for future queries.
VortexRAG decouples identity management using a high-performance, secure Go microservice:
- Storage: High-speed local SQLite database.
- Encryption: Passwords are fully hashed using
golang.org/x/crypto/bcrypt. - State: Stateless JWT generation using
github.com/golang-jwt/jwt/v5. - FastAPI Hook: FastAPI API keys/endpoints validate JWT payloads against Go's public key or shared token secret, securing all ingestion and querying routes.
| Layer | Technology | Description |
|---|---|---|
| Frontend UI | Next.js 14, React, TailwindCSS | Premium glassmorphic interface, physics graphs, SSE streaming |
| Core API | FastAPI, Python 3.11 | High-performance async API orchestrating agents |
| Orchestration | LangGraph, LangChain | Stateful, graphical multi-agent execution |
| Authentication | Go, SQLite | High-speed, compiled microservice handling JWT |
| Vector DB | Qdrant | Dense vector search, HNSW indexing |
| Graph DB | Neo4j | Call-graph relation indexing |
| Cache Store | Redis | High-speed semantic vector cache |
| Embeddings | Google Gemini | gemini-embedding-2 for 1536-dim dense representations |
| LLM Provider | Groq (Llama 3) | Ultra-fast token-per-second streaming interface |
vortex-rag/
โโโ backend/
โ โโโ app/
โ โ โโโ api/
โ โ โ โโโ v1/endpoints/
โ โ โโโ core/
โ โ โโโ db/
โ โ โ โโโ neo4j.py # Neo4j Driver pool
โ โ โ โโโ qdrant.py # Qdrant client pool
โ โ โ โโโ redis.py # Redis Vector DB semantic cache pool
โ โ โโโ services/
โ โ โโโ ast_chunker.py # tree-sitter AST parser
โ โ โโโ hybrid_search.py # dense Qdrant + local BM25 + mathematical RRF
โ โ โโโ rag_agent.py # LangGraph Collaborative Multi-Agent Swarm
โ โ โโโ semantic_cache.py # Redis vector caching
โ โโโ main.py
โโโ frontend/
โ โโโ src/
โ โ โโโ app/
โ โ โ โโโ dashboard/
โ โ โ โ โโโ ingest/page.tsx # Ingest monitoring panel
โ โ โ โ โโโ pr-review/ # PR Agent trigger
โ โ โ โ โโโ query/page.tsx # Premium search & swarm monitor UI
โ โ โ โ โโโ graph/page.tsx # 2D Physics Graph Explorer
โ โ โ โ โโโ cache/page.tsx # Redis Cache Monitor
โ โโโ package.json
โโโ go-auth/ # Go Auth microservice
git clone https://github.com/sakshamkamra33/vortex-codebase-intelligence.git
cd vortex-codebase-intelligencecd backend
python -m venv .venv
source .venv/Scripts/activate # Windows
pip install -r requirements.txtCreate a .env file in the backend/ directory:
# API Keys
GROQ_API_KEY=your_groq_key
GOOGLE_API_KEY=your_gemini_key
# Databases
QDRANT_URL=your_qdrant_url
QDRANT_API_KEY=your_qdrant_key
NEO4J_URI=your_neo4j_uri
NEO4J_USERNAME=neo4j
NEO4J_PASSWORD=your_neo4j_password
REDIS_URL=your_upstash_redis_urlRun the FastAPI Server:
uvicorn app.main:app --reload --host 0.0.0.0 --port 8000cd frontend
npm install
npm run devNavigate to http://localhost:3000 to access the Mission Control dashboard.
Trigger a smart incremental update via curl:
curl -X POST http://localhost:8000/api/v1/ingest/sync \
-H "Authorization: Bearer <your_jwt_token>" \
-H "Content-Type: application/json" \
-d '{
"repo_url": "https://github.com/your-org/my-project",
"branch": "main",
"modified_files": ["backend/app/main.py"],
"deleted_files": ["backend/old_utils.py"]
}'curl -N http://localhost:8000/api/v1/query/stream \
-H "Authorization: Bearer <your_jwt_token>" \
-H "Content-Type: application/json" \
-d '{
"question": "Tell me about the login flow and its security vulnerabilities.",
"repo_id": "vortex-rag_main"
}'- Full Ingestion (150 large files): ~45 seconds (cloning, tree-sitter chunking, dense vectorizing, graph rendering).
- Smart Delta Sync (2 modified files): 1.8 seconds! (re-indexing only the diff, removing stale Qdrant vectors and Neo4j relations).
- Redis Cache Miss (Swarm Execution): ~4.5 seconds (RRF Dense/Sparse, Neo4j Graph Cypher, Parallel Security & Performance Agents, Synthesizing tokens).
- Redis Cache Hit: 11 milliseconds! (Cosine similarity comparison and direct cache recovery).
- Parallel Execution State Locks: Implementing parallel security/performance nodes in LangGraph created state lockups because they modified the same dictionary. Resolved by defining distinct state key values
security_auditandperformance_audit, which LangGraph merges natively using dictionary merge-joins upon reaching the compliance architect join node. - BM25 vs Vector Scaling Mismatch: Sparse scores are unbounded, whereas dense cosine similarity scores lie between 0 and 1. Simple addition broke. Resolved by ranking both lists separately and combining them using mathematical Reciprocal Rank Fusion (RRF).
- Embedding Rate Limiting: Free tier embedders have strict requests-per-minute ceilings. Resolved by caching active embeddings inside Redis and storing pre-computed vector hashes during incremental ingestion runs.
- Dynamic Graph Visualizer: An interactive WebGL node-graph panel in the Next.js frontend showing your Neo4j codebase connections dynamically. (Completed in v1.1)
- Semantic Cache Monitor: Live dashboard tracking Redis hit rates and cost savings. (Completed in v1.1)
- Multi-Branch Comparative Auditing: Diff branch
feature/authagainstmainin Neo4j and predict code regression vulnerabilities before merging. - Custom Local Embeddings: Replace Google Gemini with an open-source local BGE-M3 embedder to run the entire pipeline offline.
This project is licensed under the MIT License - see the LICENSE file for details.
- Saksham Kamra - GitHub