How mlouie/rag-chatbot works
The product is a multi-tenant platform for turning uploaded documents into embeddable RAG chatbots. Admins create bots and upload content; the API processes it into searchable chunks. A visitor chats through the widget or dashboard preview, and the API retrieves relevant context and generates a provider-backed answer. Admins can review unanswered questions and add answers to bot knowledge. Source-index references and README claims support the main backend links; frontend/API wiring and unsampled subsystems are shown cautiously.
Main entry points: chat.py Chat routes · unanswered_questions.py Question routes · main.py FastAPI entry · documents.py Document routes
Components 27
Admin Console
- Admin dashboard
app/src/app/(dashboard)/dashboard/page.tsx - Bot management
app/src/app/(dashboard)/bots/page.tsx - Document admin
app/src/app/(dashboard)/bots/[id]/documents/page.tsx - Question review
app/src/app/(dashboard)/unanswered-questions/page.tsx - Chat preview
app/src/components/chat/chat-preview.tsx
API and Access
- JWT authentication
api/api/core/auth.py - FastAPI entry
api/main.py - Bot routes
api/api/routers/bots.py - Document routes
api/api/routers/documents.py - Chat routes
api/api/routers/chat.py - Question routes
api/api/routers/unanswered_questions.py - Usage statistics
api/api/routers/stats.py - Domain records
api/api/models - Postgres and pgvector
api/api/core/database.py
Knowledge Pipeline
- Ingestion jobs
api/api/services/jobs/processor.py - Document processing
api/api/services/document/processor.py - Text extraction
api/api/services/document/extractor.py - Text chunking
api/api/services/document/chunker.py - Embedding generation
api/api/services/document/embedder.py
Chat Runtime
- Retrieval and generation
api/api/services/rag/service.py - OpenAI provider
api/api/services/llm/openai_provider.py - Anthropic provider
api/api/services/llm/anthropic_provider.py
Chat Clients
- Widget initializer
widget/src/index.js - Widget chat UI
widget/src/widget.js - Widget API client
widget/src/api.js
Other components
- Bot administrator
- Website visitor
Connections 40
- Bot administrator → Admin dashboard: manages bots
README.md - Admin dashboard → Bot management: opens
- Bot administrator → Document admin: uploads files
README.md - Bot administrator → Question review: reviews questions
README.md - Bot administrator → Chat preview: tests bot
README.md - FastAPI entry → Bot routes: registers
api/main.py - FastAPI entry → Document routes: registers
api/main.py - FastAPI entry → Chat routes: registers
api/main.py - FastAPI entry → Usage statistics: registers
api/main.py - FastAPI entry → Question routes: registers
api/main.py - Bot routes → JWT authentication: authenticates
api/api/routers/bots.py - Bot routes → Postgres and pgvector: uses sessions
api/api/routers/bots.py - Bot routes → Domain records: queries bots
api/api/routers/bots.py - Document routes → JWT authentication: authenticates
api/api/routers/documents.py - Document routes → Postgres and pgvector: uses sessions
api/api/routers/documents.py - Document routes → Ingestion jobs: dispatches processing
api/api/routers/documents.py - Document routes → Domain records: uses records
api/api/routers/documents.py - Ingestion jobs → Document processing: invokes
- Document processing → Text extraction: extracts text
api/api/services/document/processor.py - Document processing → Text chunking: splits text
api/api/services/document/processor.py - Document processing → Embedding generation: embeds chunks
api/api/services/document/processor.py - Document processing → Domain records: updates documents
api/api/services/document/processor.py - Chat routes → JWT authentication: authenticates optionally
api/api/routers/chat.py - Chat routes → Postgres and pgvector: uses sessions
api/api/routers/chat.py - Chat routes → Domain records: stores chat records
api/api/routers/chat.py - Chat routes → Retrieval and generation: requests answers
api/api/routers/chat.py - Retrieval and generation → Postgres and pgvector: searches vectors
api/api/services/rag/service.py - Retrieval and generation → OpenAI provider: selects provider
api/api/services/rag/service.py - Retrieval and generation → Anthropic provider: selects provider
api/api/services/rag/service.py - Question routes → JWT authentication: authenticates
api/api/routers/unanswered_questions.py - Question routes → Postgres and pgvector: uses sessions
api/api/routers/unanswered_questions.py - Question routes → Domain records: reads and updates
api/api/routers/unanswered_questions.py - Question routes → Embedding generation: embeds quick answers
api/api/routers/unanswered_questions.py - Website visitor → Widget initializer: loads embed
README.md - Widget initializer → Widget chat UI: initializes
widget/src/index.js - Widget chat UI → Widget API client: sends messages
widget/src/widget.js - Widget API client → Chat routes: posts chat
README.md - Chat preview → Chat routes: tests chat
README.md - Bot administrator → Bot routes: configures bots
README.md - Bot administrator → Question routes: submits answers
README.md