# aryan-018008/documind-ai architecture

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

- Interactive diagram: https://gitdiagram.com/aryan-018008/documind-ai
- Repository: https://github.com/aryan-018008/documind-ai

## Overview

DocuMind AI is a Flask application for authenticated, PDF-grounded question answering. The principal workflow uploads a PDF, extracts page text, chunks it, builds a semantic/lexical search index, and sends retrieved context to Groq for an answer with source references. Authentication and email OTP verification are a separate product branch. The graph follows the sampled route/service calls and README capabilities; the frontend and some integrations are documented but not sampled in source.

Main entry points: [`routes/chat_routes.py`](https://github.com/aryan-018008/documind-ai/blob/main/routes/chat_routes.py) (Chat API), [`routes/documents_routes.py`](https://github.com/aryan-018008/documind-ai/blob/main/routes/documents_routes.py) (Document upload and listing), [`app.py`](https://github.com/aryan-018008/documind-ai/blob/main/app.py) (Flask entry and dashboard), [`templates`](https://github.com/aryan-018008/documind-ai/tree/main/templates) (Web interface)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web application"]
  node_app["Flask entry and dashboard<br/>[app.py]"]
  node_interface["Web interface"]
end

subgraph group_identity["Identity and accounts"]
  node_auth_routes["Authentication routes<br/>[auth_routes.py]"]
  node_auth_helpers["Login guard<br/>[auth_helpers.py]"]
  node_database[("SQLite account and document data<br/>[db.py]")]
  node_resend["Resend email service"]
end

subgraph group_documents["Document processing"]
  node_document_routes["Document upload and listing"]
  node_file_storage["Uploaded PDF files"]
  node_pdf["PDF text extraction<br/>[pdf_service.py]"]
end

subgraph group_qa["Question answering"]
  node_chat_routes["Chat API<br/>[chat_routes.py]"]
  node_chunking["Page text chunking"]
  node_vector_store["Hybrid vector search"]
  node_embeddings["Text embeddings"]
  node_rag["Grounded answer generation<br/>[rag_service.py]"]
end

node_user(("User"))
node_groq["Groq language model"]

node_user -.->|"uses"| node_interface
node_interface -.->|"views"| node_app
node_app -->|"registers routes"| node_auth_routes
node_app -->|"registers routes"| node_document_routes
node_app -->|"registers routes"| node_chat_routes
node_app -->|"initializes and queries"| node_database
node_auth_routes -->|"reads and writes"| node_database
node_auth_routes -->|"sends verification email"| node_resend
node_document_routes -->|"guards access"| node_auth_helpers
node_chat_routes -->|"guards access"| node_auth_helpers
node_document_routes -->|"saves PDF"| node_file_storage
node_document_routes -->|"extracts text"| node_pdf
node_document_routes -->|"stores metadata"| node_database
node_chat_routes -->|"checks ownership"| node_database
node_chat_routes -->|"reads selected PDF"| node_file_storage
node_chat_routes -->|"extracts pages"| node_pdf
node_chat_routes -->|"chunks pages"| node_chunking
node_chat_routes -->|"builds index"| node_vector_store
node_vector_store -->|"generates vectors"| node_embeddings
node_chat_routes -->|"requests answer"| node_rag
node_rag -->|"retrieves passages"| node_vector_store
node_rag -->|"generates response"| node_groq
node_chat_routes -.->|"returns answer and sources"| node_interface
node_document_routes -.->|"returns upload results"| node_interface

click node_app "https://github.com/aryan-018008/documind-ai/blob/main/app.py"
click node_interface "https://github.com/aryan-018008/documind-ai/tree/main/templates"
click node_auth_routes "https://github.com/aryan-018008/documind-ai/blob/main/routes/auth_routes.py"
click node_auth_helpers "https://github.com/aryan-018008/documind-ai/blob/main/routes/auth_helpers.py"
click node_database "https://github.com/aryan-018008/documind-ai/blob/main/database/db.py"
click node_document_routes "https://github.com/aryan-018008/documind-ai/blob/main/routes/documents_routes.py"
click node_file_storage "https://github.com/aryan-018008/documind-ai/tree/main/uploads"
click node_pdf "https://github.com/aryan-018008/documind-ai/blob/main/services/pdf_service.py"
click node_chat_routes "https://github.com/aryan-018008/documind-ai/blob/main/routes/chat_routes.py"
click node_chunking "https://github.com/aryan-018008/documind-ai/blob/main/services/chunking_service.py"
click node_vector_store "https://github.com/aryan-018008/documind-ai/blob/main/services/vector_store_service.py"
click node_embeddings "https://github.com/aryan-018008/documind-ai/blob/main/services/embedding_service.py"
click node_rag "https://github.com/aryan-018008/documind-ai/blob/main/services/rag_service.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_interface,node_user toneBlue
class node_auth_routes,node_auth_helpers,node_database,node_resend toneAmber
class node_document_routes,node_file_storage,node_pdf toneMint
class node_chat_routes,node_chunking,node_vector_store,node_embeddings,node_rag toneRose
class node_groq toneIndigo
```

## Components

### Web application

- [Flask entry and dashboard](https://github.com/aryan-018008/documind-ai/blob/main/app.py): `app.py`
- [Web interface](https://github.com/aryan-018008/documind-ai/tree/main/templates): `templates`

### Identity and accounts

- [Authentication routes](https://github.com/aryan-018008/documind-ai/blob/main/routes/auth_routes.py): `routes/auth_routes.py`
- [Login guard](https://github.com/aryan-018008/documind-ai/blob/main/routes/auth_helpers.py): `routes/auth_helpers.py`
- [SQLite account and document data](https://github.com/aryan-018008/documind-ai/blob/main/database/db.py): `database/db.py`
- **Resend email service**

### Document processing

- [Document upload and listing](https://github.com/aryan-018008/documind-ai/blob/main/routes/documents_routes.py): `routes/documents_routes.py`
- [Uploaded PDF files](https://github.com/aryan-018008/documind-ai/tree/main/uploads): `uploads`
- [PDF text extraction](https://github.com/aryan-018008/documind-ai/blob/main/services/pdf_service.py): `services/pdf_service.py`

### Question answering

- [Chat API](https://github.com/aryan-018008/documind-ai/blob/main/routes/chat_routes.py): `routes/chat_routes.py`
- [Page text chunking](https://github.com/aryan-018008/documind-ai/blob/main/services/chunking_service.py): `services/chunking_service.py`
- [Hybrid vector search](https://github.com/aryan-018008/documind-ai/blob/main/services/vector_store_service.py): `services/vector_store_service.py`
- [Text embeddings](https://github.com/aryan-018008/documind-ai/blob/main/services/embedding_service.py): `services/embedding_service.py`
- [Grounded answer generation](https://github.com/aryan-018008/documind-ai/blob/main/services/rag_service.py): `services/rag_service.py`

### Other components

- **User**
- **Groq language model**

## Connections

- User → Web interface: uses (evidence: `README.md`)
- Web interface → Flask entry and dashboard: views (evidence: `README.md`)
- Flask entry and dashboard → Authentication routes: registers routes (evidence: `app.py`)
- Flask entry and dashboard → Document upload and listing: registers routes (evidence: `app.py`)
- Flask entry and dashboard → Chat API: registers routes (evidence: `app.py`)
- Flask entry and dashboard → SQLite account and document data: initializes and queries (evidence: `app.py`)
- Authentication routes → SQLite account and document data: reads and writes (evidence: `routes/auth_routes.py`)
- Authentication routes → Resend email service: sends verification email (evidence: `routes/auth_routes.py`)
- Document upload and listing → Login guard: guards access (evidence: `routes/documents_routes.py`)
- Chat API → Login guard: guards access (evidence: `routes/chat_routes.py`)
- Document upload and listing → Uploaded PDF files: saves PDF (evidence: `routes/documents_routes.py`)
- Document upload and listing → PDF text extraction: extracts text (evidence: `routes/documents_routes.py`)
- Document upload and listing → SQLite account and document data: stores metadata (evidence: `routes/documents_routes.py`)
- Chat API → SQLite account and document data: checks ownership (evidence: `routes/chat_routes.py`)
- Chat API → Uploaded PDF files: reads selected PDF (evidence: `routes/chat_routes.py`)
- Chat API → PDF text extraction: extracts pages (evidence: `routes/chat_routes.py`)
- Chat API → Page text chunking: chunks pages (evidence: `routes/chat_routes.py`)
- Chat API → Hybrid vector search: builds index (evidence: `routes/chat_routes.py`)
- Hybrid vector search → Text embeddings: generates vectors (evidence: `services/vector_store_service.py`)
- Chat API → Grounded answer generation: requests answer (evidence: `routes/chat_routes.py`)
- Grounded answer generation → Hybrid vector search: retrieves passages (evidence: `services/rag_service.py`)
- Grounded answer generation → Groq language model: generates response (evidence: `services/rag_service.py`)
- Chat API → Web interface: returns answer and sources (evidence: `README.md`)
- Document upload and listing → Web interface: returns upload results (evidence: `README.md`)
