How ahamed-safnas/agentic-rag works
This is an enterprise document RAG application. Users submit questions through the Streamlit UI or API; the API applies guardrails, runs a stateful LangGraph planner/retriever/responder workflow, and returns an answer with sources and reasoning. A separate ingestion path parses, chunks, embeds, and indexes local documents. The README also documents evaluation, memory, caching, rate limiting, and observability capabilities. Relationships for the main workflow are supported by excerpts or README statements; unsampled integrations are shown only where documented.
Main entry points: main.py FastAPI API · graph.py Graph orchestration · processor.py Ingestion processor · pipeline.py Live eval pipeline
Components 27
API and experience
- Chat UI
ui/app.py - FastAPI API
app/main.py - Guardrails
app/guardrails/rails.py
Agent workflow
- Graph orchestration
app/agents/graph.py - Agent state
app/agents/state.py - Query planner
app/agents/nodes/planner.py - Document retriever
app/agents/nodes/retriever.py - Answer responder
app/agents/nodes/responder.py
Knowledge ingestion and search
- Ingestion processor
app/ingestion/processor.py - Document loaders
app/ingestion/loaders - Text chunker
app/ingestion/chunking/splitter.py - Embedding service
app/services/retrieval/embedding.py - Vector search
app/services/retrieval/qdrant_service.py - Semantic reranker
app/services/retrieval/ranking_service.py
State and operations
- Response cache
app/services/cache.py - LLM gateway client
app/gateway/client.py - Conversation checkpoint
app/agents/graph.py - Metrics endpoint
app/main.py - Health checks
app/health.py
Evaluation
- Live eval pipeline
evals/pipeline.py - RAG evaluation metrics
evals/metrics.py - Guardrails evaluation
evals/guardrails_eval.py
Other components
- User
- Qdrant
- Jina embeddings API
- Jina reranker API
- Redis rate limiting
Connections 29
- User → Chat UI: asks question
README.md - Chat UI → FastAPI API: submits query
README.md - FastAPI API → Guardrails: checks input
app/main.py - FastAPI API → Response cache: checks cache
app/main.py - FastAPI API → Graph orchestration: runs pipeline
app/main.py - Graph orchestration → Query planner: dispatches
app/agents/graph.py - Graph orchestration → Document retriever: routes technical
app/agents/graph.py - Graph orchestration → Answer responder: routes conversational
app/agents/graph.py - Graph orchestration → Agent state: uses state
app/agents/graph.py - Query planner → LLM gateway client: requests LLM
app/agents/nodes/planner.py - Answer responder → LLM gateway client: requests LLM
app/agents/nodes/responder.py - Guardrails → LLM gateway client: requests LLM
app/guardrails/rails.py - Document retriever → Vector search: searches
app/agents/nodes/retriever.py - Document retriever → Semantic reranker: reranks results
app/agents/nodes/retriever.py - Vector search → Embedding service: embeds query
app/services/retrieval/qdrant_service.py - Vector search → Qdrant: queries vectors
app/services/retrieval/qdrant_service.py - Semantic reranker → Jina reranker API: reranks documents
app/services/retrieval/ranking_service.py - Embedding service → Jina embeddings API: embeds texts
app/services/retrieval/embedding.py - Ingestion processor → Document loaders: parses files
app/ingestion/processor.py - Ingestion processor → Text chunker: chunks text
app/ingestion/processor.py - Ingestion processor → Embedding service: embeds chunks
app/ingestion/processor.py - Ingestion processor → Qdrant: upserts vectors
app/ingestion/processor.py - Graph orchestration → Conversation checkpoint: checkpoints state
app/agents/graph.py - FastAPI API → Redis rate limiting: limits requests
README.md - FastAPI API → Metrics endpoint: exposes metrics
app/main.py - FastAPI API → Health checks: includes health routes
app/main.py - Live eval pipeline → FastAPI API: submits live queries
evals/pipeline.py - Live eval pipeline → RAG evaluation metrics: evaluates results
- Live eval pipeline → Guardrails evaluation: evaluates safety