# data-science-lover/enterprise-rag-chatbot architecture

> Architecture diagram of the GitHub repository data-science-lover/enterprise-rag-chatbot, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/data-science-lover/enterprise-rag-chatbot
- Repository: https://github.com/data-science-lover/enterprise-rag-chatbot

## Overview

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: [`backend/main.py`](https://github.com/data-science-lover/enterprise-rag-chatbot/blob/main/backend/main.py) (FastAPI application), [`src/components/settings/SettingsContext.tsx`](https://github.com/data-science-lover/enterprise-rag-chatbot/blob/main/src/components/settings/SettingsContext.tsx) (Provider settings state), [`backend/api/routes.py`](https://github.com/data-science-lover/enterprise-rag-chatbot/blob/main/backend/api/routes.py) (Chat route), [`backend/rag/store.py`](https://github.com/data-science-lover/enterprise-rag-chatbot/blob/main/backend/rag/store.py) (Chroma vector store)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Chat and workspace UI"]
  node_page["App entry<br/>[page.tsx]"]
  node_shell["App shell<br/>[AppShell.tsx]"]
  node_sidebar["Workspace navigation<br/>[Sidebar.tsx]"]
  node_chat["Chat and citations<br/>[ChatWindow.tsx]"]
  node_upload["Document upload"]
  node_spaces["Space state<br/>[SpacesContext.tsx]"]
end

subgraph group_configuration["Provider settings"]
  node_settingsui["Settings UI<br/>[SettingsDialog.tsx]"]
  node_settings["Provider settings state"]
  node_modelui["Model selection<br/>[ModelSelector.tsx]"]
end

subgraph group_api["Backend API"]
  node_main["FastAPI application<br/>[main.py]"]
  node_chatapi["Chat route<br/>[routes.py]"]
  node_docapi["Document routes<br/>[documents.py]"]
  node_manageapi["Space and chat management<br/>[management.py]"]
  node_modelapi["Model routes<br/>[models_routes.py]"]
  node_keyapi["API key routes<br/>[keys.py]"]
  node_providerapi["Provider routes<br/>[providers.py]"]
end

subgraph group_rag["RAG processing"]
  node_reader["Chat document reader<br/>[document_reader.py]"]
  node_ingest["Document ingestion and OCR<br/>[ingest.py]"]
  node_query["Vector retrieval<br/>[query.py]"]
  node_llm["LLM streaming client<br/>[llm.py]"]
end

subgraph group_persistence["Persistence"]
  node_store[("Chroma vector store<br/>[store.py]")]
  node_browserstore[("Browser-local state<br/>[SpacesContext.tsx]")]
end

node_user(("User"))
node_llmproviders{{"LLM providers"}}
node_chromadb[("ChromaDB")]

node_user -->|"opens"| node_page
node_page -->|"renders"| node_shell
node_shell -->|"renders"| node_sidebar
node_shell -->|"renders"| node_chat
node_sidebar -->|"selects spaces"| node_spaces
node_chat -->|"reads workspace"| node_spaces
node_chat -->|"opens upload"| node_upload
node_upload -.->|"uploads files"| node_docapi
node_chat -.->|"sends chat"| node_chatapi
node_settingsui -->|"reads settings"| node_settings
node_modelui -->|"reads models"| node_settings
node_settings -->|"loads providers"| node_providerapi
node_settings -->|"loads models"| node_modelapi
node_settings -.->|"loads keys"| node_keyapi
node_spaces -->|"persists state"| node_browserstore
node_spaces -->|"deletes spaces"| node_manageapi
node_main -->|"registers routes"| node_chatapi
node_main -->|"registers routes"| node_docapi
node_main -->|"registers routes"| node_manageapi
node_main -->|"registers routes"| node_modelapi
node_main -->|"registers routes"| node_keyapi
node_main -->|"registers routes"| node_providerapi
node_chatapi -->|"retrieves context"| node_query
node_chatapi -->|"reads chat files"| node_reader
node_chatapi -->|"streams completion"| node_llm
node_docapi -->|"ingests documents"| node_ingest
node_docapi -->|"manages vectors"| node_store
node_manageapi -->|"manages vectors"| node_store
node_manageapi -->|"uses ingestion"| node_ingest
node_modelapi -->|"lists models"| node_llm
node_query -->|"retrieves vectors"| node_store
node_ingest -->|"writes vectors"| node_store
node_llm -->|"calls provider"| node_llmproviders
node_store -->|"persists collections"| node_chromadb

click node_page "https://github.com/data-science-lover/enterprise-rag-chatbot/blob/main/src/app/page.tsx"
click node_shell "https://github.com/data-science-lover/enterprise-rag-chatbot/blob/main/src/components/layout/AppShell.tsx"
click node_sidebar "https://github.com/data-science-lover/enterprise-rag-chatbot/blob/main/src/components/layout/Sidebar.tsx"
click node_chat "https://github.com/data-science-lover/enterprise-rag-chatbot/blob/main/src/components/chat/ChatWindow.tsx"
click node_upload "https://github.com/data-science-lover/enterprise-rag-chatbot/blob/main/src/components/chat/FileUploadModal.tsx"
click node_spaces "https://github.com/data-science-lover/enterprise-rag-chatbot/blob/main/src/components/spaces/SpacesContext.tsx"
click node_settingsui "https://github.com/data-science-lover/enterprise-rag-chatbot/blob/main/src/components/settings/SettingsDialog.tsx"
click node_settings "https://github.com/data-science-lover/enterprise-rag-chatbot/blob/main/src/components/settings/SettingsContext.tsx"
click node_modelui "https://github.com/data-science-lover/enterprise-rag-chatbot/blob/main/src/components/chat/ModelSelector.tsx"
click node_main "https://github.com/data-science-lover/enterprise-rag-chatbot/blob/main/backend/main.py"
click node_chatapi "https://github.com/data-science-lover/enterprise-rag-chatbot/blob/main/backend/api/routes.py"
click node_docapi "https://github.com/data-science-lover/enterprise-rag-chatbot/blob/main/backend/api/documents.py"
click node_manageapi "https://github.com/data-science-lover/enterprise-rag-chatbot/blob/main/backend/api/management.py"
click node_modelapi "https://github.com/data-science-lover/enterprise-rag-chatbot/blob/main/backend/api/models_routes.py"
click node_keyapi "https://github.com/data-science-lover/enterprise-rag-chatbot/blob/main/backend/api/keys.py"
click node_providerapi "https://github.com/data-science-lover/enterprise-rag-chatbot/blob/main/backend/api/providers.py"
click node_reader "https://github.com/data-science-lover/enterprise-rag-chatbot/blob/main/backend/rag/document_reader.py"
click node_ingest "https://github.com/data-science-lover/enterprise-rag-chatbot/blob/main/backend/rag/ingest.py"
click node_query "https://github.com/data-science-lover/enterprise-rag-chatbot/blob/main/backend/rag/query.py"
click node_llm "https://github.com/data-science-lover/enterprise-rag-chatbot/blob/main/backend/models/llm.py"
click node_store "https://github.com/data-science-lover/enterprise-rag-chatbot/blob/main/backend/rag/store.py"
click node_browserstore "https://github.com/data-science-lover/enterprise-rag-chatbot/blob/main/src/components/spaces/SpacesContext.tsx"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_page,node_shell,node_sidebar,node_chat,node_upload,node_spaces,node_user toneBlue
class node_settingsui,node_settings,node_modelui,node_chromadb toneAmber
class node_main,node_chatapi,node_docapi,node_manageapi,node_modelapi,node_keyapi,node_providerapi toneMint
class node_reader,node_ingest,node_query,node_llm toneRose
class node_store,node_browserstore,node_llmproviders toneIndigo
```

## Components

### Chat and workspace UI

- [App entry](https://github.com/data-science-lover/enterprise-rag-chatbot/blob/main/src/app/page.tsx): `src/app/page.tsx`
- [App shell](https://github.com/data-science-lover/enterprise-rag-chatbot/blob/main/src/components/layout/AppShell.tsx): `src/components/layout/AppShell.tsx`
- [Workspace navigation](https://github.com/data-science-lover/enterprise-rag-chatbot/blob/main/src/components/layout/Sidebar.tsx): `src/components/layout/Sidebar.tsx`
- [Chat and citations](https://github.com/data-science-lover/enterprise-rag-chatbot/blob/main/src/components/chat/ChatWindow.tsx): `src/components/chat/ChatWindow.tsx`
- [Document upload](https://github.com/data-science-lover/enterprise-rag-chatbot/blob/main/src/components/chat/FileUploadModal.tsx): `src/components/chat/FileUploadModal.tsx`
- [Space state](https://github.com/data-science-lover/enterprise-rag-chatbot/blob/main/src/components/spaces/SpacesContext.tsx): `src/components/spaces/SpacesContext.tsx`

### Provider settings

- [Settings UI](https://github.com/data-science-lover/enterprise-rag-chatbot/blob/main/src/components/settings/SettingsDialog.tsx): `src/components/settings/SettingsDialog.tsx`
- [Provider settings state](https://github.com/data-science-lover/enterprise-rag-chatbot/blob/main/src/components/settings/SettingsContext.tsx): `src/components/settings/SettingsContext.tsx`
- [Model selection](https://github.com/data-science-lover/enterprise-rag-chatbot/blob/main/src/components/chat/ModelSelector.tsx): `src/components/chat/ModelSelector.tsx`

### Backend API

- [FastAPI application](https://github.com/data-science-lover/enterprise-rag-chatbot/blob/main/backend/main.py): `backend/main.py`
- [Chat route](https://github.com/data-science-lover/enterprise-rag-chatbot/blob/main/backend/api/routes.py): `backend/api/routes.py`
- [Document routes](https://github.com/data-science-lover/enterprise-rag-chatbot/blob/main/backend/api/documents.py): `backend/api/documents.py`
- [Space and chat management](https://github.com/data-science-lover/enterprise-rag-chatbot/blob/main/backend/api/management.py): `backend/api/management.py`
- [Model routes](https://github.com/data-science-lover/enterprise-rag-chatbot/blob/main/backend/api/models_routes.py): `backend/api/models_routes.py`
- [API key routes](https://github.com/data-science-lover/enterprise-rag-chatbot/blob/main/backend/api/keys.py): `backend/api/keys.py`
- [Provider routes](https://github.com/data-science-lover/enterprise-rag-chatbot/blob/main/backend/api/providers.py): `backend/api/providers.py`

### RAG processing

- [Chat document reader](https://github.com/data-science-lover/enterprise-rag-chatbot/blob/main/backend/rag/document_reader.py): `backend/rag/document_reader.py`
- [Document ingestion and OCR](https://github.com/data-science-lover/enterprise-rag-chatbot/blob/main/backend/rag/ingest.py): `backend/rag/ingest.py`
- [Vector retrieval](https://github.com/data-science-lover/enterprise-rag-chatbot/blob/main/backend/rag/query.py): `backend/rag/query.py`
- [LLM streaming client](https://github.com/data-science-lover/enterprise-rag-chatbot/blob/main/backend/models/llm.py): `backend/models/llm.py`

### Persistence

- [Chroma vector store](https://github.com/data-science-lover/enterprise-rag-chatbot/blob/main/backend/rag/store.py): `backend/rag/store.py`
- [Browser-local state](https://github.com/data-science-lover/enterprise-rag-chatbot/blob/main/src/components/spaces/SpacesContext.tsx): `src/components/spaces/SpacesContext.tsx`

### Other components

- **User**
- **LLM providers**
- **ChromaDB**

## Connections

- User → App entry: opens (evidence: `src/app/page.tsx`)
- App entry → App shell: renders (evidence: `src/app/page.tsx`)
- App shell → Workspace navigation: renders (evidence: `src/components/layout/AppShell.tsx`)
- App shell → Chat and citations: renders (evidence: `src/components/layout/AppShell.tsx`)
- Workspace navigation → Space state: selects spaces (evidence: `src/components/layout/Sidebar.tsx`)
- Chat and citations → Space state: reads workspace (evidence: `src/components/chat/ChatWindow.tsx`)
- Chat and citations → Document upload: opens upload (evidence: `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 (evidence: `src/components/settings/SettingsDialog.tsx`)
- Model selection → Provider settings state: reads models (evidence: `src/components/chat/ModelSelector.tsx`)
- Provider settings state → Provider routes: loads providers (evidence: `src/components/settings/SettingsContext.tsx`)
- Provider settings state → Model routes: loads models (evidence: `src/components/settings/SettingsContext.tsx`)
- Provider settings state → API key routes: loads keys
- Space state → Browser-local state: persists state (evidence: `src/components/spaces/SpacesContext.tsx`)
- Space state → Space and chat management: deletes spaces (evidence: `src/components/spaces/SpacesContext.tsx`)
- FastAPI application → Chat route: registers routes (evidence: `backend/main.py`)
- FastAPI application → Document routes: registers routes (evidence: `backend/main.py`)
- FastAPI application → Space and chat management: registers routes (evidence: `backend/main.py`)
- FastAPI application → Model routes: registers routes (evidence: `backend/main.py`)
- FastAPI application → API key routes: registers routes (evidence: `backend/main.py`)
- FastAPI application → Provider routes: registers routes (evidence: `backend/main.py`)
- Chat route → Vector retrieval: retrieves context (evidence: `backend/api/routes.py`)
- Chat route → Chat document reader: reads chat files (evidence: `backend/api/routes.py`)
- Chat route → LLM streaming client: streams completion (evidence: `backend/api/routes.py`)
- Document routes → Document ingestion and OCR: ingests documents (evidence: `backend/api/documents.py`)
- Document routes → Chroma vector store: manages vectors (evidence: `backend/api/documents.py`)
- Space and chat management → Chroma vector store: manages vectors (evidence: `backend/api/management.py`)
- Space and chat management → Document ingestion and OCR: uses ingestion (evidence: `backend/api/management.py`)
- Model routes → LLM streaming client: lists models (evidence: `backend/api/models_routes.py`)
- Vector retrieval → Chroma vector store: retrieves vectors (evidence: `backend/rag/query.py`)
- Document ingestion and OCR → Chroma vector store: writes vectors (evidence: `backend/rag/ingest.py`)
- LLM streaming client → LLM providers: calls provider (evidence: `backend/models/llm.py`)
- Chroma vector store → ChromaDB: persists collections (evidence: `backend/rag/store.py`)
