How mitanshumakwana/pdf-chatbot-using-rag works
This is a session-scoped PDF RAG web app: a signed-in user uploads PDFs, asks questions about selected documents, and receives grounded answers with source pages. The browser sends authenticated requests to FastAPI; indexing and question answering are handled by the RAG assistant, which uses ChromaDB for document chunks and a configured model for generation. Redis is an optional semantic answer cache, not the document store. The graph preserves the documented extraction, chunking, embedding, per-document retrieval, and cache stages; some internal RAG details come from the README because the source excerpt is partial.
Main entry points: main.py FastAPI routes · script.js Chat interface · rag.py Per-document search · semantic_cache.py Semantic cache
Components 18
Web experience
- Chat interface
static/script.js - Web page
templates/index.html
API and identity
- FastAPI routes
main.py - Bearer verification
authentication.py
Document Q&A
- PDF indexing
rag.py - PDF extraction
rag.py - Chunk and embed
rag.py - ChromaDB documents
rag.py - Per-document search
rag.py - Labeled context
rag.py - Configured LLM
rag.py - Answer and sources
rag.py
Answer cache
- Cache lifecycle
main.py - Semantic cache
semantic_cache.py
Other components
- Signed-in user
- Supabase Auth
- Ollama or Gemini
- Redis Search
Connections 22
- Signed-in user → Chat interface: uses
README.md - Chat interface → Web page: renders
- Chat interface → FastAPI routes: sends requests
README.md - Chat interface → Supabase Auth: authenticates
static/script.js - FastAPI routes → Bearer verification: requires user
main.py - Bearer verification → Supabase Auth: verifies token
authentication.py - FastAPI routes → PDF indexing: indexes PDF
main.py - PDF indexing → PDF extraction: extracts text
README.md - PDF extraction → Chunk and embed: splits and embeds
README.md - Chunk and embed → ChromaDB documents: stores chunks
README.md - FastAPI routes → Per-document search: queries documents
main.py - Per-document search → ChromaDB documents: searches chunks
README.md - Per-document search → Labeled context: labels results
README.md - Labeled context → Configured LLM: prompts model
README.md - Configured LLM → Ollama or Gemini: calls provider
README.md - Configured LLM → Answer and sources: generates answer
README.md - Answer and sources → Chat interface: returns sources
README.md - FastAPI routes → Cache lifecycle: starts and closes
main.py - Cache lifecycle → Semantic cache: creates cache
main.py - Semantic cache → Redis Search: reads and writes
semantic_cache.py - Per-document search → Semantic cache: looks up and stores answers
README.md - PDF indexing → Semantic cache: invalidates scope
rag.py