# newblathe/docmind architecture

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

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

## Overview

DocMind is a document-analysis web application. Users upload supported files, select documents and ask a question; the pipeline indexes new documents, retrieves relevant passages, produces cited per-document answers, then identifies themes. Users can also list and delete uploaded documents. The graph includes the documented UI capabilities and the sampled backend calls; detailed UI request wiring and some deployment integrations are not shown in the excerpts.

Main entry points: [`backend/app/api/routes/pipeline_routes.py`](https://github.com/newblathe/docmind/blob/main/backend/app/api/routes/pipeline_routes.py) (Pipeline API), [`backend/app/api/routes/document_routes.py`](https://github.com/newblathe/docmind/blob/main/backend/app/api/routes/document_routes.py) (Document API), [`backend/app/services/meta_store.py`](https://github.com/newblathe/docmind/blob/main/backend/app/services/meta_store.py) (Metadata and Search), [`backend/app/services/query_engine.py`](https://github.com/newblathe/docmind/blob/main/backend/app/services/query_engine.py) (Answer and Citation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client_api["Client and API"]
  node_web_ui["Web UI"]
  node_app["FastAPI App<br/>[main.py]"]
  node_document_api["Document API<br/>[document_routes.py]"]
  node_pipeline_api["Pipeline API<br/>[pipeline_routes.py]"]
  node_api_models["API Models<br/>[models.py]"]
end

subgraph group_document_ingest["Document Ingestion"]
  node_uploads[("Uploaded Files")]
  node_preprocessor["Preprocessor"]
end

subgraph group_analysis["Document Analysis"]
  node_metadata_service["Metadata and Search<br/>[meta_store.py]"]
  node_query_engine["Answer and Citation<br/>[query_engine.py]"]
  node_theme_identifier["Theme Identifier"]
end

subgraph group_platform_state["Platform and State"]
  node_metadata_db[("MongoDB Metadata")]
  node_config["Configuration<br/>[config.py]"]
  node_rate_limiter["Rate Limiter<br/>[limiter.py]"]
  node_logger["Logger<br/>[logger.py]"]
end

node_user(("User"))
node_groq["Groq LLM"]

node_user -->|"uses"| node_web_ui
node_app -->|"serves"| node_web_ui
node_web_ui -.->|"uploads, lists, deletes"| node_document_api
node_web_ui -.->|"submits questions"| node_pipeline_api
node_app -->|"registers router"| node_document_api
node_app -->|"registers router"| node_pipeline_api
node_document_api -->|"writes, lists, deletes"| node_uploads
node_document_api -->|"removes document metadata"| node_metadata_service
node_pipeline_api -->|"reads selected files"| node_uploads
node_pipeline_api -->|"checks indexed documents"| node_metadata_service
node_pipeline_api -->|"preprocesses new files"| node_preprocessor
node_preprocessor -->|"replaces chunks and embeddings"| node_metadata_service
node_pipeline_api -->|"requests answers"| node_query_engine
node_query_engine -->|"searches document chunks"| node_metadata_service
node_metadata_service -->|"stores and reads metadata"| node_metadata_db
node_query_engine -->|"generates cited answers"| node_groq
node_pipeline_api -->|"requests themes"| node_theme_identifier
node_theme_identifier -->|"identifies themes"| node_groq
node_pipeline_api -->|"validates and returns"| node_api_models
node_document_api -->|"returns responses"| node_api_models
node_document_api -->|"uses limits"| node_rate_limiter
node_pipeline_api -->|"uses limits"| node_rate_limiter
node_app -->|"configures middleware"| node_rate_limiter
node_document_api -->|"reads upload path"| node_config
node_pipeline_api -->|"reads upload path"| node_config
node_metadata_service -->|"reads database URL"| node_config
node_query_engine -->|"reads API key"| node_config
node_theme_identifier -->|"reads API key"| node_config
node_document_api -->|"logs operations"| node_logger
node_pipeline_api -->|"logs pipeline"| node_logger
node_preprocessor -->|"logs processing"| node_logger
node_query_engine -->|"logs extraction"| node_logger
node_theme_identifier -->|"logs theme extraction"| node_logger
node_web_ui -.->|"shows results"| node_user

click node_web_ui "https://github.com/newblathe/docmind/tree/main/demo"
click node_app "https://github.com/newblathe/docmind/blob/main/backend/app/main.py"
click node_document_api "https://github.com/newblathe/docmind/blob/main/backend/app/api/routes/document_routes.py"
click node_pipeline_api "https://github.com/newblathe/docmind/blob/main/backend/app/api/routes/pipeline_routes.py"
click node_api_models "https://github.com/newblathe/docmind/blob/main/backend/app/models/models.py"
click node_preprocessor "https://github.com/newblathe/docmind/blob/main/backend/app/services/document_preprocessor.py"
click node_metadata_service "https://github.com/newblathe/docmind/blob/main/backend/app/services/meta_store.py"
click node_query_engine "https://github.com/newblathe/docmind/blob/main/backend/app/services/query_engine.py"
click node_theme_identifier "https://github.com/newblathe/docmind/blob/main/backend/app/services/theme_identifier.py"
click node_config "https://github.com/newblathe/docmind/blob/main/backend/app/core/config.py"
click node_rate_limiter "https://github.com/newblathe/docmind/blob/main/backend/app/core/limiter.py"
click node_logger "https://github.com/newblathe/docmind/blob/main/backend/app/core/logger.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_web_ui,node_app,node_document_api,node_pipeline_api,node_api_models,node_user toneBlue
class node_uploads,node_preprocessor toneAmber
class node_metadata_service,node_query_engine,node_theme_identifier toneMint
class node_metadata_db,node_config,node_rate_limiter,node_logger toneRose
class node_groq toneIndigo
```

## Components

### Client and API

- [Web UI](https://github.com/newblathe/docmind/tree/main/demo): `demo`
- [FastAPI App](https://github.com/newblathe/docmind/blob/main/backend/app/main.py): `backend/app/main.py`
- [Document API](https://github.com/newblathe/docmind/blob/main/backend/app/api/routes/document_routes.py): `backend/app/api/routes/document_routes.py`
- [Pipeline API](https://github.com/newblathe/docmind/blob/main/backend/app/api/routes/pipeline_routes.py): `backend/app/api/routes/pipeline_routes.py`
- [API Models](https://github.com/newblathe/docmind/blob/main/backend/app/models/models.py): `backend/app/models/models.py`

### Document Ingestion

- **Uploaded Files**
- [Preprocessor](https://github.com/newblathe/docmind/blob/main/backend/app/services/document_preprocessor.py): `backend/app/services/document_preprocessor.py`

### Document Analysis

- [Metadata and Search](https://github.com/newblathe/docmind/blob/main/backend/app/services/meta_store.py): `backend/app/services/meta_store.py`
- [Answer and Citation](https://github.com/newblathe/docmind/blob/main/backend/app/services/query_engine.py): `backend/app/services/query_engine.py`
- [Theme Identifier](https://github.com/newblathe/docmind/blob/main/backend/app/services/theme_identifier.py): `backend/app/services/theme_identifier.py`

### Platform and State

- **MongoDB Metadata**
- [Configuration](https://github.com/newblathe/docmind/blob/main/backend/app/core/config.py): `backend/app/core/config.py`
- [Rate Limiter](https://github.com/newblathe/docmind/blob/main/backend/app/core/limiter.py): `backend/app/core/limiter.py`
- [Logger](https://github.com/newblathe/docmind/blob/main/backend/app/core/logger.py): `backend/app/core/logger.py`

### Other components

- **User**
- **Groq LLM**

## Connections

- User → Web UI: uses (evidence: `README.MD`)
- FastAPI App → Web UI: serves (evidence: `backend/app/main.py`)
- Web UI → Document API: uploads, lists, deletes (evidence: `README.MD`)
- Web UI → Pipeline API: submits questions (evidence: `README.MD`)
- FastAPI App → Document API: registers router (evidence: `backend/app/main.py`)
- FastAPI App → Pipeline API: registers router (evidence: `backend/app/main.py`)
- Document API → Uploaded Files: writes, lists, deletes (evidence: `backend/app/api/routes/document_routes.py`)
- Document API → Metadata and Search: removes document metadata (evidence: `backend/app/api/routes/document_routes.py`)
- Pipeline API → Uploaded Files: reads selected files (evidence: `backend/app/api/routes/pipeline_routes.py`)
- Pipeline API → Metadata and Search: checks indexed documents (evidence: `backend/app/api/routes/pipeline_routes.py`)
- Pipeline API → Preprocessor: preprocesses new files (evidence: `backend/app/api/routes/pipeline_routes.py`)
- Preprocessor → Metadata and Search: replaces chunks and embeddings (evidence: `backend/app/services/document_preprocessor.py`)
- Pipeline API → Answer and Citation: requests answers (evidence: `backend/app/api/routes/pipeline_routes.py`)
- Answer and Citation → Metadata and Search: searches document chunks (evidence: `backend/app/services/query_engine.py`)
- Metadata and Search → MongoDB Metadata: stores and reads metadata (evidence: `backend/app/services/meta_store.py`)
- Answer and Citation → Groq LLM: generates cited answers (evidence: `backend/app/services/query_engine.py`)
- Pipeline API → Theme Identifier: requests themes (evidence: `backend/app/api/routes/pipeline_routes.py`)
- Theme Identifier → Groq LLM: identifies themes (evidence: `backend/app/services/theme_identifier.py`)
- Pipeline API → API Models: validates and returns (evidence: `backend/app/api/routes/pipeline_routes.py`)
- Document API → API Models: returns responses (evidence: `backend/app/api/routes/document_routes.py`)
- Document API → Rate Limiter: uses limits (evidence: `backend/app/api/routes/document_routes.py`)
- Pipeline API → Rate Limiter: uses limits (evidence: `backend/app/api/routes/pipeline_routes.py`)
- FastAPI App → Rate Limiter: configures middleware (evidence: `backend/app/main.py`)
- Document API → Configuration: reads upload path (evidence: `backend/app/api/routes/document_routes.py`)
- Pipeline API → Configuration: reads upload path (evidence: `backend/app/api/routes/pipeline_routes.py`)
- Metadata and Search → Configuration: reads database URL (evidence: `backend/app/services/meta_store.py`)
- Answer and Citation → Configuration: reads API key (evidence: `backend/app/services/query_engine.py`)
- Theme Identifier → Configuration: reads API key (evidence: `backend/app/services/theme_identifier.py`)
- Document API → Logger: logs operations (evidence: `backend/app/api/routes/document_routes.py`)
- Pipeline API → Logger: logs pipeline (evidence: `backend/app/api/routes/pipeline_routes.py`)
- Preprocessor → Logger: logs processing (evidence: `backend/app/services/document_preprocessor.py`)
- Answer and Citation → Logger: logs extraction (evidence: `backend/app/services/query_engine.py`)
- Theme Identifier → Logger: logs theme extraction (evidence: `backend/app/services/theme_identifier.py`)
- Web UI → User: shows results (evidence: `README.MD`)
