# atharvpatil322/qna-rag-application architecture

> Architecture diagram of the GitHub repository atharvpatil322/qna-rag-application, 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/atharvpatil322/qna-rag-application
- Repository: https://github.com/atharvpatil322/qna-rag-application

## Overview

This is a multi-user document Q&A product: users authenticate, upload PDFs, and ask contextual questions; admins can inspect and rebuild the vector index. The frontend provides chat, document, account, and settings surfaces, while the FastAPI backend coordinates processing, retrieval, persistence, and inference. Document upload has an explicitly streamed progress path, and chat passes through a controller to its service. The README documents the broader RAG, storage, and recovery capabilities; unsampled implementation links are shown only when supported by that documentation.

Main entry points: [`frontend/src/App.tsx`](https://github.com/atharvpatil322/qna-rag-application/blob/main/frontend/src/App.tsx) (Web application), [`server/app/services/document_service.py`](https://github.com/atharvpatil322/qna-rag-application/blob/main/server/app/services/document_service.py) (Document service), [`server/main.py`](https://github.com/atharvpatil322/qna-rag-application/blob/main/server/main.py) (FastAPI application), [`server/app/routes/upload_routes.py`](https://github.com/atharvpatil322/qna-rag-application/blob/main/server/app/routes/upload_routes.py) (Upload routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web client"]
  node_webapp["Web application<br/>[App.tsx]"]
  node_authui["Authentication screens"]
  node_chatscreen["Chat experience<br/>[ChatInterface.tsx]"]
  node_docsui["Document screens"]
  node_accountui["Account and settings"]
  node_apiclient["API client<br/>[api.ts]"]
end

subgraph group_api["API and workflows"]
  node_apiapp["FastAPI application<br/>[main.py]"]
  node_authroutes["Auth routes<br/>[auth_routes.py]"]
  node_authcontroller["Auth controller<br/>[auth_controller.py]"]
  node_uploadroutes["Upload routes<br/>[upload_routes.py]"]
  node_uploadcontroller["Upload controller"]
  node_chatroutes["Chat routes<br/>[chat_routes.py]"]
  node_chatcontroller["Chat controller<br/>[chat_controller.py]"]
  node_usersvc["User service<br/>[user_service.py]"]
end

subgraph group_rag["Document and RAG"]
  node_docsvc["Document service"]
  node_processor["PDF processing"]
  node_chatsvc["Chat service<br/>[chat_service.py]"]
  node_llm["LLM providers<br/>[providers.py]"]
  node_vectors[("Vector search")]
end

subgraph group_state["Persistence and identity"]
  node_postgres[("PostgreSQL<br/>[postgres.py]")]
  node_mongo[("MongoDB<br/>[mongodb.py]")]
  node_authsvc["Authentication service<br/>[auth_service.py]"]
  node_authutils["JWT and passwords<br/>[auth.py]"]
end

subgraph group_ops["Administration"]
  node_rebuild["Vector recovery"]
  node_admincontroller["Admin vector controller"]
  node_sse["Progress events<br/>[sse.py]"]
end

node_user(("User"))
node_admin(("Administrator"))

node_user -->|"uses"| node_webapp
node_admin -->|"manages"| node_webapp
node_webapp -->|"routes"| node_authui
node_webapp -.->|"routes"| node_chatscreen
node_webapp -.->|"routes"| node_docsui
node_webapp -.->|"routes"| node_accountui
node_webapp -.->|"calls"| node_apiclient
node_apiclient -.->|"sends requests"| node_apiapp
node_apiapp -->|"registers routes"| node_authroutes
node_apiapp -->|"registers routes"| node_uploadroutes
node_apiapp -->|"registers routes"| node_chatroutes
node_authroutes -.->|"dispatches"| node_authcontroller
node_authcontroller -->|"delegates"| node_authsvc
node_authsvc -->|"reads and writes"| node_postgres
node_authsvc -->|"uses"| node_authutils
node_authcontroller -.->|"delegates"| node_usersvc
node_uploadroutes -->|"processes upload"| node_docsvc
node_uploadroutes -->|"dispatches"| node_uploadcontroller
node_uploadroutes -->|"streams events"| node_sse
node_docsvc -->|"extracts and chunks"| node_processor
node_docsvc -->|"stores embeddings"| node_vectors
node_docsvc -->|"stores documents"| node_mongo
node_docsvc -->|"stores metadata"| node_postgres
node_chatroutes -.->|"dispatches"| node_chatcontroller
node_chatcontroller -->|"processes chat"| node_chatsvc
node_chatcontroller -->|"gets vector store"| node_vectors
node_chatsvc -.->|"retrieves context"| node_vectors
node_chatsvc -.->|"generates answers"| node_llm
node_chatsvc -.->|"stores conversations"| node_mongo
node_admincontroller -->|"rebuilds vectors"| node_rebuild
node_rebuild -->|"reads backup"| node_mongo
node_rebuild -->|"restores index"| node_vectors
node_admincontroller -->|"emits progress"| node_sse

click node_webapp "https://github.com/atharvpatil322/qna-rag-application/blob/main/frontend/src/App.tsx"
click node_authui "https://github.com/atharvpatil322/qna-rag-application/tree/main/frontend/src/pages/auth"
click node_chatscreen "https://github.com/atharvpatil322/qna-rag-application/blob/main/frontend/src/components/chat/ChatInterface.tsx"
click node_docsui "https://github.com/atharvpatil322/qna-rag-application/tree/main/frontend/src/components/documents"
click node_accountui "https://github.com/atharvpatil322/qna-rag-application/tree/main/frontend/src/pages"
click node_apiclient "https://github.com/atharvpatil322/qna-rag-application/blob/main/frontend/src/lib/api.ts"
click node_apiapp "https://github.com/atharvpatil322/qna-rag-application/blob/main/server/main.py"
click node_authroutes "https://github.com/atharvpatil322/qna-rag-application/blob/main/server/app/routes/auth_routes.py"
click node_authcontroller "https://github.com/atharvpatil322/qna-rag-application/blob/main/server/app/controllers/auth_controller.py"
click node_uploadroutes "https://github.com/atharvpatil322/qna-rag-application/blob/main/server/app/routes/upload_routes.py"
click node_uploadcontroller "https://github.com/atharvpatil322/qna-rag-application/blob/main/server/app/controllers/upload_controller.py"
click node_chatroutes "https://github.com/atharvpatil322/qna-rag-application/blob/main/server/app/routes/chat_routes.py"
click node_chatcontroller "https://github.com/atharvpatil322/qna-rag-application/blob/main/server/app/controllers/chat_controller.py"
click node_usersvc "https://github.com/atharvpatil322/qna-rag-application/blob/main/server/app/services/user_service.py"
click node_docsvc "https://github.com/atharvpatil322/qna-rag-application/blob/main/server/app/services/document_service.py"
click node_processor "https://github.com/atharvpatil322/qna-rag-application/blob/main/server/app/utils/document_processor.py"
click node_chatsvc "https://github.com/atharvpatil322/qna-rag-application/blob/main/server/app/services/chat_service.py"
click node_llm "https://github.com/atharvpatil322/qna-rag-application/blob/main/server/app/llm/providers.py"
click node_vectors "https://github.com/atharvpatil322/qna-rag-application/blob/main/server/app/db/milvus_vector_store.py"
click node_postgres "https://github.com/atharvpatil322/qna-rag-application/blob/main/server/app/db/postgres.py"
click node_mongo "https://github.com/atharvpatil322/qna-rag-application/blob/main/server/app/db/mongodb.py"
click node_authsvc "https://github.com/atharvpatil322/qna-rag-application/blob/main/server/app/services/auth_service.py"
click node_authutils "https://github.com/atharvpatil322/qna-rag-application/blob/main/server/app/utils/auth.py"
click node_rebuild "https://github.com/atharvpatil322/qna-rag-application/blob/main/server/app/services/vector_rebuild_service.py"
click node_admincontroller "https://github.com/atharvpatil322/qna-rag-application/blob/main/server/app/controllers/admin_vector_controller.py"
click node_sse "https://github.com/atharvpatil322/qna-rag-application/blob/main/server/app/utils/sse.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_webapp,node_authui,node_chatscreen,node_docsui,node_accountui,node_apiclient,node_user toneBlue
class node_apiapp,node_authroutes,node_authcontroller,node_uploadroutes,node_uploadcontroller,node_chatroutes,node_chatcontroller,node_usersvc toneAmber
class node_docsvc,node_processor,node_chatsvc,node_llm,node_vectors toneMint
class node_postgres,node_mongo,node_authsvc,node_authutils toneRose
class node_rebuild,node_admincontroller,node_sse,node_admin toneIndigo
```

## Components

### Web client

- [Web application](https://github.com/atharvpatil322/qna-rag-application/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Authentication screens](https://github.com/atharvpatil322/qna-rag-application/tree/main/frontend/src/pages/auth): `frontend/src/pages/auth`
- [Chat experience](https://github.com/atharvpatil322/qna-rag-application/blob/main/frontend/src/components/chat/ChatInterface.tsx): `frontend/src/components/chat/ChatInterface.tsx`
- [Document screens](https://github.com/atharvpatil322/qna-rag-application/tree/main/frontend/src/components/documents): `frontend/src/components/documents`
- [Account and settings](https://github.com/atharvpatil322/qna-rag-application/tree/main/frontend/src/pages): `frontend/src/pages`
- [API client](https://github.com/atharvpatil322/qna-rag-application/blob/main/frontend/src/lib/api.ts): `frontend/src/lib/api.ts`

### API and workflows

- [FastAPI application](https://github.com/atharvpatil322/qna-rag-application/blob/main/server/main.py): `server/main.py`
- [Auth routes](https://github.com/atharvpatil322/qna-rag-application/blob/main/server/app/routes/auth_routes.py): `server/app/routes/auth_routes.py`
- [Auth controller](https://github.com/atharvpatil322/qna-rag-application/blob/main/server/app/controllers/auth_controller.py): `server/app/controllers/auth_controller.py`
- [Upload routes](https://github.com/atharvpatil322/qna-rag-application/blob/main/server/app/routes/upload_routes.py): `server/app/routes/upload_routes.py`
- [Upload controller](https://github.com/atharvpatil322/qna-rag-application/blob/main/server/app/controllers/upload_controller.py): `server/app/controllers/upload_controller.py`
- [Chat routes](https://github.com/atharvpatil322/qna-rag-application/blob/main/server/app/routes/chat_routes.py): `server/app/routes/chat_routes.py`
- [Chat controller](https://github.com/atharvpatil322/qna-rag-application/blob/main/server/app/controllers/chat_controller.py): `server/app/controllers/chat_controller.py`
- [User service](https://github.com/atharvpatil322/qna-rag-application/blob/main/server/app/services/user_service.py): `server/app/services/user_service.py`

### Document and RAG

- [Document service](https://github.com/atharvpatil322/qna-rag-application/blob/main/server/app/services/document_service.py): `server/app/services/document_service.py`
- [PDF processing](https://github.com/atharvpatil322/qna-rag-application/blob/main/server/app/utils/document_processor.py): `server/app/utils/document_processor.py`
- [Chat service](https://github.com/atharvpatil322/qna-rag-application/blob/main/server/app/services/chat_service.py): `server/app/services/chat_service.py`
- [LLM providers](https://github.com/atharvpatil322/qna-rag-application/blob/main/server/app/llm/providers.py): `server/app/llm/providers.py`
- [Vector search](https://github.com/atharvpatil322/qna-rag-application/blob/main/server/app/db/milvus_vector_store.py): `server/app/db/milvus_vector_store.py`

### Persistence and identity

- [PostgreSQL](https://github.com/atharvpatil322/qna-rag-application/blob/main/server/app/db/postgres.py): `server/app/db/postgres.py`
- [MongoDB](https://github.com/atharvpatil322/qna-rag-application/blob/main/server/app/db/mongodb.py): `server/app/db/mongodb.py`
- [Authentication service](https://github.com/atharvpatil322/qna-rag-application/blob/main/server/app/services/auth_service.py): `server/app/services/auth_service.py`
- [JWT and passwords](https://github.com/atharvpatil322/qna-rag-application/blob/main/server/app/utils/auth.py): `server/app/utils/auth.py`

### Administration

- [Vector recovery](https://github.com/atharvpatil322/qna-rag-application/blob/main/server/app/services/vector_rebuild_service.py): `server/app/services/vector_rebuild_service.py`
- [Admin vector controller](https://github.com/atharvpatil322/qna-rag-application/blob/main/server/app/controllers/admin_vector_controller.py): `server/app/controllers/admin_vector_controller.py`
- [Progress events](https://github.com/atharvpatil322/qna-rag-application/blob/main/server/app/utils/sse.py): `server/app/utils/sse.py`

### Other components

- **User**
- **Administrator**

## Connections

- User → Web application: uses
- Administrator → Web application: manages
- Web application → Authentication screens: routes (evidence: `frontend/src/App.tsx`)
- Web application → Chat experience: routes
- Web application → Document screens: routes
- Web application → Account and settings: routes (evidence: `frontend/src/App.tsx`)
- Web application → API client: calls
- API client → FastAPI application: sends requests
- FastAPI application → Auth routes: registers routes (evidence: `server/main.py`)
- FastAPI application → Upload routes: registers routes (evidence: `server/main.py`)
- FastAPI application → Chat routes: registers routes (evidence: `server/main.py`)
- Auth routes → Auth controller: dispatches
- Auth controller → Authentication service: delegates (evidence: `server/app/controllers/auth_controller.py`)
- Authentication service → PostgreSQL: reads and writes (evidence: `server/app/services/auth_service.py`)
- Authentication service → JWT and passwords: uses (evidence: `server/app/services/auth_service.py`)
- Auth controller → User service: delegates
- Upload routes → Document service: processes upload (evidence: `server/app/routes/upload_routes.py`)
- Upload routes → Upload controller: dispatches (evidence: `server/app/routes/upload_routes.py`)
- Upload routes → Progress events: streams events (evidence: `server/app/routes/upload_routes.py`)
- Document service → PDF processing: extracts and chunks (evidence: `server/app/services/document_service.py`)
- Document service → Vector search: stores embeddings (evidence: `server/app/services/document_service.py`)
- Document service → MongoDB: stores documents (evidence: `server/app/services/document_service.py`)
- Document service → PostgreSQL: stores metadata (evidence: `server/app/services/document_service.py`)
- Chat routes → Chat controller: dispatches
- Chat controller → Chat service: processes chat (evidence: `server/app/controllers/chat_controller.py`)
- Chat controller → Vector search: gets vector store (evidence: `server/app/controllers/chat_controller.py`)
- Chat service → Vector search: retrieves context
- Chat service → LLM providers: generates answers
- Chat service → MongoDB: stores conversations
- Admin vector controller → Vector recovery: rebuilds vectors (evidence: `server/app/controllers/admin_vector_controller.py`)
- Vector recovery → MongoDB: reads backup (evidence: `server/app/services/vector_rebuild_service.py`)
- Vector recovery → Vector search: restores index (evidence: `server/app/services/vector_rebuild_service.py`)
- Admin vector controller → Progress events: emits progress (evidence: `server/app/controllers/admin_vector_controller.py`)
