# onlyshreeya/docmind architecture

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

- Interactive diagram: https://gitdiagram.com/onlyshreeya/docmind
- Repository: https://github.com/onlyshreeya/docmind

## Overview

DocMind lets users organize documents by domain, upload them, and ask cited questions grounded in those documents. The frontend calls a Node API for folders, documents, and chats; the API stores metadata and chat history and proxies ML work. The FastAPI service parses and domain-chunks uploads, embeds them into vector storage, then retrieves passages for answer generation. An optional advanced query path adds conversational memory, graph expansion, budget selection, and conflict checks. The README describes the service and external-store architecture; some backend route details and external wiring are documented rather than shown in excerpts.

Main entry points: [`ml-service/app/modules/pipeline.py`](https://github.com/onlyshreeya/docmind/blob/main/ml-service/app/modules/pipeline.py) (Advanced RAG pipeline), [`ml-service/app/routers/ingest.py`](https://github.com/onlyshreeya/docmind/blob/main/ml-service/app/routers/ingest.py) (Upload ingestion), [`backend/src/server.js`](https://github.com/onlyshreeya/docmind/blob/main/backend/src/server.js) (Express API), [`frontend/src/App.jsx`](https://github.com/onlyshreeya/docmind/blob/main/frontend/src/App.jsx) (App state)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["User interface"]
  node_app["App state<br/>[App.jsx]"]
  node_sidebar["Folder and document UI<br/>[Sidebar.jsx]"]
  node_chatui["Chat and citations<br/>[ChatWindow.jsx]"]
end

subgraph group_api["Metadata API"]
  node_express["Express API<br/>[server.js]"]
  node_folderapi["Folder management<br/>[folders.js]"]
  node_documentapi["Document management<br/>[documents.js]"]
  node_chatapi["Chat and ML proxy<br/>[chat.js]"]
  node_folderdata[("Folder metadata<br/>[Folder.js]")]
  node_documentdata[("Document metadata<br/>[Document.js]")]
  node_chatdata[("Chat history<br/>[ChatSession.js]")]
end

subgraph group_rag["RAG service"]
  node_fastapi["FastAPI service<br/>[main.py]"]
  node_ingest["Upload ingestion<br/>[ingest.py]"]
  node_parsing["Document parsing<br/>[parsing.py]"]
  node_chunking["Domain chunking<br/>[chunking.py]"]
  node_profiles["Domain profiles<br/>[domains.py]"]
  node_embeddings["Text embeddings<br/>[embeddings.py]"]
  node_vectorstore[("Vector storage<br/>[vectorstore.py]")]
  node_queryapi["Query endpoints<br/>[query.py]"]
  node_retrieval["Passage retrieval<br/>[retrieval.py]"]
  node_generation["Answer generation<br/>[generation.py]"]
  node_pipeline["Advanced RAG pipeline<br/>[pipeline.py]"]
  node_csm["Conversational memory<br/>[csm.py]"]
  node_eacg["Entity graph expansion<br/>[eacg.py]"]
  node_cba["Context budget selection<br/>[cba.py]"]
  node_cdcr["Conflict detection<br/>[cdcr.py]"]
end

node_user(("DocMind user"))
node_mongo[("MongoDB")]
node_chroma[("ChromaDB")]
node_gemini["Gemini API"]

node_user -->|"uses"| node_app
node_app -->|"renders"| node_sidebar
node_app -->|"renders"| node_chatui
node_app -->|"requests API"| node_express
node_express -->|"mounts routes"| node_folderapi
node_express -->|"mounts routes"| node_documentapi
node_express -->|"mounts routes"| node_chatapi
node_folderapi -->|"reads and writes"| node_folderdata
node_folderapi -->|"manages related docs"| node_documentdata
node_folderapi -->|"manages related chats"| node_chatdata
node_documentapi -->|"reads and writes"| node_documentdata
node_chatapi -->|"reads and writes"| node_chatdata
node_express -->|"connects"| node_mongo
node_chatapi -->|"proxies ML requests"| node_fastapi
node_fastapi -->|"registers router"| node_ingest
node_fastapi -->|"registers router"| node_queryapi
node_ingest -->|"extracts text"| node_parsing
node_ingest -->|"chunks text"| node_chunking
node_ingest -->|"gets profile"| node_profiles
node_chunking -->|"uses settings"| node_profiles
node_ingest -->|"embeds chunks"| node_embeddings
node_ingest -->|"upserts chunks"| node_vectorstore
node_queryapi -->|"retrieves passages"| node_retrieval
node_queryapi -->|"generates answer"| node_generation
node_queryapi -->|"dispatches advanced query"| node_pipeline
node_retrieval -->|"embeds query"| node_embeddings
node_retrieval -->|"searches vectors"| node_vectorstore
node_generation -->|"uses domain prompts"| node_profiles
node_pipeline -->|"reformulates query"| node_csm
node_pipeline -->|"retrieves seeds"| node_retrieval
node_pipeline -->|"expands passages"| node_eacg
node_pipeline -->|"selects passages"| node_cba
node_pipeline -->|"checks conflicts"| node_cdcr
node_pipeline -->|"generates answer"| node_generation
node_vectorstore -->|"stores vectors"| node_chroma
node_generation -->|"uses generation API"| node_gemini

click node_app "https://github.com/onlyshreeya/docmind/blob/main/frontend/src/App.jsx"
click node_sidebar "https://github.com/onlyshreeya/docmind/blob/main/frontend/src/components/Sidebar.jsx"
click node_chatui "https://github.com/onlyshreeya/docmind/blob/main/frontend/src/components/ChatWindow.jsx"
click node_express "https://github.com/onlyshreeya/docmind/blob/main/backend/src/server.js"
click node_folderapi "https://github.com/onlyshreeya/docmind/blob/main/backend/src/routes/folders.js"
click node_documentapi "https://github.com/onlyshreeya/docmind/blob/main/backend/src/routes/documents.js"
click node_chatapi "https://github.com/onlyshreeya/docmind/blob/main/backend/src/routes/chat.js"
click node_folderdata "https://github.com/onlyshreeya/docmind/blob/main/backend/src/models/Folder.js"
click node_documentdata "https://github.com/onlyshreeya/docmind/blob/main/backend/src/models/Document.js"
click node_chatdata "https://github.com/onlyshreeya/docmind/blob/main/backend/src/models/ChatSession.js"
click node_fastapi "https://github.com/onlyshreeya/docmind/blob/main/ml-service/main.py"
click node_ingest "https://github.com/onlyshreeya/docmind/blob/main/ml-service/app/routers/ingest.py"
click node_parsing "https://github.com/onlyshreeya/docmind/blob/main/ml-service/app/parsing.py"
click node_chunking "https://github.com/onlyshreeya/docmind/blob/main/ml-service/app/chunking.py"
click node_profiles "https://github.com/onlyshreeya/docmind/blob/main/ml-service/app/domains.py"
click node_embeddings "https://github.com/onlyshreeya/docmind/blob/main/ml-service/app/embeddings.py"
click node_vectorstore "https://github.com/onlyshreeya/docmind/blob/main/ml-service/app/vectorstore.py"
click node_queryapi "https://github.com/onlyshreeya/docmind/blob/main/ml-service/app/routers/query.py"
click node_retrieval "https://github.com/onlyshreeya/docmind/blob/main/ml-service/app/retrieval.py"
click node_generation "https://github.com/onlyshreeya/docmind/blob/main/ml-service/app/generation.py"
click node_pipeline "https://github.com/onlyshreeya/docmind/blob/main/ml-service/app/modules/pipeline.py"
click node_csm "https://github.com/onlyshreeya/docmind/blob/main/ml-service/app/modules/csm.py"
click node_eacg "https://github.com/onlyshreeya/docmind/blob/main/ml-service/app/modules/eacg.py"
click node_cba "https://github.com/onlyshreeya/docmind/blob/main/ml-service/app/modules/cba.py"
click node_cdcr "https://github.com/onlyshreeya/docmind/blob/main/ml-service/app/modules/cdcr.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_sidebar,node_chatui,node_user toneBlue
class node_express,node_folderapi,node_documentapi,node_chatapi,node_folderdata,node_documentdata,node_chatdata,node_mongo,node_chroma toneAmber
class node_fastapi,node_ingest,node_parsing,node_chunking,node_profiles,node_embeddings,node_vectorstore,node_queryapi,node_retrieval,node_generation,node_pipeline,node_csm,node_eacg,node_cba,node_cdcr,node_gemini toneMint
```

## Components

### User interface

- [App state](https://github.com/onlyshreeya/docmind/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Folder and document UI](https://github.com/onlyshreeya/docmind/blob/main/frontend/src/components/Sidebar.jsx): `frontend/src/components/Sidebar.jsx`
- [Chat and citations](https://github.com/onlyshreeya/docmind/blob/main/frontend/src/components/ChatWindow.jsx): `frontend/src/components/ChatWindow.jsx`

### Metadata API

- [Express API](https://github.com/onlyshreeya/docmind/blob/main/backend/src/server.js): `backend/src/server.js`
- [Folder management](https://github.com/onlyshreeya/docmind/blob/main/backend/src/routes/folders.js): `backend/src/routes/folders.js`
- [Document management](https://github.com/onlyshreeya/docmind/blob/main/backend/src/routes/documents.js): `backend/src/routes/documents.js`
- [Chat and ML proxy](https://github.com/onlyshreeya/docmind/blob/main/backend/src/routes/chat.js): `backend/src/routes/chat.js`
- [Folder metadata](https://github.com/onlyshreeya/docmind/blob/main/backend/src/models/Folder.js): `backend/src/models/Folder.js`
- [Document metadata](https://github.com/onlyshreeya/docmind/blob/main/backend/src/models/Document.js): `backend/src/models/Document.js`
- [Chat history](https://github.com/onlyshreeya/docmind/blob/main/backend/src/models/ChatSession.js): `backend/src/models/ChatSession.js`

### RAG service

- [FastAPI service](https://github.com/onlyshreeya/docmind/blob/main/ml-service/main.py): `ml-service/main.py`
- [Upload ingestion](https://github.com/onlyshreeya/docmind/blob/main/ml-service/app/routers/ingest.py): `ml-service/app/routers/ingest.py`
- [Document parsing](https://github.com/onlyshreeya/docmind/blob/main/ml-service/app/parsing.py): `ml-service/app/parsing.py`
- [Domain chunking](https://github.com/onlyshreeya/docmind/blob/main/ml-service/app/chunking.py): `ml-service/app/chunking.py`
- [Domain profiles](https://github.com/onlyshreeya/docmind/blob/main/ml-service/app/domains.py): `ml-service/app/domains.py`
- [Text embeddings](https://github.com/onlyshreeya/docmind/blob/main/ml-service/app/embeddings.py): `ml-service/app/embeddings.py`
- [Vector storage](https://github.com/onlyshreeya/docmind/blob/main/ml-service/app/vectorstore.py): `ml-service/app/vectorstore.py`
- [Query endpoints](https://github.com/onlyshreeya/docmind/blob/main/ml-service/app/routers/query.py): `ml-service/app/routers/query.py`
- [Passage retrieval](https://github.com/onlyshreeya/docmind/blob/main/ml-service/app/retrieval.py): `ml-service/app/retrieval.py`
- [Answer generation](https://github.com/onlyshreeya/docmind/blob/main/ml-service/app/generation.py): `ml-service/app/generation.py`
- [Advanced RAG pipeline](https://github.com/onlyshreeya/docmind/blob/main/ml-service/app/modules/pipeline.py): `ml-service/app/modules/pipeline.py`
- [Conversational memory](https://github.com/onlyshreeya/docmind/blob/main/ml-service/app/modules/csm.py): `ml-service/app/modules/csm.py`
- [Entity graph expansion](https://github.com/onlyshreeya/docmind/blob/main/ml-service/app/modules/eacg.py): `ml-service/app/modules/eacg.py`
- [Context budget selection](https://github.com/onlyshreeya/docmind/blob/main/ml-service/app/modules/cba.py): `ml-service/app/modules/cba.py`
- [Conflict detection](https://github.com/onlyshreeya/docmind/blob/main/ml-service/app/modules/cdcr.py): `ml-service/app/modules/cdcr.py`

### Other components

- **DocMind user**
- **MongoDB**
- **ChromaDB**
- **Gemini API**

## Connections

- DocMind user → App state: uses (evidence: `frontend/src/App.jsx`)
- App state → Folder and document UI: renders (evidence: `frontend/src/App.jsx`)
- App state → Chat and citations: renders (evidence: `frontend/src/App.jsx`)
- App state → Express API: requests API (evidence: `frontend/src/App.jsx`)
- Express API → Folder management: mounts routes (evidence: `backend/src/server.js`)
- Express API → Document management: mounts routes (evidence: `backend/src/server.js`)
- Express API → Chat and ML proxy: mounts routes (evidence: `backend/src/server.js`)
- Folder management → Folder metadata: reads and writes (evidence: `backend/src/routes/folders.js`)
- Folder management → Document metadata: manages related docs (evidence: `backend/src/routes/folders.js`)
- Folder management → Chat history: manages related chats (evidence: `backend/src/routes/folders.js`)
- Document management → Document metadata: reads and writes (evidence: `backend/src/routes/documents.js`)
- Chat and ML proxy → Chat history: reads and writes (evidence: `backend/src/routes/chat.js`)
- Express API → MongoDB: connects (evidence: `README.md`)
- Chat and ML proxy → FastAPI service: proxies ML requests (evidence: `README.md`)
- FastAPI service → Upload ingestion: registers router (evidence: `ml-service/main.py`)
- FastAPI service → Query endpoints: registers router (evidence: `ml-service/main.py`)
- Upload ingestion → Document parsing: extracts text (evidence: `ml-service/app/routers/ingest.py`)
- Upload ingestion → Domain chunking: chunks text (evidence: `ml-service/app/routers/ingest.py`)
- Upload ingestion → Domain profiles: gets profile (evidence: `ml-service/app/routers/ingest.py`)
- Domain chunking → Domain profiles: uses settings (evidence: `ml-service/app/chunking.py`)
- Upload ingestion → Text embeddings: embeds chunks (evidence: `ml-service/app/routers/ingest.py`)
- Upload ingestion → Vector storage: upserts chunks (evidence: `ml-service/app/routers/ingest.py`)
- Query endpoints → Passage retrieval: retrieves passages (evidence: `ml-service/app/routers/query.py`)
- Query endpoints → Answer generation: generates answer (evidence: `ml-service/app/routers/query.py`)
- Query endpoints → Advanced RAG pipeline: dispatches advanced query (evidence: `ml-service/app/routers/query.py`)
- Passage retrieval → Text embeddings: embeds query (evidence: `ml-service/app/retrieval.py`)
- Passage retrieval → Vector storage: searches vectors (evidence: `ml-service/app/retrieval.py`)
- Answer generation → Domain profiles: uses domain prompts (evidence: `ml-service/app/generation.py`)
- Advanced RAG pipeline → Conversational memory: reformulates query (evidence: `ml-service/app/modules/pipeline.py`)
- Advanced RAG pipeline → Passage retrieval: retrieves seeds (evidence: `ml-service/app/modules/pipeline.py`)
- Advanced RAG pipeline → Entity graph expansion: expands passages (evidence: `ml-service/app/modules/pipeline.py`)
- Advanced RAG pipeline → Context budget selection: selects passages (evidence: `ml-service/app/modules/pipeline.py`)
- Advanced RAG pipeline → Conflict detection: checks conflicts (evidence: `ml-service/app/modules/pipeline.py`)
- Advanced RAG pipeline → Answer generation: generates answer (evidence: `ml-service/app/modules/pipeline.py`)
- Vector storage → ChromaDB: stores vectors (evidence: `README.md`)
- Answer generation → Gemini API: uses generation API (evidence: `README.md`)
