How fatir002/rag-chatbot works
RAG Chatbot lets a user upload one PDF, DOCX, or TXT document, then ask questions grounded in that upload. The browser sends uploads to the FastAPI entry point, which extracts text and delegates chunking, embedding, and storage; queries are classified, retrieved within the supplied document ID, and answered from retrieved context, with source text returned for verification. Casual messages skip retrieval. The README documents Supabase/pgvector and Groq integrations; sampled code confirms their callers. The graph omits deployment details and does not infer unsampled implementation links.
Main entry points: main.py FastAPI routes · clients.py Shared clients · generate.py Answer generation · router.py Message classifier
Components 15
Chat interface
- Browser
static/index.html - Chat client
static/script.js
API orchestration
- FastAPI routes
app/main.py - API contracts
app/models.py - Message classifier
app/router.py - Answer generation
app/generate.py
Document pipeline
- Text extraction
app/loaders.py - Chunk and ingest
app/ingest.py - Scoped retrieval
app/retrieve.py
Models and services
- Shared clients
app/clients.py - Settings
app/config.py - Sentence embeddings
app/clients.py - Supabase pgvector
- Groq models
Other components
- User
Connections 20
- User → Browser: uses
- Browser → Chat client: loads
- Chat client → FastAPI routes: uploads / queries
- FastAPI routes → Chat client: returns answer and sources
- FastAPI routes → API contracts: validates / shapes
- FastAPI routes → Text extraction: extracts upload text
- FastAPI routes → Chunk and ingest: ingests text
- Chunk and ingest → Shared clients: encodes / stores
- FastAPI routes → Message classifier: classifies question
- Message classifier → Groq models: classifies via
- FastAPI routes → Answer generation: generates casual reply
- FastAPI routes → Scoped retrieval: retrieves document chunks
- Scoped retrieval → Shared clients: encodes / searches
- FastAPI routes → Answer generation: generates grounded answer
- Answer generation → Groq models: generates via
- Shared clients → Sentence embeddings: uses
- Shared clients → Supabase pgvector: connects to
- Shared clients → Settings: reads settings
- Message classifier → Settings: reads settings
- Answer generation → Settings: reads settings