How data-science-lover/enterprise-rag-chatbot works
Enterprise RAG Chat lets users organize conversations and documents into spaces, configure providers, and ask questions against uploaded knowledge. The principal path is chat UI → FastAPI chat route → retrieval and LLM streaming; uploads enter document ingestion and persistent vector storage. Separate branches cover space/chat management and provider/model settings. The source excerpts show backend retrieval, ingestion, storage, and frontend state persistence, but not the complete frontend request wiring; those uncertain connections are dashed. OCR and provider breadth are documented or visible in sampled code.
Main entry points: main.py FastAPI application · SettingsContext.tsx Provider settings state · routes.py Chat route · store.py Chroma vector store
Components 25
Chat and workspace UI
- App entry
src/app/page.tsx - App shell
src/components/layout/AppShell.tsx - Workspace navigation
src/components/layout/Sidebar.tsx - Chat and citations
src/components/chat/ChatWindow.tsx - Document upload
src/components/chat/FileUploadModal.tsx - Space state
src/components/spaces/SpacesContext.tsx
Provider settings
- Settings UI
src/components/settings/SettingsDialog.tsx - Provider settings state
src/components/settings/SettingsContext.tsx - Model selection
src/components/chat/ModelSelector.tsx
Backend API
- FastAPI application
backend/main.py - Chat route
backend/api/routes.py - Document routes
backend/api/documents.py - Space and chat management
backend/api/management.py - Model routes
backend/api/models_routes.py - API key routes
backend/api/keys.py - Provider routes
backend/api/providers.py
RAG processing
- Chat document reader
backend/rag/document_reader.py - Document ingestion and OCR
backend/rag/ingest.py - Vector retrieval
backend/rag/query.py - LLM streaming client
backend/models/llm.py
Persistence
- Chroma vector store
backend/rag/store.py - Browser-local state
src/components/spaces/SpacesContext.tsx
Other components
- User
- LLM providers
- ChromaDB
Connections 34
- User → App entry: opens
src/app/page.tsx - App entry → App shell: renders
src/app/page.tsx - App shell → Workspace navigation: renders
src/components/layout/AppShell.tsx - App shell → Chat and citations: renders
src/components/layout/AppShell.tsx - Workspace navigation → Space state: selects spaces
src/components/layout/Sidebar.tsx - Chat and citations → Space state: reads workspace
src/components/chat/ChatWindow.tsx - Chat and citations → Document upload: opens upload
src/components/chat/ChatWindow.tsx - Document upload → Document routes: uploads files
- Chat and citations → Chat route: sends chat
- Settings UI → Provider settings state: reads settings
src/components/settings/SettingsDialog.tsx - Model selection → Provider settings state: reads models
src/components/chat/ModelSelector.tsx - Provider settings state → Provider routes: loads providers
src/components/settings/SettingsContext.tsx - Provider settings state → Model routes: loads models
src/components/settings/SettingsContext.tsx - Provider settings state → API key routes: loads keys
- Space state → Browser-local state: persists state
src/components/spaces/SpacesContext.tsx - Space state → Space and chat management: deletes spaces
src/components/spaces/SpacesContext.tsx - FastAPI application → Chat route: registers routes
backend/main.py - FastAPI application → Document routes: registers routes
backend/main.py - FastAPI application → Space and chat management: registers routes
backend/main.py - FastAPI application → Model routes: registers routes
backend/main.py - FastAPI application → API key routes: registers routes
backend/main.py - FastAPI application → Provider routes: registers routes
backend/main.py - Chat route → Vector retrieval: retrieves context
backend/api/routes.py - Chat route → Chat document reader: reads chat files
backend/api/routes.py - Chat route → LLM streaming client: streams completion
backend/api/routes.py - Document routes → Document ingestion and OCR: ingests documents
backend/api/documents.py - Document routes → Chroma vector store: manages vectors
backend/api/documents.py - Space and chat management → Chroma vector store: manages vectors
backend/api/management.py - Space and chat management → Document ingestion and OCR: uses ingestion
backend/api/management.py - Model routes → LLM streaming client: lists models
backend/api/models_routes.py - Vector retrieval → Chroma vector store: retrieves vectors
backend/rag/query.py - Document ingestion and OCR → Chroma vector store: writes vectors
backend/rag/ingest.py - LLM streaming client → LLM providers: calls provider
backend/models/llm.py - Chroma vector store → ChromaDB: persists collections
backend/rag/store.py