# hlong24082k/doc-mind architecture

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

- Interactive diagram: https://gitdiagram.com/hlong24082k/doc-mind
- Repository: https://github.com/hlong24082k/doc-mind

## Overview

This repository implements a document-oriented chat web app: users sign in, manage documents, and can enter a chat flow, with the server exposing API routes and a Gemini-backed streaming service. The sampled client code confirms routing, authentication state, and API service calls; the sampled server code confirms router mounting, MongoDB connection setup, and LLM streaming. Endpoint internals and several page implementations were not sampled, so uncertain wiring is left out.

Main entry points: [`client/src/router.tsx`](https://github.com/hlong24082k/doc-mind/blob/develop/client/src/router.tsx) (App routes), [`server/src/app/routers`](https://github.com/hlong24082k/doc-mind/tree/develop/server/src/app/routers) (API routes), [`server/src/app/main.py`](https://github.com/hlong24082k/doc-mind/blob/develop/server/src/app/main.py) (HTTP API), [`client/src/api/apiClient.ts`](https://github.com/hlong24082k/doc-mind/blob/develop/client/src/api/apiClient.ts) (API client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web client"]
  node_router["App routes<br/>[router.tsx]"]
  node_login["Login page<br/>[LoginPage.tsx]"]
  node_signup["Signup page<br/>[SignupPage.tsx]"]
  node_chatpage["Chat page<br/>[ChatPage.tsx]"]
  node_documents["Documents page<br/>[DocumentsPage.tsx]"]
  node_authstate["Auth state<br/>[authStore.ts]"]
  node_authservice["Auth service<br/>[auth.service.ts]"]
  node_docservice["Document service"]
  node_apiclient["API client<br/>[apiClient.ts]"]
end

subgraph group_server["API server"]
  node_api["HTTP API<br/>[main.py]"]
  node_routes["API routes"]
  node_authroutes["Auth endpoints<br/>[endpoint.py]"]
  node_docroutes["Document endpoints<br/>[endpoint.py]"]
  node_chatroutes["Conversation endpoints<br/>[endpoint.py]"]
  node_chatservice["Chat stream service<br/>[services.py]"]
end

subgraph group_data["Persistence"]
  node_dbsession["Mongo session<br/>[session.py]"]
  node_doccrud["Document CRUD<br/>[document.py]"]
  node_usercrud["User CRUD<br/>[user.py]"]
  node_models["Data models"]
end

subgraph group_ai["Chat generation"]
  node_llmbase["LLM interface<br/>[base.py]"]
  node_gemini["Gemini provider<br/>[gemini_provider.py]"]
  node_prompts["Prompt templates"]
  node_postprocess["Response processing<br/>[post_processor.py]"]
end

node_user(("User"))
node_mongo[("MongoDB")]
node_geminiservice{{"Gemini API"}}

node_user -->|"uses"| node_router
node_router -->|"routes"| node_login
node_router -->|"routes"| node_signup
node_router -->|"routes"| node_chatpage
node_router -->|"routes"| node_documents
node_router -->|"checks access"| node_authstate
node_authstate -->|"calls"| node_authservice
node_authservice -->|"requests"| node_apiclient
node_docservice -->|"requests"| node_apiclient
node_apiclient -->|"sends HTTP"| node_api
node_api -->|"mounts"| node_routes
node_api -->|"initializes"| node_dbsession
node_routes --> node_authroutes
node_routes --> node_docroutes
node_routes --> node_chatroutes
node_dbsession -->|"connects"| node_mongo
node_chatservice -->|"uses"| node_llmbase
node_chatservice -->|"defaults to"| node_gemini
node_gemini -.->|"generates from"| node_geminiservice

click node_router "https://github.com/hlong24082k/doc-mind/blob/develop/client/src/router.tsx"
click node_login "https://github.com/hlong24082k/doc-mind/blob/develop/client/src/pages/LoginPage.tsx"
click node_signup "https://github.com/hlong24082k/doc-mind/blob/develop/client/src/pages/SignupPage.tsx"
click node_chatpage "https://github.com/hlong24082k/doc-mind/blob/develop/client/src/pages/ChatPage.tsx"
click node_documents "https://github.com/hlong24082k/doc-mind/blob/develop/client/src/pages/DocumentsPage.tsx"
click node_authstate "https://github.com/hlong24082k/doc-mind/blob/develop/client/src/store/authStore.ts"
click node_authservice "https://github.com/hlong24082k/doc-mind/blob/develop/client/src/api/services/auth.service.ts"
click node_docservice "https://github.com/hlong24082k/doc-mind/blob/develop/client/src/api/services/document.service.ts"
click node_apiclient "https://github.com/hlong24082k/doc-mind/blob/develop/client/src/api/apiClient.ts"
click node_api "https://github.com/hlong24082k/doc-mind/blob/develop/server/src/app/main.py"
click node_routes "https://github.com/hlong24082k/doc-mind/tree/develop/server/src/app/routers"
click node_authroutes "https://github.com/hlong24082k/doc-mind/blob/develop/server/src/app/routers/auth/endpoint.py"
click node_docroutes "https://github.com/hlong24082k/doc-mind/blob/develop/server/src/app/routers/document/endpoint.py"
click node_chatroutes "https://github.com/hlong24082k/doc-mind/blob/develop/server/src/app/routers/conversation/endpoint.py"
click node_chatservice "https://github.com/hlong24082k/doc-mind/blob/develop/server/src/app/routers/conversation/services.py"
click node_dbsession "https://github.com/hlong24082k/doc-mind/blob/develop/server/src/app/db/session.py"
click node_doccrud "https://github.com/hlong24082k/doc-mind/blob/develop/server/src/app/cruds/document.py"
click node_usercrud "https://github.com/hlong24082k/doc-mind/blob/develop/server/src/app/cruds/user.py"
click node_models "https://github.com/hlong24082k/doc-mind/tree/develop/server/src/app/models"
click node_llmbase "https://github.com/hlong24082k/doc-mind/blob/develop/server/src/app/core/llm/base.py"
click node_gemini "https://github.com/hlong24082k/doc-mind/blob/develop/server/src/app/core/llm/gemini_provider.py"
click node_prompts "https://github.com/hlong24082k/doc-mind/blob/develop/server/src/app/core/prompt/prompt_templates.py"
click node_postprocess "https://github.com/hlong24082k/doc-mind/blob/develop/server/src/app/core/llm/post_processor.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_router,node_login,node_signup,node_chatpage,node_documents,node_authstate,node_authservice,node_docservice,node_apiclient,node_user toneBlue
class node_api,node_routes,node_authroutes,node_docroutes,node_chatroutes,node_chatservice,node_mongo toneAmber
class node_dbsession,node_doccrud,node_usercrud,node_models,node_geminiservice toneMint
class node_llmbase,node_gemini,node_prompts,node_postprocess toneRose
```

## Components

### Web client

- [App routes](https://github.com/hlong24082k/doc-mind/blob/develop/client/src/router.tsx): `client/src/router.tsx`
- [Login page](https://github.com/hlong24082k/doc-mind/blob/develop/client/src/pages/LoginPage.tsx): `client/src/pages/LoginPage.tsx`
- [Signup page](https://github.com/hlong24082k/doc-mind/blob/develop/client/src/pages/SignupPage.tsx): `client/src/pages/SignupPage.tsx`
- [Chat page](https://github.com/hlong24082k/doc-mind/blob/develop/client/src/pages/ChatPage.tsx): `client/src/pages/ChatPage.tsx`
- [Documents page](https://github.com/hlong24082k/doc-mind/blob/develop/client/src/pages/DocumentsPage.tsx): `client/src/pages/DocumentsPage.tsx`
- [Auth state](https://github.com/hlong24082k/doc-mind/blob/develop/client/src/store/authStore.ts): `client/src/store/authStore.ts`
- [Auth service](https://github.com/hlong24082k/doc-mind/blob/develop/client/src/api/services/auth.service.ts): `client/src/api/services/auth.service.ts`
- [Document service](https://github.com/hlong24082k/doc-mind/blob/develop/client/src/api/services/document.service.ts): `client/src/api/services/document.service.ts`
- [API client](https://github.com/hlong24082k/doc-mind/blob/develop/client/src/api/apiClient.ts): `client/src/api/apiClient.ts`

### API server

- [HTTP API](https://github.com/hlong24082k/doc-mind/blob/develop/server/src/app/main.py): `server/src/app/main.py`
- [API routes](https://github.com/hlong24082k/doc-mind/tree/develop/server/src/app/routers): `server/src/app/routers`
- [Auth endpoints](https://github.com/hlong24082k/doc-mind/blob/develop/server/src/app/routers/auth/endpoint.py): `server/src/app/routers/auth/endpoint.py`
- [Document endpoints](https://github.com/hlong24082k/doc-mind/blob/develop/server/src/app/routers/document/endpoint.py): `server/src/app/routers/document/endpoint.py`
- [Conversation endpoints](https://github.com/hlong24082k/doc-mind/blob/develop/server/src/app/routers/conversation/endpoint.py): `server/src/app/routers/conversation/endpoint.py`
- [Chat stream service](https://github.com/hlong24082k/doc-mind/blob/develop/server/src/app/routers/conversation/services.py): `server/src/app/routers/conversation/services.py`

### Persistence

- [Mongo session](https://github.com/hlong24082k/doc-mind/blob/develop/server/src/app/db/session.py): `server/src/app/db/session.py`
- [Document CRUD](https://github.com/hlong24082k/doc-mind/blob/develop/server/src/app/cruds/document.py): `server/src/app/cruds/document.py`
- [User CRUD](https://github.com/hlong24082k/doc-mind/blob/develop/server/src/app/cruds/user.py): `server/src/app/cruds/user.py`
- [Data models](https://github.com/hlong24082k/doc-mind/tree/develop/server/src/app/models): `server/src/app/models`

### Chat generation

- [LLM interface](https://github.com/hlong24082k/doc-mind/blob/develop/server/src/app/core/llm/base.py): `server/src/app/core/llm/base.py`
- [Gemini provider](https://github.com/hlong24082k/doc-mind/blob/develop/server/src/app/core/llm/gemini_provider.py): `server/src/app/core/llm/gemini_provider.py`
- [Prompt templates](https://github.com/hlong24082k/doc-mind/blob/develop/server/src/app/core/prompt/prompt_templates.py): `server/src/app/core/prompt/prompt_templates.py`
- [Response processing](https://github.com/hlong24082k/doc-mind/blob/develop/server/src/app/core/llm/post_processor.py): `server/src/app/core/llm/post_processor.py`

### Other components

- **User**
- **MongoDB**
- **Gemini API**

## Connections

- User → App routes: uses
- App routes → Login page: routes
- App routes → Signup page: routes
- App routes → Chat page: routes
- App routes → Documents page: routes
- App routes → Auth state: checks access
- Auth state → Auth service: calls
- Auth service → API client: requests
- Document service → API client: requests
- API client → HTTP API: sends HTTP
- HTTP API → API routes: mounts
- HTTP API → Mongo session: initializes
- API routes → Auth endpoints
- API routes → Document endpoints
- API routes → Conversation endpoints
- Mongo session → MongoDB: connects
- Chat stream service → LLM interface: uses
- Chat stream service → Gemini provider: defaults to
- Gemini provider → Gemini API: generates from
