# abhishek4852/docsense architecture

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

- Interactive diagram: https://gitdiagram.com/abhishek4852/docsense
- Repository: https://github.com/abhishek4852/docsense

## Overview

DocSense is a multi-tenant document knowledge assistant. Users register and sign in, upload documents or text, then query an organization’s indexed knowledge through dashboard chat; WhatsApp offers a second documented access channel. Ingestion and answer generation are distinct RAG stages, with retrieval and re-ranking between them. The graph includes account, document, chat, and WhatsApp capabilities from the README; WhatsApp configuration and several frontend-to-API connections are only partially evidenced in the excerpts, so uncertain links are dashed.

Main entry points: [`frontend/src/api/axios.js`](https://github.com/abhishek4852/docsense/blob/main/frontend/src/api/axios.js) (API client), [`backend/whatsapp/views.py`](https://github.com/abhishek4852/docsense/blob/main/backend/whatsapp/views.py) (Webhook and message handling), [`backend/documents/views.py`](https://github.com/abhishek4852/docsense/blob/main/backend/documents/views.py) (Document endpoints), [`backend/chat/views.py`](https://github.com/abhishek4852/docsense/blob/main/backend/chat/views.py) (Chat endpoints)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web experience"]
  node_landing["Landing page<br/>[LandingPage.jsx]"]
  node_register["Registration<br/>[RegisterPage.jsx]"]
  node_login["Sign in<br/>[LoginPage.jsx]"]
  node_dashboard["Dashboard shell"]
  node_upload_ui["Document upload UI<br/>[UploadPage.jsx]"]
  node_chat_ui["Chat interface<br/>[ChatPage.jsx]"]
  node_wa_ui["WhatsApp settings UI"]
  node_api_client["API client<br/>[axios.js]"]
end

subgraph group_identity["Accounts and tenancy"]
  node_accounts[("Organization and users<br/>[models.py]")]
  node_account_views["Account endpoints<br/>[views.py]"]
end

subgraph group_knowledge["Knowledge ingestion"]
  node_documents[("Document records<br/>[models.py]")]
  node_document_views["Document endpoints<br/>[views.py]"]
  node_parser["Document parsing<br/>[parser.py]"]
  node_chunking["Type-aware chunking<br/>[chunking.py]"]
end

subgraph group_rag["RAG and chat"]
  node_embedding["Text embeddings<br/>[embedding.py]"]
  node_vector_store[("Organization vector store<br/>[vector_store.py]")]
  node_retriever["Retrieval and reranking<br/>[retriever.py]"]
  node_prompt["Prompt construction<br/>[prompt.py]"]
  node_generator["Answer generation<br/>[generator.py]"]
  node_chat_views["Chat endpoints<br/>[views.py]"]
  node_chat_records[("Chat sessions and messages<br/>[models.py]")]
end

subgraph group_messaging["WhatsApp"]
  node_wa_views["Webhook and message handling<br/>[views.py]"]
  node_wa_records[("WhatsApp configuration and history<br/>[models.py]")]
end

node_visitor(("User"))
node_meta(("Meta WhatsApp"))

node_visitor -.->|"opens"| node_landing
node_landing -->|"links to"| node_register
node_landing -->|"links to"| node_login
node_register -->|"submits registration"| node_api_client
node_login -->|"sends credentials"| node_api_client
node_api_client -.->|"calls API"| node_account_views
node_account_views -.->|"reads and writes"| node_accounts
node_dashboard -->|"routes to"| node_upload_ui
node_dashboard -->|"routes to"| node_chat_ui
node_dashboard -->|"routes to"| node_wa_ui
node_upload_ui -.->|"uploads documents"| node_api_client
node_chat_ui -->|"requests chat"| node_api_client
node_wa_ui -.->|"configures channel"| node_api_client
node_api_client -.->|"calls API"| node_document_views
node_api_client -.->|"calls API"| node_chat_views
node_api_client -.->|"calls API"| node_wa_views
node_document_views -->|"creates and lists"| node_documents
node_document_views -->|"extracts text"| node_parser
node_document_views -->|"chunks text"| node_chunking
node_document_views -->|"embeds chunks"| node_embedding
node_document_views -->|"indexes chunks"| node_vector_store
node_chat_views -->|"reads and writes"| node_chat_records
node_chat_views -->|"retrieves context"| node_retriever
node_chat_views -->|"builds prompt"| node_prompt
node_chat_views -->|"generates answer"| node_generator
node_retriever -->|"embeds query"| node_embedding
node_retriever -->|"searches chunks"| node_vector_store
node_wa_views -->|"reads and writes"| node_wa_records
node_wa_views -->|"retrieves context"| node_retriever
node_wa_views -->|"builds prompt"| node_prompt
node_wa_views -.->|"generates answer"| node_generator
node_wa_views -->|"sends replies"| node_meta
node_meta -.->|"delivers webhook"| node_wa_views

click node_landing "https://github.com/abhishek4852/docsense/blob/main/frontend/src/pages/LandingPage.jsx"
click node_register "https://github.com/abhishek4852/docsense/blob/main/frontend/src/pages/auth/RegisterPage.jsx"
click node_login "https://github.com/abhishek4852/docsense/blob/main/frontend/src/pages/auth/LoginPage.jsx"
click node_dashboard "https://github.com/abhishek4852/docsense/blob/main/frontend/src/pages/dashboard/DashboardLayout.jsx"
click node_upload_ui "https://github.com/abhishek4852/docsense/blob/main/frontend/src/pages/dashboard/UploadPage.jsx"
click node_chat_ui "https://github.com/abhishek4852/docsense/blob/main/frontend/src/pages/dashboard/ChatPage.jsx"
click node_wa_ui "https://github.com/abhishek4852/docsense/blob/main/frontend/src/pages/dashboard/WhatsAppSettingsPage.jsx"
click node_api_client "https://github.com/abhishek4852/docsense/blob/main/frontend/src/api/axios.js"
click node_accounts "https://github.com/abhishek4852/docsense/blob/main/backend/accounts/models.py"
click node_account_views "https://github.com/abhishek4852/docsense/blob/main/backend/accounts/views.py"
click node_documents "https://github.com/abhishek4852/docsense/blob/main/backend/documents/models.py"
click node_document_views "https://github.com/abhishek4852/docsense/blob/main/backend/documents/views.py"
click node_parser "https://github.com/abhishek4852/docsense/blob/main/backend/rag/parser.py"
click node_chunking "https://github.com/abhishek4852/docsense/blob/main/backend/rag/chunking.py"
click node_embedding "https://github.com/abhishek4852/docsense/blob/main/backend/rag/embedding.py"
click node_vector_store "https://github.com/abhishek4852/docsense/blob/main/backend/rag/vector_store.py"
click node_retriever "https://github.com/abhishek4852/docsense/blob/main/backend/rag/retriever.py"
click node_prompt "https://github.com/abhishek4852/docsense/blob/main/backend/rag/prompt.py"
click node_generator "https://github.com/abhishek4852/docsense/blob/main/backend/rag/generator.py"
click node_chat_views "https://github.com/abhishek4852/docsense/blob/main/backend/chat/views.py"
click node_chat_records "https://github.com/abhishek4852/docsense/blob/main/backend/chat/models.py"
click node_wa_views "https://github.com/abhishek4852/docsense/blob/main/backend/whatsapp/views.py"
click node_wa_records "https://github.com/abhishek4852/docsense/blob/main/backend/whatsapp/models.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_landing,node_register,node_login,node_dashboard,node_upload_ui,node_chat_ui,node_wa_ui,node_api_client,node_visitor toneBlue
class node_accounts,node_account_views toneAmber
class node_documents,node_document_views,node_parser,node_chunking toneMint
class node_embedding,node_vector_store,node_retriever,node_prompt,node_generator,node_chat_views,node_chat_records toneRose
class node_wa_views,node_wa_records,node_meta toneIndigo
```

## Components

### Web experience

- [Landing page](https://github.com/abhishek4852/docsense/blob/main/frontend/src/pages/LandingPage.jsx): `frontend/src/pages/LandingPage.jsx`
- [Registration](https://github.com/abhishek4852/docsense/blob/main/frontend/src/pages/auth/RegisterPage.jsx): `frontend/src/pages/auth/RegisterPage.jsx`
- [Sign in](https://github.com/abhishek4852/docsense/blob/main/frontend/src/pages/auth/LoginPage.jsx): `frontend/src/pages/auth/LoginPage.jsx`
- [Dashboard shell](https://github.com/abhishek4852/docsense/blob/main/frontend/src/pages/dashboard/DashboardLayout.jsx): `frontend/src/pages/dashboard/DashboardLayout.jsx`
- [Document upload UI](https://github.com/abhishek4852/docsense/blob/main/frontend/src/pages/dashboard/UploadPage.jsx): `frontend/src/pages/dashboard/UploadPage.jsx`
- [Chat interface](https://github.com/abhishek4852/docsense/blob/main/frontend/src/pages/dashboard/ChatPage.jsx): `frontend/src/pages/dashboard/ChatPage.jsx`
- [WhatsApp settings UI](https://github.com/abhishek4852/docsense/blob/main/frontend/src/pages/dashboard/WhatsAppSettingsPage.jsx): `frontend/src/pages/dashboard/WhatsAppSettingsPage.jsx`
- [API client](https://github.com/abhishek4852/docsense/blob/main/frontend/src/api/axios.js): `frontend/src/api/axios.js`

### Accounts and tenancy

- [Organization and users](https://github.com/abhishek4852/docsense/blob/main/backend/accounts/models.py): `backend/accounts/models.py`
- [Account endpoints](https://github.com/abhishek4852/docsense/blob/main/backend/accounts/views.py): `backend/accounts/views.py`

### Knowledge ingestion

- [Document records](https://github.com/abhishek4852/docsense/blob/main/backend/documents/models.py): `backend/documents/models.py`
- [Document endpoints](https://github.com/abhishek4852/docsense/blob/main/backend/documents/views.py): `backend/documents/views.py`
- [Document parsing](https://github.com/abhishek4852/docsense/blob/main/backend/rag/parser.py): `backend/rag/parser.py`
- [Type-aware chunking](https://github.com/abhishek4852/docsense/blob/main/backend/rag/chunking.py): `backend/rag/chunking.py`

### RAG and chat

- [Text embeddings](https://github.com/abhishek4852/docsense/blob/main/backend/rag/embedding.py): `backend/rag/embedding.py`
- [Organization vector store](https://github.com/abhishek4852/docsense/blob/main/backend/rag/vector_store.py): `backend/rag/vector_store.py`
- [Retrieval and reranking](https://github.com/abhishek4852/docsense/blob/main/backend/rag/retriever.py): `backend/rag/retriever.py`
- [Prompt construction](https://github.com/abhishek4852/docsense/blob/main/backend/rag/prompt.py): `backend/rag/prompt.py`
- [Answer generation](https://github.com/abhishek4852/docsense/blob/main/backend/rag/generator.py): `backend/rag/generator.py`
- [Chat endpoints](https://github.com/abhishek4852/docsense/blob/main/backend/chat/views.py): `backend/chat/views.py`
- [Chat sessions and messages](https://github.com/abhishek4852/docsense/blob/main/backend/chat/models.py): `backend/chat/models.py`

### WhatsApp

- [Webhook and message handling](https://github.com/abhishek4852/docsense/blob/main/backend/whatsapp/views.py): `backend/whatsapp/views.py`
- [WhatsApp configuration and history](https://github.com/abhishek4852/docsense/blob/main/backend/whatsapp/models.py): `backend/whatsapp/models.py`

### Other components

- **User**
- **Meta WhatsApp**

## Connections

- User → Landing page: opens
- Landing page → Registration: links to (evidence: `frontend/src/pages/LandingPage.jsx`)
- Landing page → Sign in: links to (evidence: `frontend/src/pages/LandingPage.jsx`)
- Registration → API client: submits registration (evidence: `frontend/src/pages/auth/RegisterPage.jsx`)
- Sign in → API client: sends credentials (evidence: `frontend/src/pages/auth/LoginPage.jsx`)
- API client → Account endpoints: calls API
- Account endpoints → Organization and users: reads and writes
- Dashboard shell → Document upload UI: routes to (evidence: `frontend/src/App.jsx`)
- Dashboard shell → Chat interface: routes to (evidence: `frontend/src/App.jsx`)
- Dashboard shell → WhatsApp settings UI: routes to (evidence: `frontend/src/App.jsx`)
- Document upload UI → API client: uploads documents (evidence: `frontend/src/pages/dashboard/UploadPage.jsx`)
- Chat interface → API client: requests chat (evidence: `frontend/src/pages/dashboard/ChatPage.jsx`)
- WhatsApp settings UI → API client: configures channel (evidence: `frontend/src/pages/dashboard/WhatsAppSettingsPage.jsx`)
- API client → Document endpoints: calls API
- API client → Chat endpoints: calls API
- API client → Webhook and message handling: calls API
- Document endpoints → Document records: creates and lists (evidence: `backend/documents/views.py`)
- Document endpoints → Document parsing: extracts text (evidence: `backend/documents/views.py`)
- Document endpoints → Type-aware chunking: chunks text (evidence: `backend/documents/views.py`)
- Document endpoints → Text embeddings: embeds chunks (evidence: `backend/documents/views.py`)
- Document endpoints → Organization vector store: indexes chunks (evidence: `backend/documents/views.py`)
- Chat endpoints → Chat sessions and messages: reads and writes (evidence: `backend/chat/views.py`)
- Chat endpoints → Retrieval and reranking: retrieves context (evidence: `backend/chat/views.py`)
- Chat endpoints → Prompt construction: builds prompt (evidence: `backend/chat/views.py`)
- Chat endpoints → Answer generation: generates answer (evidence: `backend/chat/views.py`)
- Retrieval and reranking → Text embeddings: embeds query (evidence: `backend/rag/retriever.py`)
- Retrieval and reranking → Organization vector store: searches chunks (evidence: `backend/rag/retriever.py`)
- Webhook and message handling → WhatsApp configuration and history: reads and writes (evidence: `backend/whatsapp/views.py`)
- Webhook and message handling → Retrieval and reranking: retrieves context (evidence: `backend/whatsapp/views.py`)
- Webhook and message handling → Prompt construction: builds prompt (evidence: `backend/whatsapp/views.py`)
- Webhook and message handling → Answer generation: generates answer (evidence: `backend/whatsapp/views.py`)
- Webhook and message handling → Meta WhatsApp: sends replies (evidence: `backend/whatsapp/views.py`)
- Meta WhatsApp → Webhook and message handling: delivers webhook
