How kirtipratihar/yap-engine-v2-agentic-self-correcting-rag works
Yap Engine is a multi-user document Q&A assistant. Users authenticate in the Next.js chat, upload PDFs or images, then ask questions and receive document-grounded answers with citations and quality metadata. The backend handles ingestion and session-scoped retrieval, while a LangGraph workflow routes intents, evaluates retrieved chunks, retries weak searches, and generates answers. The graph captures documented capabilities as well as sampled calls; several backend details, including streaming and observability implementation, are documented but not shown in the excerpts.
Main entry points: main.py API and sessions · graph.py RAG orchestration · page.js Chat and upload UI · route.js Backend proxy
Components 18
Chat client
- Chat and upload UI
frontend/src/app/page.js - Backend proxy
frontend/src/app/api/proxy/[...slug]/route.js
Backend API
- API and sessions
backend/main.py - Authentication and quotas
backend/main.py - Session memory
backend/main.py - Quality and health endpoints
backend/main.py
Document ingestion
- Upload processing
backend/main.py - Extract and chunk
backend/main.py - Text embeddings
backend/main.py
RAG workflow
- RAG orchestration
backend/graph.py - Intent classifier
backend/router.py - Hybrid retrieval
backend/main.py - Retrieval evaluation
backend/evaluator.py - Query rewrite
backend/evaluator.py - Answer generation
backend/graph.py
External services
- Document vectors
- Groq LLM
Other components
- Research user
Connections 20
- Research user → Chat and upload UI: asks and uploads
README.md - Chat and upload UI → API and sessions: sends requests
README.md - Chat and upload UI → Backend proxy: can route through
README.md - Backend proxy → API and sessions: forwards requests
frontend/src/app/api/proxy/[...slug]/route.js - API and sessions → Authentication and quotas: authenticates users
README.md - API and sessions → Upload processing: handles uploads
README.md - Upload processing → Extract and chunk: extracts and chunks
README.md - Extract and chunk → Text embeddings: embeds chunks
README.md - Text embeddings → Document vectors: writes vectors
README.md - API and sessions → RAG orchestration: invokes graph
backend/main.py - RAG orchestration → Intent classifier: classifies intent
backend/graph.py - RAG orchestration → Hybrid retrieval: requests retrieval
backend/graph.py - Hybrid retrieval → Document vectors: queries vectors
README.md - RAG orchestration → Retrieval evaluation: scores chunks
backend/graph.py - RAG orchestration → Query rewrite: rewrites weak queries
backend/graph.py - RAG orchestration → Answer generation: dispatches answer
backend/graph.py - Answer generation → Groq LLM: generates answer
README.md - API and sessions → Session memory: keeps session memory
README.md - API and sessions → Quality and health endpoints: records and serves metrics
README.md - API and sessions → Chat and upload UI: returns answer and citations
README.md