Skip to content

Latest commit

ย 

History

274 Commits

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation


Typing SVG


Live Demo Featured on UptimeRobot RAG Docs Portfolio


GitHub Stars GitHub Forks

Python FastAPI React LangGraph Docker Render


Tip

๐Ÿ† Featured in UptimeRobot's Global Case Study

"How Ambuj Kumar Tripathi built an 11-Node Agentic RAG system with 99.9% uptime on $0 infrastructure" This project was officially featured by UptimeRobot for its resilient production architecture on 512MB RAM, dual-purpose cold-start elimination, and hallucination-resistant document retrieval.

๐Ÿ“– Read the Full Published Spotlight on UptimeRobot Blog โ†’


โšก What Is This?

An autonomous, 11-node Agentic RAG pipeline that parses and queries complex Indian financial & legal documents โ€” Union Budget, Finance Bill, Tax Laws, PF/Pension Schemes, RBI KYC, and Constitution of India โ€” using a purpose-built state machine that thinks before it answers.

Unlike traditional RAG (retrieve โ†’ generate), this system employs an agentic flow where each query passes through specialized nodes that classify intent, cross-question vague queries, guard against hallucinations, and verify answer grounding โ€” all orchestrated via LangGraph StateGraph.


๐ŸŒฟ Branches

Branch Description
main Production โ€” stable, lean version live on Render (512MB RAM constraints)
v2-local-heavy Parallel Vector Retrieval + Cohere Neural Reranking. ๐Ÿ‘‰ View Architecture

๐Ÿ—๏ธ System Architecture


๐Ÿ”ฎ 11-Node LangGraph StateGraph โ€” Animated Architecture

Agentic Financial Parser โ€” 11-Node Architecture
โœจ Classifier โ†’ 6-Path Routing โ†’ Retrieval โ†’ Rerank โ†’ Generate โ†’ Hallucination Guard โ†’ Post-Process

๐Ÿง  The 11-Node Agentic RAG Pipeline

Node Purpose Key Detail
1. Classifier Intent detection + 6-path routing Returns structured JSON: intent ยท doc_type ยท confidence ยท search_intents
2. Reject Safety guard Blocks abusive + jailbreak queries with regex blocklist guardrail
3. Greet Efficiency bypass Handles greetings without hitting vector DB (zero cost)
4. CrossQuestioner HITL clarification Asks clarifying questions for vague queries (max 2 rounds)
5. Retriever Dual vector search Jina MRL โ†’ Pinecone โ†’ Parent-Child Resolution โ†’ Cohere Rerank Top 10
6. Web Search Out-of-scope fallback Tavily API โ€” only fires after HITL user permission
7. Stock Tool Native LLM tool calling Gemini functionDeclarations + yfinance for live market data
8. Generator LLM synthesis Gemini 3.5 Flash Lite (primary) with pybreaker circuit breakers
9. HallucinationGuard Answer verification LLM-as-Judge โ€” advisory mode (appends disclaimer, doesn't block)
10. PostProcess Persistence + streaming MongoDB + Redis cache + Langfuse tracing + SSE stream
11. Fallback Circuit breaker recovery pybreaker pattern: 3 API failures โ†’ graceful fallback message

๐Ÿ”ง Tech Stack

Category Technology Purpose
RAG Engine LangGraph StateGraph 11-node autonomous state machine orchestration
Jina v3 (MRL) Matryoshka Representation Learning embeddings
Cohere Neural Reranker Advanced Stage-2 semantic filtering (V2)
LlamaParse LLM-native 3-tier document parsing
Tavily Search API Live Web Search fallback for Out-of-Scope queries
Backend & APIs FastAPI + Uvicorn Async REST API with SSE streaming
Authlib + PyJWT Google OAuth 2.0 + JWT session management
WhatsApp Meta Cloud API Real-time user bot interaction via Webhooks
Frontend React 19 + Vite SPA with lazy loading, dark theme, real-time streaming UI
Data Layer Pinecone Serverless 14,662 vectors โ€” core brain + ephemeral user uploads
Supabase (PostgreSQL) Parent chunk storage + file registry
MongoDB (Motor) Async chat history, feedback, user sessions
Upstash Redis Semantic caching (<100ms) + rate limiting + analytics
Reliability Pybreaker Circuit breaker pattern โ€” 3 failures โ†’ auto-open โ†’ 30s reset
Langfuse Distributed tracing โ€” LLM latency, token usage, cost tracking
UptimeRobot GET/HEAD health monitoring โ€” zero cold starts
Deployment Docker (Multi-stage) + Render Frontend build โ†’ backend image โ†’ production serve

๐Ÿ“Š Infrastructure Scale

Metric Value
Total Chunks 15,408 (Financial Parser Portfolio)
Live Vectors 14,662 high-dimensional vectors in Pinecone (256d MRL)
Documents Indexed 20+ Indian Government Acts & Financial Frameworks
Parent Chunks Stored in Supabase for full-context retrieval
Cache Latency <100ms (Upstash Redis semantic cache)
Rate Limit 10 queries/min per user (Redis sliding window)
Session TTL 24h auto-cleanup (MongoDB TTL indexes)

๐Ÿ“„ Documents Indexed

Category Documents
Financial Union Budget 2024-25, Finance Bill 2024-25, Income Tax Amendments
Pension/PF EPF Scheme 1952, EPS Pension Scheme 1995, PMVVY, APY
Banking RBI KYC Master Direction 2016, UPI Guidelines
Legal Constitution of India, Consumer Protection Act

๐Ÿ” Security Architecture

7-Layer Upload Security Framework
โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
Layer 1 โ”‚ Frontend Gating     โ”‚ .pdf only, 10MB limit, accept='.pdf'
Layer 2 โ”‚ Magic Byte Verify   โ”‚ %PDF- header validation (anti-spoofing)
Layer 3 โ”‚ Rate Limiting       โ”‚ 5 uploads/day per user+IP (Redis)
Layer 4 โ”‚ SHA-256 Dedup       โ”‚ Content-hash prevents re-indexing identical files
Layer 5 โ”‚ Session Isolation   โ”‚ is_temporary: true โ€” auto-deletes on logout
Layer 6 โ”‚ TTL Auto-Cleanup    โ”‚ MongoDB 24h TTL on chunks + temp_uploads
Layer 7 โ”‚ Auth Guard          โ”‚ JWT verification on every API endpoint

๐Ÿš€ Quick Start

Prerequisites

  • Python 3.11+
  • Node.js 18+
  • API Keys: OpenRouter, Pinecone, MongoDB, Supabase, Google OAuth

Local Development

# Clone
git clone https://github.com/Ambuj123-lab/agentic-rag-financial-parser.git
cd agentic-rag-financial-parser

# Backend
python -m venv venv && venv\Scripts\activate  # Windows
pip install -r requirements.txt
cp .env.example .env  # Fill in your API keys
uvicorn app.main:app --reload

# Frontend (new terminal)
cd frontend
npm install && npm run dev

Docker (Production)

docker build -t financial-parser .
docker run -p 8000:8000 --env-file .env financial-parser

๐Ÿ“ Project Structure

agentic-rag-financial-parser/
โ”œโ”€โ”€ app/
โ”‚   โ”œโ”€โ”€ main.py              # FastAPI app + SPA serving + health check
โ”‚   โ”œโ”€โ”€ api/
โ”‚   โ”‚   โ”œโ”€โ”€ auth.py           # Google OAuth + JWT + dev-login
โ”‚   โ”‚   โ”œโ”€โ”€ oauth.py          # Authlib Google client config
โ”‚   โ”‚   โ””โ”€โ”€ upload.py         # 7-layer secure file upload
โ”‚   โ”œโ”€โ”€ core/
โ”‚   โ”‚   โ””โ”€โ”€ config.py         # Pydantic Settings (env vars)
โ”‚   โ”œโ”€โ”€ db/
โ”‚   โ”‚   โ”œโ”€โ”€ mongodb.py        # Async Motor client + indexes
โ”‚   โ”‚   โ”œโ”€โ”€ pinecone_client.py # Pinecone Serverless init
โ”‚   โ”‚   โ””โ”€โ”€ supabase_client.py # Supabase PostgreSQL client
โ”‚   โ””โ”€โ”€ rag/
โ”‚       โ”œโ”€โ”€ graph.py          # โญ 11-Node LangGraph StateGraph
โ”‚       โ”œโ”€โ”€ routes.py         # Chat endpoints + SSE streaming
โ”‚       โ”œโ”€โ”€ embedder.py       # Jina v3 MRL embeddings
โ”‚       โ””โ”€โ”€ chunker.py        # Markdown + recursive splitting
โ”œโ”€โ”€ frontend/
โ”‚   โ”œโ”€โ”€ src/
โ”‚   โ”‚   โ”œโ”€โ”€ pages/            # Landing, Dashboard, Admin, AuthCallback
โ”‚   โ”‚   โ”œโ”€โ”€ context/          # AuthContext (JWT state)
โ”‚   โ”‚   โ””โ”€โ”€ api/              # Axios client with interceptors
โ”‚   โ””โ”€โ”€ vite.config.js        # Dev proxy + code splitting
โ”œโ”€โ”€ Dockerfile                # Multi-stage: Node build โ†’ Python serve
โ”œโ”€โ”€ requirements.txt          # Pinned Python dependencies
โ””โ”€โ”€ .dockerignore             # Minimal Docker context

๐ŸŒ Live Links

Resource URL
๐Ÿš€ Live Application agentic-rag-financial-parser.onrender.com
๐Ÿ“– RAG Documentation ambuj-rag-docs.netlify.app
๐Ÿ‘ค Portfolio ambuj-ai-portfolio.vercel.app
๐Ÿ’ป Source Code GitHub Repository

๐Ÿ‘จโ€๐Ÿ’ป Author

Ambuj Kumar Tripathi GenAI Engineer & RAG Systems Specialist | LLMOps

LinkedIn GitHub Portfolio


๐Ÿ“œ License

This project is licensed under the GNU Affero General Public License v3.0 (AGPL-3.0).
Due to the integration of PyMuPDF (which is licensed under AGPL-3.0) for high-performance PDF parsing, this repository inherits the AGPL-3.0 license to comply with open-source copyleft requirements.


Built with ๐Ÿง  LangGraph โ€ข โšก FastAPI โ€ข โš›๏ธ React โ€ข ๐Ÿ” Pinecone โ€ข ๐Ÿ˜ Supabase โ€ข ๐Ÿƒ MongoDB โ€ข ๐Ÿ”ด Redis

7

About

Enterprise RAG ecosystem managing 32000+ semantic chunks. Features hybrid parsing (LlamaParse/PyMuPDF) and 256-dim MRL embeddings for 512MB RAM environments

Topics

Resources

Stars

108 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages