How dharamveer007/adaptive-rag works
Adaptive RAG is a document-aware chatbot with both React and Streamlit interfaces, backed by a FastAPI service. Users authenticate, create or select a session, optionally upload documents, and submit questions; the API persists conversation history and invokes a LangGraph workflow that routes among document retrieval, general answers, and web search before returning a response. The graph also preserves session history, document indexing, grading, rewriting, and answer generation as distinct responsibilities. Source excerpts show the API and workflow wiring; some UI and pipeline details are supported only by the README or source index.
Main entry points: routes.py RAG endpoints · graph_builder.py Query classification · App.jsx React application · client.js React API client
Components 23
User interfaces
- React application
frontend/src/App.jsx - Chat interface
frontend/src/components/ChatArea.jsx - Upload dialog
frontend/src/components/UploadModal.jsx - Login page
frontend/src/pages/LoginPage.jsx - Streamlit chat
streamlit_app/pages/chat.py - React API client
frontend/src/api/client.js - Streamlit API client
streamlit_app/utils/api_client.py
API and sessions
- FastAPI service
src/main.py - RAG endpoints
src/api/routes.py - API authentication
src/api/security.py - Session history
src/memory/chat_history_mongo.py
Adaptive RAG workflow
- Workflow orchestration
src/rag/graph_builder.py - Query classification
src/rag/graph_builder.py - Retrieval agent
src/rag/reAct_agent.py - Grade and rewrite
src/rag/graph_builder.py - Answer generation
src/rag/graph_builder.py - Web search
src/rag/graph_builder.py - General LLM
src/rag/graph_builder.py
Knowledge and integrations
- MongoDB
src/db/mongo_client.py - Document processing
src/rag/document_upload.py - Vector retrieval
src/rag/retriever_setup.py - Groq language model
src/llms/openai.py
Other components
- Chat user
Connections 35
- Chat user → React application: uses
README.md - Chat user → Streamlit chat: uses
README.md - React application → Chat interface: renders
frontend/src/App.jsx - React application → Upload dialog: opens
frontend/src/App.jsx - React application → Login page: shows
frontend/src/App.jsx - React application → React API client: calls
frontend/src/App.jsx - Chat interface → React API client: calls
frontend/src/components/ChatArea.jsx - Upload dialog → React API client: uploads through
frontend/src/components/UploadModal.jsx - Login page → React API client: authenticates through
frontend/src/pages/LoginPage.jsx - React API client → RAG endpoints: calls
frontend/src/api/client.js - Streamlit chat → Streamlit API client: calls
streamlit_app/pages/chat.py - Streamlit API client → RAG endpoints: calls
streamlit_app/utils/api_client.py - Streamlit API client → API authentication: calls auth service
- FastAPI service → RAG endpoints: registers
src/main.py - RAG endpoints → API authentication: authenticates
src/api/routes.py - RAG endpoints → Session history: reads and writes
src/api/routes.py - Session history → MongoDB: persists in
src/memory/chat_history_mongo.py - RAG endpoints → MongoDB: queries sessions
src/api/routes.py - RAG endpoints → Workflow orchestration: invokes
src/api/routes.py - RAG endpoints → Document processing: dispatches upload
src/api/routes.py - Document processing → Vector retrieval: indexes chunks
src/rag/document_upload.py - Workflow orchestration → Query classification: starts at
src/rag/graph_builder.py - Query classification → Vector retrieval: classifies with retrieval
src/rag/graph_builder.py - Query classification → Retrieval agent: routes index queries
src/rag/graph_builder.py - Retrieval agent → Vector retrieval: retrieves from
src/rag/reAct_agent.py - Retrieval agent → Grade and rewrite: returns results for grading
src/rag/graph_builder.py - Grade and rewrite → Retrieval agent: rewrites and retries
src/rag/graph_builder.py - Grade and rewrite → Answer generation: routes relevant results
src/rag/graph_builder.py - Query classification → General LLM: routes general queries
src/rag/graph_builder.py - Query classification → Web search: routes search queries
src/rag/graph_builder.py - Web search → Answer generation: passes search results
src/rag/graph_builder.py - General LLM → Groq language model: generates with
src/rag/graph_builder.py - Query classification → Groq language model: classifies with
src/rag/graph_builder.py - Grade and rewrite → Groq language model: grades and rewrites with
src/rag/graph_builder.py - Answer generation → Groq language model: generates with
src/rag/graph_builder.py