# patildhrup/set2-l2-01-rag-chatbot architecture

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

- Interactive diagram: https://gitdiagram.com/patildhrup/set2-l2-01-rag-chatbot
- Repository: https://github.com/patildhrup/set2-l2-01-rag-chatbot

## Overview

This is a knowledge-base application for uploading documents, managing conversations, and asking questions grounded in stored content. The frontend routes users through authentication, workspace, document, and chat screens; the backend exposes corresponding API areas and has a document-ingestion worker that processes uploaded files into searchable vectors. The sampled code supports the ingestion flow and frontend chat wiring, but not the internal chat API/service calls or retrieval-to-generation orchestration, so those links are omitted. Unsampled features are represented at their existing directory paths.

Main entry points: [`backend/app/services/ingestion/worker.py`](https://github.com/patildhrup/set2-l2-01-rag-chatbot/blob/main/backend/app/services/ingestion/worker.py) (Ingestion worker), [`backend/app/services/ingestion/pipeline.py`](https://github.com/patildhrup/set2-l2-01-rag-chatbot/blob/main/backend/app/services/ingestion/pipeline.py) (Processing pipeline), [`backend/app/services/ingestion/service.py`](https://github.com/patildhrup/set2-l2-01-rag-chatbot/blob/main/backend/app/services/ingestion/service.py) (Upload service), [`backend/app/main.py`](https://github.com/patildhrup/set2-l2-01-rag-chatbot/blob/main/backend/app/main.py) (Application setup)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Web application"]
  node_app["Route application<br/>[App.jsx]"]
  node_chat_ui["Chat screen<br/>[ChatPage.jsx]"]
  node_sessions_hook["Session hook<br/>[useSessions.js]"]
  node_chat_client["Chat client<br/>[chatService.js]"]
  node_http_client["HTTP client<br/>[http.js]"]
  node_auth_state["Auth state<br/>[authStore.js]"]
  node_auth_client["Auth clients"]
  node_document_ui["Document screens<br/>[DocumentsPage.jsx]"]
  node_document_client["Document client<br/>[documentService.js]"]
end

subgraph group_api["API and identity"]
  node_api_router["API router<br/>[router.py]"]
  node_auth_api["Authentication API<br/>[auth.py]"]
  node_feature_apis["Workspace and content APIs"]
  node_auth_core["Auth dependencies"]
end

subgraph group_ingestion["Document ingestion"]
  node_ingest_worker["Ingestion worker<br/>[worker.py]"]
  node_ingest_service["Upload service<br/>[service.py]"]
  node_file_storage["File storage<br/>[storage.py]"]
  node_ingest_pipeline["Processing pipeline<br/>[pipeline.py]"]
  node_extractor["Text extraction<br/>[extraction.py]"]
  node_chunker["Text chunking<br/>[chunking.py]"]
  node_validation["Upload validation<br/>[validation.py]"]
end

subgraph group_knowledge["Knowledge and chat data"]
  node_relational[("Relational models<br/>[models.py]")]
  node_document_repo["Document repository<br/>[documents.py]"]
  node_kb_repo["Knowledge-base repository<br/>[knowledge_bases.py]"]
  node_vector_store[("Vector store<br/>[chroma.py]")]
  node_retrieval["Retrieval service<br/>[retrieval.py]"]
  node_chat_services["Chat and generation"]
end

subgraph group_runtime["Application runtime"]
  node_main["Application setup<br/>[main.py]"]
  node_settings["Configuration<br/>[config.py]"]
end

node_user(("User"))

node_user -->|"uses"| node_app
node_app -->|"routes to"| node_chat_ui
node_chat_ui -->|"uses"| node_sessions_hook
node_chat_ui -->|"calls"| node_chat_client
node_sessions_hook -->|"calls"| node_chat_client
node_chat_client -->|"uses"| node_http_client
node_app -->|"initializes"| node_auth_state
node_auth_state -->|"uses"| node_auth_client
node_app -->|"routes to"| node_document_ui
node_document_ui -.->|"calls"| node_document_client
node_api_router -->|"registers"| node_auth_api
node_api_router -->|"registers"| node_feature_apis
node_auth_api -->|"uses"| node_auth_core
node_main -->|"mounts"| node_api_router
node_main -->|"loads"| node_settings
node_main -->|"configures"| node_ingest_worker
node_main -->|"constructs"| node_ingest_pipeline
node_ingest_worker -->|"runs"| node_ingest_pipeline
node_ingest_worker -->|"reads files"| node_file_storage
node_ingest_worker -->|"updates records"| node_document_repo
node_ingest_worker -->|"loads workspace"| node_kb_repo
node_ingest_service -->|"stores uploads"| node_file_storage
node_ingest_service -->|"validates files"| node_validation
node_ingest_service -->|"records uploads"| node_document_repo
node_ingest_service -->|"checks workspace"| node_kb_repo
node_file_storage -->|"checks extensions"| node_validation
node_ingest_pipeline -->|"extracts text"| node_extractor
node_ingest_pipeline -->|"chunks text"| node_chunker
node_ingest_pipeline -->|"writes vectors"| node_vector_store
node_document_repo -->|"reads and writes"| node_relational
node_kb_repo -->|"reads and writes"| node_relational
node_retrieval -->|"queries"| node_vector_store

click node_app "https://github.com/patildhrup/set2-l2-01-rag-chatbot/blob/main/frontend/src/App.jsx"
click node_chat_ui "https://github.com/patildhrup/set2-l2-01-rag-chatbot/blob/main/frontend/src/pages/ChatPage.jsx"
click node_sessions_hook "https://github.com/patildhrup/set2-l2-01-rag-chatbot/blob/main/frontend/src/hooks/useSessions.js"
click node_chat_client "https://github.com/patildhrup/set2-l2-01-rag-chatbot/blob/main/frontend/src/services/chatService.js"
click node_http_client "https://github.com/patildhrup/set2-l2-01-rag-chatbot/blob/main/frontend/src/services/http.js"
click node_auth_state "https://github.com/patildhrup/set2-l2-01-rag-chatbot/blob/main/frontend/src/store/authStore.js"
click node_auth_client "https://github.com/patildhrup/set2-l2-01-rag-chatbot/tree/main/frontend/src/services"
click node_document_ui "https://github.com/patildhrup/set2-l2-01-rag-chatbot/blob/main/frontend/src/pages/DocumentsPage.jsx"
click node_document_client "https://github.com/patildhrup/set2-l2-01-rag-chatbot/blob/main/frontend/src/services/documentService.js"
click node_api_router "https://github.com/patildhrup/set2-l2-01-rag-chatbot/blob/main/backend/app/api/v1/router.py"
click node_auth_api "https://github.com/patildhrup/set2-l2-01-rag-chatbot/blob/main/backend/app/api/v1/auth.py"
click node_feature_apis "https://github.com/patildhrup/set2-l2-01-rag-chatbot/tree/main/backend/app/api/v1"
click node_auth_core "https://github.com/patildhrup/set2-l2-01-rag-chatbot/tree/main/backend/app/api"
click node_ingest_worker "https://github.com/patildhrup/set2-l2-01-rag-chatbot/blob/main/backend/app/services/ingestion/worker.py"
click node_ingest_service "https://github.com/patildhrup/set2-l2-01-rag-chatbot/blob/main/backend/app/services/ingestion/service.py"
click node_file_storage "https://github.com/patildhrup/set2-l2-01-rag-chatbot/blob/main/backend/app/services/ingestion/storage.py"
click node_ingest_pipeline "https://github.com/patildhrup/set2-l2-01-rag-chatbot/blob/main/backend/app/services/ingestion/pipeline.py"
click node_extractor "https://github.com/patildhrup/set2-l2-01-rag-chatbot/blob/main/backend/app/services/ingestion/extraction.py"
click node_chunker "https://github.com/patildhrup/set2-l2-01-rag-chatbot/blob/main/backend/app/services/ingestion/chunking.py"
click node_validation "https://github.com/patildhrup/set2-l2-01-rag-chatbot/blob/main/backend/app/services/ingestion/validation.py"
click node_relational "https://github.com/patildhrup/set2-l2-01-rag-chatbot/blob/main/backend/app/db/models.py"
click node_document_repo "https://github.com/patildhrup/set2-l2-01-rag-chatbot/blob/main/backend/app/db/repositories/documents.py"
click node_kb_repo "https://github.com/patildhrup/set2-l2-01-rag-chatbot/blob/main/backend/app/db/repositories/knowledge_bases.py"
click node_vector_store "https://github.com/patildhrup/set2-l2-01-rag-chatbot/blob/main/backend/app/vectorstore/chroma.py"
click node_retrieval "https://github.com/patildhrup/set2-l2-01-rag-chatbot/blob/main/backend/app/services/retrieval.py"
click node_chat_services "https://github.com/patildhrup/set2-l2-01-rag-chatbot/tree/main/backend/app/services"
click node_main "https://github.com/patildhrup/set2-l2-01-rag-chatbot/blob/main/backend/app/main.py"
click node_settings "https://github.com/patildhrup/set2-l2-01-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_app,node_chat_ui,node_sessions_hook,node_chat_client,node_http_client,node_auth_state,node_auth_client,node_document_ui,node_document_client,node_user toneBlue
class node_api_router,node_auth_api,node_feature_apis,node_auth_core toneAmber
class node_ingest_worker,node_ingest_service,node_file_storage,node_ingest_pipeline,node_extractor,node_chunker,node_validation toneMint
class node_relational,node_document_repo,node_kb_repo,node_vector_store,node_retrieval,node_chat_services toneRose
class node_main,node_settings toneIndigo
```

## Components

### Web application

- [Route application](https://github.com/patildhrup/set2-l2-01-rag-chatbot/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Chat screen](https://github.com/patildhrup/set2-l2-01-rag-chatbot/blob/main/frontend/src/pages/ChatPage.jsx): `frontend/src/pages/ChatPage.jsx`
- [Session hook](https://github.com/patildhrup/set2-l2-01-rag-chatbot/blob/main/frontend/src/hooks/useSessions.js): `frontend/src/hooks/useSessions.js`
- [Chat client](https://github.com/patildhrup/set2-l2-01-rag-chatbot/blob/main/frontend/src/services/chatService.js): `frontend/src/services/chatService.js`
- [HTTP client](https://github.com/patildhrup/set2-l2-01-rag-chatbot/blob/main/frontend/src/services/http.js): `frontend/src/services/http.js`
- [Auth state](https://github.com/patildhrup/set2-l2-01-rag-chatbot/blob/main/frontend/src/store/authStore.js): `frontend/src/store/authStore.js`
- [Auth clients](https://github.com/patildhrup/set2-l2-01-rag-chatbot/tree/main/frontend/src/services): `frontend/src/services`
- [Document screens](https://github.com/patildhrup/set2-l2-01-rag-chatbot/blob/main/frontend/src/pages/DocumentsPage.jsx): `frontend/src/pages/DocumentsPage.jsx`
- [Document client](https://github.com/patildhrup/set2-l2-01-rag-chatbot/blob/main/frontend/src/services/documentService.js): `frontend/src/services/documentService.js`

### API and identity

- [API router](https://github.com/patildhrup/set2-l2-01-rag-chatbot/blob/main/backend/app/api/v1/router.py): `backend/app/api/v1/router.py`
- [Authentication API](https://github.com/patildhrup/set2-l2-01-rag-chatbot/blob/main/backend/app/api/v1/auth.py): `backend/app/api/v1/auth.py`
- [Workspace and content APIs](https://github.com/patildhrup/set2-l2-01-rag-chatbot/tree/main/backend/app/api/v1): `backend/app/api/v1`
- [Auth dependencies](https://github.com/patildhrup/set2-l2-01-rag-chatbot/tree/main/backend/app/api): `backend/app/api`

### Document ingestion

- [Ingestion worker](https://github.com/patildhrup/set2-l2-01-rag-chatbot/blob/main/backend/app/services/ingestion/worker.py): `backend/app/services/ingestion/worker.py`
- [Upload service](https://github.com/patildhrup/set2-l2-01-rag-chatbot/blob/main/backend/app/services/ingestion/service.py): `backend/app/services/ingestion/service.py`
- [File storage](https://github.com/patildhrup/set2-l2-01-rag-chatbot/blob/main/backend/app/services/ingestion/storage.py): `backend/app/services/ingestion/storage.py`
- [Processing pipeline](https://github.com/patildhrup/set2-l2-01-rag-chatbot/blob/main/backend/app/services/ingestion/pipeline.py): `backend/app/services/ingestion/pipeline.py`
- [Text extraction](https://github.com/patildhrup/set2-l2-01-rag-chatbot/blob/main/backend/app/services/ingestion/extraction.py): `backend/app/services/ingestion/extraction.py`
- [Text chunking](https://github.com/patildhrup/set2-l2-01-rag-chatbot/blob/main/backend/app/services/ingestion/chunking.py): `backend/app/services/ingestion/chunking.py`
- [Upload validation](https://github.com/patildhrup/set2-l2-01-rag-chatbot/blob/main/backend/app/services/ingestion/validation.py): `backend/app/services/ingestion/validation.py`

### Knowledge and chat data

- [Relational models](https://github.com/patildhrup/set2-l2-01-rag-chatbot/blob/main/backend/app/db/models.py): `backend/app/db/models.py`
- [Document repository](https://github.com/patildhrup/set2-l2-01-rag-chatbot/blob/main/backend/app/db/repositories/documents.py): `backend/app/db/repositories/documents.py`
- [Knowledge-base repository](https://github.com/patildhrup/set2-l2-01-rag-chatbot/blob/main/backend/app/db/repositories/knowledge_bases.py): `backend/app/db/repositories/knowledge_bases.py`
- [Vector store](https://github.com/patildhrup/set2-l2-01-rag-chatbot/blob/main/backend/app/vectorstore/chroma.py): `backend/app/vectorstore/chroma.py`
- [Retrieval service](https://github.com/patildhrup/set2-l2-01-rag-chatbot/blob/main/backend/app/services/retrieval.py): `backend/app/services/retrieval.py`
- [Chat and generation](https://github.com/patildhrup/set2-l2-01-rag-chatbot/tree/main/backend/app/services): `backend/app/services`

### Application runtime

- [Application setup](https://github.com/patildhrup/set2-l2-01-rag-chatbot/blob/main/backend/app/main.py): `backend/app/main.py`
- [Configuration](https://github.com/patildhrup/set2-l2-01-rag-chatbot/blob/main/backend/app/core/config.py): `backend/app/core/config.py`

### Other components

- **User**

## Connections

- User → Route application: uses (evidence: `frontend/src/App.jsx`)
- Route application → Chat screen: routes to (evidence: `frontend/src/App.jsx`)
- Chat screen → Session hook: uses (evidence: `frontend/src/pages/ChatPage.jsx`)
- Chat screen → Chat client: calls (evidence: `frontend/src/pages/ChatPage.jsx`)
- Session hook → Chat client: calls (evidence: `frontend/src/hooks/useSessions.js`)
- Chat client → HTTP client: uses (evidence: `frontend/src/services/chatService.js`)
- Route application → Auth state: initializes (evidence: `frontend/src/App.jsx`)
- Auth state → Auth clients: uses (evidence: `frontend/src/store/authStore.js`)
- Route application → Document screens: routes to (evidence: `frontend/src/App.jsx`)
- Document screens → Document client: calls
- API router → Authentication API: registers (evidence: `backend/app/api/v1/router.py`)
- API router → Workspace and content APIs: registers (evidence: `backend/app/api/v1/router.py`)
- Authentication API → Auth dependencies: uses (evidence: `backend/app/api/v1/auth.py`)
- Application setup → API router: mounts (evidence: `backend/app/main.py`)
- Application setup → Configuration: loads (evidence: `backend/app/main.py`)
- Application setup → Ingestion worker: configures (evidence: `backend/app/main.py`)
- Application setup → Processing pipeline: constructs (evidence: `backend/app/main.py`)
- Ingestion worker → Processing pipeline: runs (evidence: `backend/app/services/ingestion/worker.py`)
- Ingestion worker → File storage: reads files (evidence: `backend/app/services/ingestion/worker.py`)
- Ingestion worker → Document repository: updates records (evidence: `backend/app/services/ingestion/worker.py`)
- Ingestion worker → Knowledge-base repository: loads workspace (evidence: `backend/app/services/ingestion/worker.py`)
- Upload service → File storage: stores uploads (evidence: `backend/app/services/ingestion/service.py`)
- Upload service → Upload validation: validates files (evidence: `backend/app/services/ingestion/service.py`)
- Upload service → Document repository: records uploads (evidence: `backend/app/services/ingestion/service.py`)
- Upload service → Knowledge-base repository: checks workspace (evidence: `backend/app/services/ingestion/service.py`)
- File storage → Upload validation: checks extensions (evidence: `backend/app/services/ingestion/storage.py`)
- Processing pipeline → Text extraction: extracts text (evidence: `backend/app/services/ingestion/pipeline.py`)
- Processing pipeline → Text chunking: chunks text (evidence: `backend/app/services/ingestion/pipeline.py`)
- Processing pipeline → Vector store: writes vectors (evidence: `backend/app/services/ingestion/pipeline.py`)
- Document repository → Relational models: reads and writes (evidence: `backend/app/db/repositories/documents.py`)
- Knowledge-base repository → Relational models: reads and writes (evidence: `backend/app/db/repositories/knowledge_bases.py`)
- Retrieval service → Vector store: queries (evidence: `backend/app/services/retrieval.py`)
