How esterkane/grounded-rag-assistant works
grounded-rag-assistant is a documentation-grounded RAG service. Its main workflow is a user question entering the HTTP API, going through hybrid retrieval and optional reranking, then citation-validated generation; answers without sufficient cited evidence take an explicit insufficient-evidence path. Ingestion prepares and indexes the corpus, while PostgreSQL supports query logging and human review. MCP exposes the shared retrieval and answer functions, and a partially implemented agent orchestrates MCP tools. Evaluation and observability support quality and operations. Some subsystem links rely on README descriptions because their implementation files were not excerpted.
Main entry points: answerer.py Grounded answerer · retriever.py Hybrid retrieval · main.py FastAPI app · ask.py Ask endpoint
Components 27
HTTP API
- FastAPI app
app/main.py - Ask endpoint
app/api/ask.py - Search endpoint
app/api/search.py
RAG Core
- Grounded answerer
app/generation/answerer.py - Hybrid retrieval
app/retrieval/retriever.py - Cross-encoder reranker
app/retrieval/reranker.py - Query embeddings
app/ingestion/embedder.py - Provider selection
app/generation/providers/factory.py - Provider fallback
app/generation/providers/fallback.py - Gemini provider
app/generation/providers/gemini.py - Ollama provider
app/generation/providers/ollama.py
Corpus Ingestion
- Corpus fetch
app/ingestion/fetch_corpus.py - Document chunking
app/ingestion/chunking.py - Index construction
app/ingestion/index.py - Ingestion runner
app/ingestion/run.py
Review and State
- Query and feedback data
app/db/repository.py - Review queue
app/api/review.py - Metrics endpoint
app/api/metrics.py
Agent and Operations
- MCP tools and server
app/mcp/tools.py - LangGraph agent
app/agent/graph.py - MCP client
app/agent/mcp_client.py - Evaluation harness
app/eval/harness.py - Logging and tracing
app/observability/logging.py
Other components
- Questioner
- Elasticsearch
- PostgreSQL
- MCP host/client
Connections 33
- Questioner → FastAPI app: sends request
README.md - FastAPI app → Ask endpoint: routes requests
app/main.py - FastAPI app → Search endpoint: routes requests
app/main.py - Ask endpoint → Grounded answerer: requests answer
app/api/ask.py - Search endpoint → Hybrid retrieval: requests search
app/api/search.py - Grounded answerer → Hybrid retrieval: runs retrieval
app/generation/answerer.py - Grounded answerer → Cross-encoder reranker: reranks candidates
app/generation/answerer.py - Hybrid retrieval → Query embeddings: embeds query
app/retrieval/retriever.py - Hybrid retrieval → Elasticsearch: searches index
README.md - Grounded answerer → Provider selection: generates response
app/generation/answerer.py - Provider selection → Provider fallback: selects fallback
app/generation/providers/factory.py - Provider selection → Gemini provider: selects provider
app/generation/providers/factory.py - Provider selection → Ollama provider: selects provider
app/generation/providers/factory.py - Provider fallback → Gemini provider: calls primary
app/generation/providers/fallback.py - Provider fallback → Ollama provider: falls back
app/generation/providers/fallback.py - Ingestion runner → Corpus fetch: starts corpus fetch
- Ingestion runner → Document chunking: prepares chunks
- Ingestion runner → Index construction: builds index
- Index construction → Query embeddings: embeds chunks
- Index construction → Elasticsearch: writes documents
- Ask endpoint → Query and feedback data: logs query
app/api/ask.py - Review queue → Query and feedback data: reads and records feedback
app/api/review.py - Metrics endpoint → Query and feedback data: reads metrics
- Query and feedback data → PostgreSQL: reads and writes
- MCP host/client → MCP tools and server: calls tools
README.md - MCP tools and server → Hybrid retrieval: reuses retrieval
README.md - MCP tools and server → Grounded answerer: reuses answering
README.md - LangGraph agent → MCP client: dispatches tools
app/agent/graph.py - MCP client → MCP tools and server: calls tools
- Evaluation harness → Hybrid retrieval: evaluates retrieval
app/eval/harness.py - Evaluation harness → Grounded answerer: evaluates answers
app/eval/harness.py - FastAPI app → Logging and tracing: configures logging
app/main.py - Ask endpoint → Logging and tracing: records activity
app/api/ask.py