# mukesh360/rag-bot- architecture

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

- Interactive diagram: https://gitdiagram.com/mukesh360/rag-bot-
- Repository: https://github.com/mukesh360/rag-bot-

## Overview

DocIntel AI is a document Q&A platform with global and agent-specific knowledge spaces. Users authenticate, upload documents for indexing, then query the global RAG system or a selected agent; results include answers and sources, with chat history persisted. The graph also shows agent management, authentication, document/history storage, and the frontend. Edges follow the excerpts, SOURCE INDEX references, or README; unsampled wiring and internals are omitted where evidence is limited.

Main entry points: [`backend/main.py`](https://github.com/mukesh360/rag-bot-/blob/main/backend/main.py) (FastAPI app), [`backend/auth/supabase_client.py`](https://github.com/mukesh360/rag-bot-/blob/main/backend/auth/supabase_client.py) (Supabase client), [`backend/agents/routes.py`](https://github.com/mukesh360/rag-bot-/blob/main/backend/agents/routes.py) (Agent routes), [`backend/rag_core.py`](https://github.com/mukesh360/rag-bot-/blob/main/backend/rag_core.py) (Global RAG)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["User interface"]
  node_frontend["Web interface<br/>[index.html]"]
  node_frontend_js["Chat and voice<br/>[app.js]"]
end

subgraph group_api["API and identity"]
  node_api_app["FastAPI app<br/>[main.py]"]
  node_auth_routes["Auth routes<br/>[routes.py]"]
  node_auth_guard["JWT validation<br/>[dependencies.py]"]
  node_supabase_client["Supabase client<br/>[supabase_client.py]"]
  node_agent_routes["Agent routes<br/>[routes.py]"]
  node_agent_service["Agent management<br/>[service.py]"]
  node_schemas["API schemas<br/>[schemas.py]"]
end

subgraph group_knowledge["Knowledge and retrieval"]
  node_doc_loader["Agent indexing<br/>[document_loader.py]"]
  node_rag_core["Global RAG<br/>[rag_core.py]"]
  node_chroma[("Vector collections")]
  node_base_docs["Global documents"]
end

subgraph group_persistence["Persistence"]
  node_supabase_db[("Supabase database")]
  node_storage["Chat and document storage<br/>[storage.py]"]
  node_offline_learning["FAQ learning"]
end

node_user(("User"))
node_ollama["Ollama LLM"]
node_supabase_auth["Supabase auth"]

node_user -->|"uses"| node_frontend
node_frontend -->|"loads"| node_frontend_js
node_frontend_js -->|"requests API"| node_api_app
node_api_app -->|"mounts routes"| node_auth_routes
node_api_app -->|"mounts routes"| node_agent_routes
node_api_app -->|"protects endpoints"| node_auth_guard
node_auth_routes -->|"authenticates"| node_supabase_client
node_auth_guard -->|"validates token"| node_supabase_client
node_agent_routes -->|"checks user"| node_auth_guard
node_agent_routes -->|"manages agents"| node_agent_service
node_agent_service -->|"uses admin client"| node_supabase_client
node_agent_routes -->|"indexes and queries"| node_doc_loader
node_doc_loader -->|"stores and searches"| node_chroma
node_api_app -->|"queries and configures"| node_rag_core
node_rag_core -->|"indexes at startup"| node_base_docs
node_rag_core -->|"retrieves context"| node_chroma
node_rag_core -->|"generates answers"| node_ollama
node_api_app -->|"reads and writes history"| node_storage
node_storage -->|"uses admin client"| node_supabase_client
node_storage -->|"persists records"| node_supabase_db
node_agent_service -->|"stores agent metadata"| node_supabase_db
node_offline_learning -->|"reads chats, writes FAQs"| node_supabase_db
node_auth_routes -->|"uses models"| node_schemas
node_agent_routes -->|"uses models"| node_schemas
node_api_app -->|"uses models"| node_schemas
node_supabase_client -->|"creates auth client"| node_supabase_auth
node_supabase_client -->|"creates admin client"| node_supabase_db

click node_frontend "https://github.com/mukesh360/rag-bot-/blob/main/frontend/templates/index.html"
click node_frontend_js "https://github.com/mukesh360/rag-bot-/blob/main/frontend/static/js/app.js"
click node_api_app "https://github.com/mukesh360/rag-bot-/blob/main/backend/main.py"
click node_auth_routes "https://github.com/mukesh360/rag-bot-/blob/main/backend/auth/routes.py"
click node_auth_guard "https://github.com/mukesh360/rag-bot-/blob/main/backend/auth/dependencies.py"
click node_supabase_client "https://github.com/mukesh360/rag-bot-/blob/main/backend/auth/supabase_client.py"
click node_agent_routes "https://github.com/mukesh360/rag-bot-/blob/main/backend/agents/routes.py"
click node_agent_service "https://github.com/mukesh360/rag-bot-/blob/main/backend/agents/service.py"
click node_schemas "https://github.com/mukesh360/rag-bot-/blob/main/backend/schemas.py"
click node_doc_loader "https://github.com/mukesh360/rag-bot-/blob/main/backend/rag/document_loader.py"
click node_rag_core "https://github.com/mukesh360/rag-bot-/blob/main/backend/rag_core.py"
click node_chroma "https://github.com/mukesh360/rag-bot-/tree/main/chroma_agents"
click node_base_docs "https://github.com/mukesh360/rag-bot-/tree/main/base_documents"
click node_storage "https://github.com/mukesh360/rag-bot-/blob/main/backend/storage.py"
click node_offline_learning "https://github.com/mukesh360/rag-bot-/blob/main/backend/offline_learning.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_frontend,node_frontend_js,node_user toneBlue
class node_api_app,node_auth_routes,node_auth_guard,node_supabase_client,node_agent_routes,node_agent_service,node_schemas toneAmber
class node_doc_loader,node_rag_core,node_chroma,node_base_docs toneMint
class node_supabase_db,node_storage,node_offline_learning toneRose
class node_ollama,node_supabase_auth toneIndigo
```

## Components

### User interface

- [Web interface](https://github.com/mukesh360/rag-bot-/blob/main/frontend/templates/index.html): `frontend/templates/index.html`
- [Chat and voice](https://github.com/mukesh360/rag-bot-/blob/main/frontend/static/js/app.js): `frontend/static/js/app.js`

### API and identity

- [FastAPI app](https://github.com/mukesh360/rag-bot-/blob/main/backend/main.py): `backend/main.py`
- [Auth routes](https://github.com/mukesh360/rag-bot-/blob/main/backend/auth/routes.py): `backend/auth/routes.py`
- [JWT validation](https://github.com/mukesh360/rag-bot-/blob/main/backend/auth/dependencies.py): `backend/auth/dependencies.py`
- [Supabase client](https://github.com/mukesh360/rag-bot-/blob/main/backend/auth/supabase_client.py): `backend/auth/supabase_client.py`
- [Agent routes](https://github.com/mukesh360/rag-bot-/blob/main/backend/agents/routes.py): `backend/agents/routes.py`
- [Agent management](https://github.com/mukesh360/rag-bot-/blob/main/backend/agents/service.py): `backend/agents/service.py`
- [API schemas](https://github.com/mukesh360/rag-bot-/blob/main/backend/schemas.py): `backend/schemas.py`

### Knowledge and retrieval

- [Agent indexing](https://github.com/mukesh360/rag-bot-/blob/main/backend/rag/document_loader.py): `backend/rag/document_loader.py`
- [Global RAG](https://github.com/mukesh360/rag-bot-/blob/main/backend/rag_core.py): `backend/rag_core.py`
- [Vector collections](https://github.com/mukesh360/rag-bot-/tree/main/chroma_agents): `chroma_agents`
- [Global documents](https://github.com/mukesh360/rag-bot-/tree/main/base_documents): `base_documents`

### Persistence

- **Supabase database**
- [Chat and document storage](https://github.com/mukesh360/rag-bot-/blob/main/backend/storage.py): `backend/storage.py`
- [FAQ learning](https://github.com/mukesh360/rag-bot-/blob/main/backend/offline_learning.py): `backend/offline_learning.py`

### Other components

- **User**
- **Ollama LLM**
- **Supabase auth**

## Connections

- User → Web interface: uses (evidence: `README.md`)
- Web interface → Chat and voice: loads (evidence: `README.md`)
- Chat and voice → FastAPI app: requests API (evidence: `README.md`)
- FastAPI app → Auth routes: mounts routes (evidence: `backend/main.py`)
- FastAPI app → Agent routes: mounts routes (evidence: `backend/main.py`)
- FastAPI app → JWT validation: protects endpoints (evidence: `backend/main.py`)
- Auth routes → Supabase client: authenticates (evidence: `backend/auth/routes.py`)
- JWT validation → Supabase client: validates token (evidence: `backend/auth/dependencies.py`)
- Agent routes → JWT validation: checks user (evidence: `backend/agents/routes.py`)
- Agent routes → Agent management: manages agents (evidence: `backend/agents/routes.py`)
- Agent management → Supabase client: uses admin client (evidence: `backend/agents/service.py`)
- Agent routes → Agent indexing: indexes and queries (evidence: `backend/agents/routes.py`)
- Agent indexing → Vector collections: stores and searches (evidence: `README.md`)
- FastAPI app → Global RAG: queries and configures (evidence: `backend/main.py`)
- Global RAG → Global documents: indexes at startup (evidence: `README.md`)
- Global RAG → Vector collections: retrieves context (evidence: `README.md`)
- Global RAG → Ollama LLM: generates answers (evidence: `README.md`)
- FastAPI app → Chat and document storage: reads and writes history (evidence: `backend/main.py`)
- Chat and document storage → Supabase client: uses admin client (evidence: `backend/storage.py`)
- Chat and document storage → Supabase database: persists records (evidence: `backend/storage.py`)
- Agent management → Supabase database: stores agent metadata (evidence: `backend/agents/service.py`)
- FAQ learning → Supabase database: reads chats, writes FAQs (evidence: `backend/offline_learning.py`)
- Auth routes → API schemas: uses models (evidence: `backend/auth/routes.py`)
- Agent routes → API schemas: uses models (evidence: `backend/agents/routes.py`)
- FastAPI app → API schemas: uses models (evidence: `backend/main.py`)
- Supabase client → Supabase auth: creates auth client (evidence: `backend/auth/supabase_client.py`)
- Supabase client → Supabase database: creates admin client (evidence: `backend/auth/supabase_client.py`)
