How sugeerth/production-rag works
Production RAG serves private-document question answering: users upload or re-index documents, then ask questions and receive grounded answers with citations. The ingestion path parses and chunks documents before embedding and indexing; the query path rewrites questions, performs hybrid retrieval and reranking, applies safety checks, and generates cited answers. The app coordinates these stages and exposes document management, feedback, and monitoring. README capabilities guide the architecture where implementation excerpts are incomplete; links to unsampled subsystems are limited to documented behavior.
Main entry points: app.py FastAPI app · indexing.py Index and search · generation.py Context and generation · app.js Web UI
Components 17
User interface
- Web UI
static/app.js - FastAPI app
app.py
Document ingestion
- Document corpus
documents - Parse and chunk
rag/ingestion.py - Embeddings
rag/embeddings.py - Index and search
rag/indexing.py - ChromaDB
- BM25 index
rag/indexing.py
Question answering
- Rewrite and rerank
rag/retrieval.py - Context and generation
rag/generation.py - Safety checks
rag/guardrails.py
Monitoring and state
- Query evaluation
rag/evaluation.py - Query log store
rag/evaluation.py - Monitoring dashboard
static/app.js
Other components
- User
- Sentence-Transformers
- Ollama LLM
Connections 28
- User → Web UI: asks or uploads
- Web UI → FastAPI app: sends requests
- FastAPI app → Document corpus: stores uploads
- FastAPI app → Parse and chunk: ingests documents
- Document corpus → Parse and chunk: reads files
- Parse and chunk → FastAPI app: returns chunks
- FastAPI app → Index and search: indexes chunks
- Index and search → Embeddings: embeds chunks
- Embeddings → Sentence-Transformers: encodes text
- Index and search → ChromaDB: upserts and queries
- Index and search → BM25 index: builds and searches
- FastAPI app → Rewrite and rerank: retrieves answers
- Rewrite and rerank → Embeddings: embeds query
- Rewrite and rerank → Index and search: hybrid search
- Rewrite and rerank → FastAPI app: returns ranked chunks
- FastAPI app → Context and generation: generates answer
- Context and generation → Safety checks: checks safety
- Context and generation → Ollama LLM: requests completion
- Ollama LLM → Context and generation: returns answer
- Context and generation → FastAPI app: returns citations
- FastAPI app → Query evaluation: logs query
- Query evaluation → Query log store: persists logs
- FastAPI app → Query evaluation: gets metrics and logs
- FastAPI app → Index and search: gets index stats
- Web UI → Monitoring dashboard: renders monitoring
- Monitoring dashboard → FastAPI app: requests stats and logs
- Web UI → FastAPI app: submits feedback
- FastAPI app → Query evaluation: records feedback