How pvnkmr205/ragnarok---production-rag-chatbot-over-your-own-documents works
RAGnarok turns uploaded or locally supplied documents into a searchable corpus, then answers questions grounded in retrieved passages with validated citations or a refusal. The main path is document extraction and chunking, embedding and persistence, vector retrieval, prompt construction, and LLM response. Streamlit and FastAPI expose the shared query core; the hybrid BM25/reranking implementation is a documented experiment, not the production path. The README also describes evaluation capabilities, but those are development tools rather than runtime product components. API ingestion is mentioned in Ingest.py’s docstring but is not present in the sampled api.py excerpt.
Main entry points: app.py Upload and chat UI · api.py HTTP API · Ingest.py Ingestion pipeline · Query.py Vector retrieval
Components 17
Document ingestion
- Ingestion pipeline
Ingest.py - Format extraction
Ingest.py - Chunk and page mapping
Ingest.py - Document embeddings
Ingest.py - Chunk records
chunks.json - Embedding matrix
embeddings.npy
Grounded Q&A
- Query and corpus core
Query.py - Vector retrieval
Query.py - Citation prompt
Query.py - Citation validation
Query.py
Product interfaces
- Upload and chat UI
app.py - HTTP API
api.py
Retrieval experiment
- Hybrid retrieval
Query_hybrid.py - BM25 candidates
Query_hybrid.py - LLM reranking
Query_hybrid.py
Other components
- Document user
- OpenRouter models
Connections 27
- Document user → Upload and chat UI: uploads and asks
README.md - Document user → HTTP API: asks via HTTP
README.md - Document user → Ingestion pipeline: runs CLI ingestion
README.md - Upload and chat UI → Ingestion pipeline: ingests upload
app.py - Ingestion pipeline → Format extraction: loads documents
Ingest.py - Format extraction → Chunk and page mapping: provides text and page offsets
Ingest.py - Chunk and page mapping → Document embeddings: embeds chunks
Ingest.py - Document embeddings → OpenRouter models: requests embeddings
Ingest.py - Ingestion pipeline → Chunk records: writes records
Ingest.py - Ingestion pipeline → Embedding matrix: writes vectors
Ingest.py - Upload and chat UI → Query and corpus core: reloads corpus
app.py - Query and corpus core → Chunk records: loads chunks
Query.py - Query and corpus core → Embedding matrix: loads vectors
Query.py - Upload and chat UI → Vector retrieval: requests results
app.py - HTTP API → Vector retrieval: requests results
api.py - Vector retrieval → OpenRouter models: embeds question
Query.py - Vector retrieval → Citation prompt: returns retrieved chunks
Query.py - Upload and chat UI → Citation prompt: builds answer prompt
app.py - HTTP API → Citation prompt: builds answer prompt
api.py - Upload and chat UI → OpenRouter models: requests answer
app.py - HTTP API → OpenRouter models: requests answer
api.py - Upload and chat UI → Citation validation: checks citations
app.py - HTTP API → Citation validation: checks citations
api.py - Hybrid retrieval → BM25 candidates: combines candidates
Query_hybrid.py - Hybrid retrieval → Vector retrieval: uses vector candidates
- BM25 candidates → LLM reranking: supplies candidates
Query_hybrid.py - Hybrid retrieval → OpenRouter models: scores and answers
Query_hybrid.py