Tip
"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 โ
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.
| Branch | Description |
|---|---|
main |
Production โ stable, lean version live on Render (512MB RAM constraints) |
v2-local-heavy |
Parallel Vector Retrieval + Cohere Neural Reranking. ๐ View Architecture |
๐ฎ 11-Node LangGraph StateGraph โ Animated Architecture
โจ Classifier โ 6-Path Routing โ Retrieval โ Rerank โ Generate โ Hallucination Guard โ Post-Process
| 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 |
| 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 |
| 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) |
| 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 |
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
- Python 3.11+
- Node.js 18+
- API Keys: OpenRouter, Pinecone, MongoDB, Supabase, Google OAuth
# 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 devdocker build -t financial-parser .
docker run -p 8000:8000 --env-file .env financial-parseragentic-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
| 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 |
Ambuj Kumar Tripathi GenAI Engineer & RAG Systems Specialist | LLMOps
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.
7