How pranav-singhal-0403/local-model-router works
Local Model Router is a PDF-grounded chat application. Users upload PDFs to build an indexed knowledge base, ask questions in a conversation, and receive answers with document/page sources and latency details; they can also manage documents and saved chats. The graph separates frontend, API and persistence, and retrieval/generation responsibilities. The sampled code shows ingestion and chat orchestration; some document and application-state wiring is unsampled, so those links are omitted or marked unverified.
Main entry points: backend Retrieval strategies · ingestion_pipeline.py PDF ingestion · api.js HTTP client · chat.py Chat endpoint
Components 27
Web interface
- Workspace
frontend/src/App.jsx - Chat window
frontend/src/components/ChatWindow.jsx - Document library
frontend/src/components/DocuemntLibrary.jsx - Message view
frontend/src/components/Message.jsx - Source card
frontend/src/components/SourceCard.jsx - HTTP client
frontend/src/services/api.js
API and history
- Chat endpoint
backend/api/chat.py - Document endpoints
backend/api/documents.py - History endpoints
backend/api/history.py - Health endpoint
backend/api/health.py - Chat history service
backend/chat_history.py - PostgreSQL access
backend/database.py
RAG processing
- RAG application state
backend/app_state.py - PDF ingestion
backend/ingestion_pipeline.py - PDF parser
backend/pdf_parser.py - Text chunker
backend/chunker.py - Dense embeddings
backend/embeddings_dense.py - SPLADE embeddings
backend/embeddings_splade.py - Retrieval strategies
backend - Answer generation
backend/answer_generator.py - Prompt builder
backend/prompt_builder.py - Ollama client
backend/ollama_client.py - Vector store client
backend/qdrant_client.py
External services
- Qdrant
- PostgreSQL
- Ollama model service
Other components
- User
Connections 36
- User → Workspace: uses
README.md - Workspace → Chat window: shows chat
frontend/src/App.jsx - Workspace → Document library: shows library
frontend/src/App.jsx - Workspace → HTTP client: manages chats
frontend/src/App.jsx - Chat window → HTTP client: sends requests
frontend/src/components/ChatWindow.jsx - Chat window → Message view: renders messages
frontend/src/components/ChatWindow.jsx - Chat window → Source card: renders sources
frontend/src/components/ChatWindow.jsx - Document library → HTTP client: manages documents
frontend/src/components/DocuemntLibrary.jsx - HTTP client → Chat endpoint: posts chat
frontend/src/services/api.js - HTTP client → Document endpoints: calls document routes
frontend/src/services/api.js - HTTP client → History endpoints: calls history routes
frontend/src/services/api.js - HTTP client → Health endpoint: checks health
frontend/src/services/api.js - Chat endpoint → RAG application state: uses RAG state
backend/api/chat.py - Chat endpoint → Chat history service: loads and saves
backend/api/chat.py - Chat endpoint → Retrieval strategies: retrieves chunks
backend/api/chat.py - Chat endpoint → Answer generation: generates answer
backend/api/chat.py - History endpoints → Chat history service: manages conversations
backend/main.py - Chat history service → PostgreSQL access: uses connections
backend/chat_history.py - PostgreSQL access → PostgreSQL: reads and writes
README.md - Document endpoints → PDF ingestion: indexes uploads
- PDF ingestion → PDF parser: extracts pages
backend/ingestion_pipeline.py - PDF ingestion → Text chunker: splits text
backend/ingestion_pipeline.py - PDF ingestion → Dense embeddings: encodes chunks
backend/ingestion_pipeline.py - PDF ingestion → SPLADE embeddings: encodes chunks
backend/ingestion_pipeline.py - PDF ingestion → Vector store client: upserts vectors
backend/ingestion_pipeline.py - Retrieval strategies → Dense embeddings: embeds queries
backend/retreiver_dense.py - Retrieval strategies → SPLADE embeddings: embeds queries
backend/retriever_splade.py - Retrieval strategies → Vector store client: searches vectors
backend/retreiver_dense.py - Retrieval strategies → Vector store client: searches vectors
backend/retriever_splade.py - Retrieval strategies → Retrieval strategies: combines results
backend/retriever_hybrid.py - Vector store client → Qdrant: stores and searches
README.md - Answer generation → Prompt builder: builds prompt
backend/answer_generator.py - Answer generation → Ollama client: requests completion
backend/answer_generator.py - Ollama client → Ollama model service: runs inference
README.md - RAG application state → PDF ingestion: configures pipeline
- RAG application state → Retrieval strategies: configures retrieval
backend/main.py