How bharathkumarreddy007/local-rag-chat works
Local RAG Chat is a single-user browser chatbot: users choose general chat or document Q&A, optionally manage/index documents, then receive streamed answers and retrieved excerpts. The backend validates requests, coordinates retrieval and local model calls, while the browser keeps conversation history and supports exports. Its RAG stages include parsing, chunking, embedding, persistent indexing, retrieval, and grounded prompting. The graph reflects the sampled source and README; finer route/UI wiring and some implementation details are documented but not fully excerpted.
Main entry points: rag.py RAG store · app.js Chat and settings · main.py Chat orchestration · index.html Chat interface
Components 17
Browser experience
- Chat interface
app/static/index.html - Chat and settings
app/static/app.js - Local chat history
app/static/app.js - Interface styling
app/static/style.css
HTTP application
- FastAPI routes
app/main.py - Chat orchestration
app/main.py - OpenAI-compatible API
app/main.py
Retrieval pipeline
- RAG store
app/rag.py - Document parsing
app/rag.py - Text chunking
app/rag.py - Embedding requests
app/rag.py - Passage retrieval
app/rag.py - Grounded prompting
app/rag.py
Local services and data
- Persistent vector index
app/rag.py - Ollama models
- Included documents
data/documents
Other components
- Single user
Connections 23
- Single user → Chat interface: uses
README.md - Chat interface → Chat and settings: loads
- Chat and settings → FastAPI routes: calls
app/static/app.js - Chat and settings → Local chat history: persists
app/static/app.js - Chat interface → Interface styling: styles with
- FastAPI routes → Chat orchestration: dispatches
app/main.py - FastAPI routes → OpenAI-compatible API: routes to
app/main.py - Chat orchestration → RAG store: retrieves via
app/main.py - Chat orchestration → Grounded prompting: builds prompt
app/main.py - Chat orchestration → Ollama models: streams chat
app/main.py - OpenAI-compatible API → Chat orchestration: reuses
app/main.py - RAG store → Document parsing: parses with
app/rag.py - RAG store → Text chunking: splits text
app/rag.py - RAG store → Embedding requests: embeds chunks
app/rag.py - Embedding requests → Ollama models: requests vectors
app/rag.py - RAG store → Persistent vector index: reads and writes
app/rag.py - RAG store → Passage retrieval: queries
app/rag.py - Passage retrieval → Embedding requests: embeds query
app/rag.py - Passage retrieval → Persistent vector index: searches
app/rag.py - FastAPI routes → Included documents: indexes on request
app/main.py - Chat and settings → Included documents: requests indexing
app/static/app.js - Grounded prompting → Passage retrieval: uses passages
app/rag.py - Chat and settings → Ollama models: selects models via API