How sabtain-dev/rag-chatbot works
Lumeluxe is a storefront RAG chatbot: a customer asks through the widget, the API applies session-aware chat logic, retrieves relevant catalog or policy content, and returns a grounded answer or fallback. The separate knowledge-base workflow ingests live product data and indexes cleaned documents. The graph preserves documented streaming, session reset, and rate limiting. Relationships for sampled runtime code are excerpt-backed; ingestion and indexing links rely on the README, since those scripts were not excerpted.
Main entry points: rag_service.py RAG service · routes.py Chat routes · index_documents.py Document indexing · generator.py Answer generator
Components 20
Chat client
- Chat widget
frontend/chatbot.js
API and limits
- FastAPI app
app/main.py - Chat routes
app/api/routes.py - Chat schemas
app/models/chat.py - IP rate limiter
app/core/rate_limit.py - Runtime config
app/core/config.py
Chat and retrieval
- RAG service
app/chatbot/rag_service.py - Session memory
app/chatbot/memory.py - Retriever
app/chatbot/retriever.py - Answer generator
app/chatbot/generator.py - System prompts
app/chatbot/prompts.py
Knowledge base
- Query embeddings
app/rag/embeddings.py - ChromaDB
chroma_db - Catalog ingestion
scripts/ingest_from_db.py - Cleaned documents
data/cleaned - Document indexing
scripts/index_documents.py - Document chunker
app/rag/chunker.py
Other components
- Customer
- Groq API
- MongoDB Atlas
Connections 22
- Customer → Chat widget: asks
README.md - Chat widget → Chat routes: sends chat
README.md - FastAPI app → Chat routes: mounts
app/main.py - FastAPI app → IP rate limiter: attaches
app/main.py - Chat routes → Chat schemas: validates
app/api/routes.py - Chat routes → IP rate limiter: limits requests
app/api/routes.py - Chat routes → RAG service: dispatches chat
app/api/routes.py - RAG service → Session memory: reads and writes
app/chatbot/rag_service.py - RAG service → Retriever: retrieves context
app/chatbot/rag_service.py - RAG service → Answer generator: generates answer
app/chatbot/rag_service.py - RAG service → Chat schemas: returns response
app/chatbot/rag_service.py - Retriever → Query embeddings: embeds query
app/chatbot/retriever.py - Retriever → ChromaDB: queries
app/chatbot/retriever.py - Answer generator → System prompts: uses prompt
app/chatbot/generator.py - Answer generator → Runtime config: loads settings
app/chatbot/generator.py - Answer generator → Groq API: requests completion
app/chatbot/generator.py - MongoDB Atlas → Catalog ingestion: provides catalog
README.md - Catalog ingestion → Document indexing: feeds reindexing
README.md - Cleaned documents → Document indexing: supplies documents
README.md - Document indexing → Document chunker: chunks documents
scripts/index_documents.py - Document indexing → Query embeddings: creates vectors
scripts/index_documents.py - Document indexing → ChromaDB: indexes chunks
scripts/index_documents.py