# rohith-2504/rag-chatbot architecture

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

- Interactive diagram: https://gitdiagram.com/rohith-2504/rag-chatbot
- Repository: https://github.com/rohith-2504/rag-chatbot

## Overview

RAG ChatBot is a browser-based assistant for account access, multi-session conversations, chat history, document uploads and retrieval-augmented answers, with optional web search and generated media. The main workflow is React UI → FastAPI chat/upload endpoints → routing, retrieval and model/tool services → persisted history or indexed documents. The graph retains documented capabilities whose internals were not sampled; edges are limited to relationships visible in excerpts, the SOURCE INDEX, or README. Several service implementations were not excerpted, so their internal call paths are omitted.

Main entry points: [`backend/app/services/media_service.py`](https://github.com/rohith-2504/rag-chatbot/blob/main/backend/app/services/media_service.py) (Media processing), [`backend/app/api/chat.py`](https://github.com/rohith-2504/rag-chatbot/blob/main/backend/app/api/chat.py) (Chat and upload API), [`frontend/src/App.jsx`](https://github.com/rohith-2504/rag-chatbot/blob/main/frontend/src/App.jsx) (API requests), [`backend/app/services/router_service.py`](https://github.com/rohith-2504/rag-chatbot/blob/main/backend/app/services/router_service.py) (Request routing)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Chat interface"]
  node_ui["Chat and sessions UI<br/>[App.jsx]"]
  node_api_client["API requests<br/>[App.jsx]"]
end

subgraph group_api["HTTP API"]
  node_app_entry["FastAPI app<br/>[main.py]"]
  node_chat_api["Chat and upload API<br/>[chat.py]"]
  node_sessions_api["Session API<br/>[sessions.py]"]
  node_messages_api["Message API<br/>[messages.py]"]
  node_auth_api["Authentication API<br/>[auth.py]"]
end

subgraph group_conversation["Conversation services"]
  node_router["Request routing<br/>[router_service.py]"]
  node_llm["LLM and tool dispatch<br/>[llm_service.py]"]
  node_tools["Assistant tools<br/>[tool_service.py]"]
  node_websearch["Web search"]
  node_sessions["Session management<br/>[session_service.py]"]
  node_messages["Message history<br/>[message_service.py]"]
  node_memory["Conversation memory<br/>[memory_service.py]"]
  node_auth["Authentication service<br/>[auth_service.py]"]
end

subgraph group_knowledge["Knowledge and media"]
  node_rag["RAG ingestion and retrieval<br/>[rag_service.py]"]
  node_media["Media processing<br/>[media_service.py]"]
  node_documents["Document extraction"]
  node_audio["Audio processing<br/>[audio_service.py]"]
  node_image["Image processing<br/>[image_service.py]"]
  node_video["Video processing<br/>[video_service.py]"]
  node_pdf["PDF processing<br/>[pdf_service.py]"]
  node_loader["Document loading<br/>[document_loader.py]"]
  node_vector[("Vector search<br/>[vector_store.py]")]
  node_generation["Media generation"]
end

subgraph group_storage["Persistence and integrations"]
  node_sqlite[("SQLite access<br/>[database.py]")]
  node_config["Runtime configuration<br/>[config.py]"]
  node_chroma[("ChromaDB")]
end

node_user(("Chat user"))
node_model_provider["OpenAI-compatible model"]
node_tavily["Tavily search"]

node_user -->|"uses"| node_ui
node_ui -->|"sends requests"| node_api_client
node_api_client -.->|"calls chat and upload"| node_chat_api
node_api_client -.->|"manages sessions"| node_sessions_api
node_api_client -.->|"loads history"| node_messages_api
node_api_client -.->|"authenticates"| node_auth_api
node_app_entry -->|"registers"| node_chat_api
node_app_entry -->|"registers"| node_sessions_api
node_app_entry -->|"registers"| node_messages_api
node_app_entry -->|"registers"| node_auth_api
node_chat_api -->|"routes chat"| node_router
node_chat_api -->|"creates sessions"| node_sessions
node_chat_api -->|"stores chat"| node_messages
node_chat_api -.->|"indexes uploads"| node_rag
node_router -->|"retrieves context"| node_rag
node_router -->|"requests response"| node_llm
node_router -->|"searches web"| node_websearch
node_router -->|"uses history"| node_messages
node_rag -->|"processes files"| node_media
node_rag -->|"adds and searches"| node_vector
node_media -->|"dispatches formats"| node_documents
node_media -->|"dispatches formats"| node_audio
node_media -->|"dispatches formats"| node_image
node_media -->|"dispatches formats"| node_video
node_media -->|"dispatches formats"| node_pdf
node_llm -->|"completes prompts"| node_model_provider
node_llm -->|"dispatches tool calls"| node_tools
node_tools -->|"delegates search"| node_websearch
node_tools -->|"generates video"| node_generation
node_websearch -->|"queries"| node_tavily
node_sessions_api -->|"handles session actions"| node_sessions
node_messages_api -->|"handles history actions"| node_messages
node_auth_api -->|"delegates authentication"| node_auth
node_sessions -->|"reads and writes"| node_sqlite
node_messages -->|"reads and writes"| node_sqlite
node_auth -->|"uses database"| node_sqlite
node_vector -.->|"stores embeddings"| node_chroma
node_config -->|"configures location"| node_sqlite
node_config -->|"configures provider"| node_llm
node_config -->|"configures key"| node_websearch
node_config -.->|"configures storage"| node_vector

click node_ui "https://github.com/rohith-2504/rag-chatbot/blob/main/frontend/src/App.jsx"
click node_api_client "https://github.com/rohith-2504/rag-chatbot/blob/main/frontend/src/App.jsx"
click node_app_entry "https://github.com/rohith-2504/rag-chatbot/blob/main/backend/app/main.py"
click node_chat_api "https://github.com/rohith-2504/rag-chatbot/blob/main/backend/app/api/chat.py"
click node_sessions_api "https://github.com/rohith-2504/rag-chatbot/blob/main/backend/app/api/sessions.py"
click node_messages_api "https://github.com/rohith-2504/rag-chatbot/blob/main/backend/app/api/messages.py"
click node_auth_api "https://github.com/rohith-2504/rag-chatbot/blob/main/backend/app/api/auth.py"
click node_router "https://github.com/rohith-2504/rag-chatbot/blob/main/backend/app/services/router_service.py"
click node_rag "https://github.com/rohith-2504/rag-chatbot/blob/main/backend/app/services/rag_service.py"
click node_media "https://github.com/rohith-2504/rag-chatbot/blob/main/backend/app/services/media_service.py"
click node_documents "https://github.com/rohith-2504/rag-chatbot/blob/main/backend/app/services/document_service.py"
click node_audio "https://github.com/rohith-2504/rag-chatbot/blob/main/backend/app/services/audio_service.py"
click node_image "https://github.com/rohith-2504/rag-chatbot/blob/main/backend/app/services/image_service.py"
click node_video "https://github.com/rohith-2504/rag-chatbot/blob/main/backend/app/services/video_service.py"
click node_pdf "https://github.com/rohith-2504/rag-chatbot/blob/main/backend/app/services/pdf_service.py"
click node_loader "https://github.com/rohith-2504/rag-chatbot/blob/main/backend/app/services/document_loader.py"
click node_vector "https://github.com/rohith-2504/rag-chatbot/blob/main/backend/app/services/vector_store.py"
click node_llm "https://github.com/rohith-2504/rag-chatbot/blob/main/backend/app/services/llm_service.py"
click node_tools "https://github.com/rohith-2504/rag-chatbot/blob/main/backend/app/services/tool_service.py"
click node_generation "https://github.com/rohith-2504/rag-chatbot/blob/main/backend/app/services/generation_service.py"
click node_websearch "https://github.com/rohith-2504/rag-chatbot/blob/main/backend/app/services/web_search_service.py"
click node_sessions "https://github.com/rohith-2504/rag-chatbot/blob/main/backend/app/services/session_service.py"
click node_messages "https://github.com/rohith-2504/rag-chatbot/blob/main/backend/app/services/message_service.py"
click node_memory "https://github.com/rohith-2504/rag-chatbot/blob/main/backend/app/services/memory_service.py"
click node_auth "https://github.com/rohith-2504/rag-chatbot/blob/main/backend/app/services/auth_service.py"
click node_sqlite "https://github.com/rohith-2504/rag-chatbot/blob/main/backend/app/services/database.py"
click node_config "https://github.com/rohith-2504/rag-chatbot/blob/main/backend/app/core/config.py"

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_ui,node_api_client,node_user toneBlue
class node_app_entry,node_chat_api,node_sessions_api,node_messages_api,node_auth_api toneAmber
class node_router,node_llm,node_tools,node_websearch,node_sessions,node_messages,node_memory,node_auth toneMint
class node_rag,node_media,node_documents,node_audio,node_image,node_video,node_pdf,node_loader,node_vector,node_generation toneRose
class node_sqlite,node_config,node_chroma,node_model_provider,node_tavily toneIndigo
```

## Components

### Chat interface

- [Chat and sessions UI](https://github.com/rohith-2504/rag-chatbot/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [API requests](https://github.com/rohith-2504/rag-chatbot/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`

### HTTP API

- [FastAPI app](https://github.com/rohith-2504/rag-chatbot/blob/main/backend/app/main.py): `backend/app/main.py`
- [Chat and upload API](https://github.com/rohith-2504/rag-chatbot/blob/main/backend/app/api/chat.py): `backend/app/api/chat.py`
- [Session API](https://github.com/rohith-2504/rag-chatbot/blob/main/backend/app/api/sessions.py): `backend/app/api/sessions.py`
- [Message API](https://github.com/rohith-2504/rag-chatbot/blob/main/backend/app/api/messages.py): `backend/app/api/messages.py`
- [Authentication API](https://github.com/rohith-2504/rag-chatbot/blob/main/backend/app/api/auth.py): `backend/app/api/auth.py`

### Conversation services

- [Request routing](https://github.com/rohith-2504/rag-chatbot/blob/main/backend/app/services/router_service.py): `backend/app/services/router_service.py`
- [LLM and tool dispatch](https://github.com/rohith-2504/rag-chatbot/blob/main/backend/app/services/llm_service.py): `backend/app/services/llm_service.py`
- [Assistant tools](https://github.com/rohith-2504/rag-chatbot/blob/main/backend/app/services/tool_service.py): `backend/app/services/tool_service.py`
- [Web search](https://github.com/rohith-2504/rag-chatbot/blob/main/backend/app/services/web_search_service.py): `backend/app/services/web_search_service.py`
- [Session management](https://github.com/rohith-2504/rag-chatbot/blob/main/backend/app/services/session_service.py): `backend/app/services/session_service.py`
- [Message history](https://github.com/rohith-2504/rag-chatbot/blob/main/backend/app/services/message_service.py): `backend/app/services/message_service.py`
- [Conversation memory](https://github.com/rohith-2504/rag-chatbot/blob/main/backend/app/services/memory_service.py): `backend/app/services/memory_service.py`
- [Authentication service](https://github.com/rohith-2504/rag-chatbot/blob/main/backend/app/services/auth_service.py): `backend/app/services/auth_service.py`

### Knowledge and media

- [RAG ingestion and retrieval](https://github.com/rohith-2504/rag-chatbot/blob/main/backend/app/services/rag_service.py): `backend/app/services/rag_service.py`
- [Media processing](https://github.com/rohith-2504/rag-chatbot/blob/main/backend/app/services/media_service.py): `backend/app/services/media_service.py`
- [Document extraction](https://github.com/rohith-2504/rag-chatbot/blob/main/backend/app/services/document_service.py): `backend/app/services/document_service.py`
- [Audio processing](https://github.com/rohith-2504/rag-chatbot/blob/main/backend/app/services/audio_service.py): `backend/app/services/audio_service.py`
- [Image processing](https://github.com/rohith-2504/rag-chatbot/blob/main/backend/app/services/image_service.py): `backend/app/services/image_service.py`
- [Video processing](https://github.com/rohith-2504/rag-chatbot/blob/main/backend/app/services/video_service.py): `backend/app/services/video_service.py`
- [PDF processing](https://github.com/rohith-2504/rag-chatbot/blob/main/backend/app/services/pdf_service.py): `backend/app/services/pdf_service.py`
- [Document loading](https://github.com/rohith-2504/rag-chatbot/blob/main/backend/app/services/document_loader.py): `backend/app/services/document_loader.py`
- [Vector search](https://github.com/rohith-2504/rag-chatbot/blob/main/backend/app/services/vector_store.py): `backend/app/services/vector_store.py`
- [Media generation](https://github.com/rohith-2504/rag-chatbot/blob/main/backend/app/services/generation_service.py): `backend/app/services/generation_service.py`

### Persistence and integrations

- [SQLite access](https://github.com/rohith-2504/rag-chatbot/blob/main/backend/app/services/database.py): `backend/app/services/database.py`
- [Runtime configuration](https://github.com/rohith-2504/rag-chatbot/blob/main/backend/app/core/config.py): `backend/app/core/config.py`
- **ChromaDB**

### Other components

- **Chat user**
- **OpenAI-compatible model**
- **Tavily search**

## Connections

- Chat user → Chat and sessions UI: uses (evidence: `README.md`)
- Chat and sessions UI → API requests: sends requests (evidence: `frontend/src/App.jsx`)
- API requests → Chat and upload API: calls chat and upload
- API requests → Session API: manages sessions
- API requests → Message API: loads history
- API requests → Authentication API: authenticates
- FastAPI app → Chat and upload API: registers (evidence: `backend/app/main.py`)
- FastAPI app → Session API: registers (evidence: `backend/app/main.py`)
- FastAPI app → Message API: registers (evidence: `backend/app/main.py`)
- FastAPI app → Authentication API: registers (evidence: `backend/app/main.py`)
- Chat and upload API → Request routing: routes chat (evidence: `backend/app/api/chat.py`)
- Chat and upload API → Session management: creates sessions (evidence: `backend/app/api/chat.py`)
- Chat and upload API → Message history: stores chat (evidence: `backend/app/api/chat.py`)
- Chat and upload API → RAG ingestion and retrieval: indexes uploads (evidence: `backend/app/api/chat.py`)
- Request routing → RAG ingestion and retrieval: retrieves context (evidence: `backend/app/services/router_service.py`)
- Request routing → LLM and tool dispatch: requests response (evidence: `backend/app/services/router_service.py`)
- Request routing → Web search: searches web (evidence: `backend/app/services/router_service.py`)
- Request routing → Message history: uses history (evidence: `backend/app/services/router_service.py`)
- RAG ingestion and retrieval → Media processing: processes files (evidence: `backend/app/services/rag_service.py`)
- RAG ingestion and retrieval → Vector search: adds and searches (evidence: `backend/app/services/rag_service.py`)
- Media processing → Document extraction: dispatches formats (evidence: `backend/app/services/media_service.py`)
- Media processing → Audio processing: dispatches formats (evidence: `backend/app/services/media_service.py`)
- Media processing → Image processing: dispatches formats (evidence: `backend/app/services/media_service.py`)
- Media processing → Video processing: dispatches formats (evidence: `backend/app/services/media_service.py`)
- Media processing → PDF processing: dispatches formats (evidence: `backend/app/services/media_service.py`)
- LLM and tool dispatch → OpenAI-compatible model: completes prompts (evidence: `backend/app/services/llm_service.py`)
- LLM and tool dispatch → Assistant tools: dispatches tool calls (evidence: `backend/app/services/llm_service.py`)
- Assistant tools → Web search: delegates search (evidence: `backend/app/services/tool_service.py`)
- Assistant tools → Media generation: generates video (evidence: `backend/app/services/tool_service.py`)
- Web search → Tavily search: queries (evidence: `backend/app/services/web_search_service.py`)
- Session API → Session management: handles session actions (evidence: `backend/app/api/sessions.py`)
- Message API → Message history: handles history actions (evidence: `backend/app/api/messages.py`)
- Authentication API → Authentication service: delegates authentication (evidence: `backend/app/api/auth.py`)
- Session management → SQLite access: reads and writes (evidence: `backend/app/services/session_service.py`)
- Message history → SQLite access: reads and writes (evidence: `backend/app/services/message_service.py`)
- Authentication service → SQLite access: uses database (evidence: `backend/app/services/auth_service.py`)
- Vector search → ChromaDB: stores embeddings
- Runtime configuration → SQLite access: configures location (evidence: `backend/app/services/database.py`)
- Runtime configuration → LLM and tool dispatch: configures provider (evidence: `backend/app/services/llm_service.py`)
- Runtime configuration → Web search: configures key (evidence: `backend/app/services/web_search_service.py`)
- Runtime configuration → Vector search: configures storage (evidence: `backend/app/services/vector_store.py`)
