How sm-joe/localrag works
LocalRAG is a Docker-first local document RAG chatbot with persistent conversation history. The main workflow is browser upload or chat, FastAPI routing, document indexing or retrieval-grounded generation, and results with citations; PostgreSQL persists conversations while Qdrant stores document vectors. The graph preserves the documented UI, filename-aware retrieval, and conversation capabilities. Some route internals are only partly excerpted, so edges that rely on documented rather than sampled behavior cite the README.
Main entry points: ingestion.py Ingestion service · page.tsx Web workspace · main.py FastAPI app · chat.py Chat endpoint
Components 19
Web interface
- Web workspace
apps/web/app/page.tsx
API and history
- FastAPI app
apps/api/app/main.py - Chat endpoint
apps/api/app/routes/chat.py - Conversation management
apps/api/app/routes/conversations.py - Document endpoints
apps/api/app/routes/documents.py - Database access
apps/api/app/db.py - History models
apps/api/app/models.py - PostgreSQL
Document indexing
- Ingestion service
apps/api/app/services/ingestion.py - Document parser
apps/api/app/services/parser.py - Text chunker
apps/api/app/services/chunker.py - Embedding service
apps/api/app/services/embeddings.py - Vector store
apps/api/app/services/vector_store.py - Qdrant
Grounded answers
- RAG orchestration
apps/api/app/services/rag.py - Document retrieval
apps/api/app/services/retrieval.py - LLM service
apps/api/app/services/llm.py - Local Ollama
Other components
- Browser user
Connections 25
- Browser user → Web workspace: uses
README.md - Web workspace → FastAPI app: calls API
README.md - FastAPI app → Document endpoints: registers
apps/api/app/main.py - FastAPI app → Chat endpoint: registers
apps/api/app/main.py - FastAPI app → Conversation management: registers
apps/api/app/main.py - Document endpoints → Ingestion service: indexes uploads
README.md - Ingestion service → Document parser: parses files
apps/api/app/services/ingestion.py - Ingestion service → Text chunker: chunks text
apps/api/app/services/ingestion.py - Ingestion service → Embedding service: embeds chunks
apps/api/app/services/ingestion.py - Ingestion service → Vector store: stores vectors
apps/api/app/services/ingestion.py - Embedding service → Local Ollama: requests embeddings
apps/api/app/services/embeddings.py - Vector store → Qdrant: reads and writes
README.md - Chat endpoint → RAG orchestration: requests answer
apps/api/app/routes/chat.py - RAG orchestration → Document retrieval: retrieves evidence
apps/api/app/services/rag.py - RAG orchestration → LLM service: generates answer
apps/api/app/services/rag.py - Document retrieval → Embedding service: embeds query
apps/api/app/services/retrieval.py - Document retrieval → Vector store: searches vectors
apps/api/app/services/retrieval.py - LLM service → Local Ollama: generates locally
apps/api/app/services/llm.py - Chat endpoint → Database access: persists history
apps/api/app/routes/chat.py - Conversation management → PostgreSQL: manages history
README.md - Chat endpoint → History models: records messages
apps/api/app/routes/chat.py - Conversation management → History models: manages records
README.md - Database access → PostgreSQL: connects
apps/api/app/db.py - Web workspace → Document endpoints: uploads and lists
README.md - Web workspace → Conversation management: restores history
README.md