# vishnukoushikkumara/dochelper architecture

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

- Interactive diagram: https://gitdiagram.com/vishnukoushikkumara/dochelper
- Repository: https://github.com/vishnukoushikkumara/dochelper

## Overview

DocuMentor lets users upload PDFs, processes them into searchable document chunks, and streams answers with source references and agent traces. The frontend combines upload, document-library polling, and chat; the backend exposes those workflows through HTTP routes backed by MongoDB, embeddings, and an LLM. The upload implementation shows parsing, chunking, embedding, persistence, and summarization. The chat agent’s internal steps are not excerpted, so its links to retrieval dependencies are shown as unverified rather than asserted.

Main entry points: [`backend/app/routes_upload.py`](https://github.com/vishnukoushikkumara/dochelper/blob/main/backend/app/routes_upload.py) (Upload route), [`backend/app/deps.py`](https://github.com/vishnukoushikkumara/dochelper/blob/main/backend/app/deps.py) (Service dependencies), [`frontend/src/api.js`](https://github.com/vishnukoushikkumara/dochelper/blob/main/frontend/src/api.js) (API client), [`frontend/src/components/Chat.jsx`](https://github.com/vishnukoushikkumara/dochelper/blob/main/frontend/src/components/Chat.jsx) (Chat)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["User interface"]
  node_app["App shell<br/>[App.jsx]"]
  node_upload_ui["PDF upload<br/>[Upload.jsx]"]
  node_library_ui["Document library<br/>[Library.jsx]"]
  node_chat_ui["Chat<br/>[Chat.jsx]"]
  node_chat_details["Sources and steps<br/>[Sources.jsx]"]
  node_agent_steps["Agent steps view<br/>[AgentSteps.jsx]"]
end

subgraph group_api["HTTP workflows"]
  node_api_client["API client<br/>[api.js]"]
  node_upload_route["Upload route<br/>[routes_upload.py]"]
  node_documents_route["Documents route"]
  node_chat_route["Chat route<br/>[routes_chat.py]"]
  node_schemas["API schemas<br/>[schemas.py]"]
end

subgraph group_ingestion["Document ingestion"]
  node_pdf_parser["PDF parser<br/>[pdf_parser.py]"]
  node_chunker["Text chunker<br/>[chunker.py]"]
end

subgraph group_services["AI and storage"]
  node_agent["Chat agent graph<br/>[agent_graph.py]"]
  node_embedder["Embedding model<br/>[embeddings.py]"]
  node_llm["LLM client<br/>[llm_client.py]"]
  node_store[("MongoDB store<br/>[mongo_client.py]")]
  node_dependencies["Service dependencies<br/>[deps.py]"]
  node_settings["Configuration<br/>[config.py]"]
end

node_user(("User"))
node_groq{{"Groq API"}}
node_mongodb[("MongoDB")]

node_user -->|"selects PDF"| node_upload_ui
node_user -->|"asks question"| node_chat_ui
node_app -->|"renders"| node_upload_ui
node_app -->|"renders"| node_library_ui
node_app -->|"renders"| node_chat_ui
node_app -->|"lists documents"| node_api_client
node_upload_ui -->|"uploads PDF"| node_api_client
node_chat_ui -->|"streams chat"| node_api_client
node_chat_ui -->|"renders sources"| node_chat_details
node_chat_ui -->|"renders trace"| node_agent_steps
node_api_client -->|"POST /upload"| node_upload_route
node_api_client -->|"GET /documents"| node_documents_route
node_api_client -->|"POST /chat"| node_chat_route
node_upload_route -->|"parses PDF"| node_pdf_parser
node_upload_route -->|"chunks text"| node_chunker
node_upload_route -->|"encodes chunks"| node_embedder
node_upload_route -->|"persists document"| node_store
node_upload_route -->|"summarizes text"| node_llm
node_upload_route -->|"resolves services"| node_dependencies
node_documents_route -->|"lists documents"| node_store
node_documents_route -->|"resolves store"| node_dependencies
node_chat_route -->|"runs graph"| node_agent
node_chat_route -->|"resolves services"| node_dependencies
node_chat_route -->|"accepts request"| node_schemas
node_agent -.->|"uses embeddings"| node_embedder
node_agent -.->|"searches chunks"| node_store
node_agent -.->|"generates answer"| node_llm
node_dependencies -->|"creates store"| node_store
node_dependencies -->|"gets embedder"| node_embedder
node_dependencies -->|"creates client"| node_llm
node_store -->|"reads and writes"| node_mongodb
node_llm -->|"requests completions"| node_groq
node_dependencies -->|"reads settings"| node_settings

click node_app "https://github.com/vishnukoushikkumara/dochelper/blob/main/frontend/src/App.jsx"
click node_upload_ui "https://github.com/vishnukoushikkumara/dochelper/blob/main/frontend/src/components/Upload.jsx"
click node_library_ui "https://github.com/vishnukoushikkumara/dochelper/blob/main/frontend/src/components/Library.jsx"
click node_chat_ui "https://github.com/vishnukoushikkumara/dochelper/blob/main/frontend/src/components/Chat.jsx"
click node_chat_details "https://github.com/vishnukoushikkumara/dochelper/blob/main/frontend/src/components/Sources.jsx"
click node_agent_steps "https://github.com/vishnukoushikkumara/dochelper/blob/main/frontend/src/components/AgentSteps.jsx"
click node_api_client "https://github.com/vishnukoushikkumara/dochelper/blob/main/frontend/src/api.js"
click node_upload_route "https://github.com/vishnukoushikkumara/dochelper/blob/main/backend/app/routes_upload.py"
click node_documents_route "https://github.com/vishnukoushikkumara/dochelper/blob/main/backend/app/routes_documents.py"
click node_chat_route "https://github.com/vishnukoushikkumara/dochelper/blob/main/backend/app/routes_chat.py"
click node_pdf_parser "https://github.com/vishnukoushikkumara/dochelper/blob/main/backend/app/pdf_parser.py"
click node_chunker "https://github.com/vishnukoushikkumara/dochelper/blob/main/backend/app/chunker.py"
click node_schemas "https://github.com/vishnukoushikkumara/dochelper/blob/main/backend/app/schemas.py"
click node_agent "https://github.com/vishnukoushikkumara/dochelper/blob/main/backend/app/agent_graph.py"
click node_embedder "https://github.com/vishnukoushikkumara/dochelper/blob/main/backend/app/embeddings.py"
click node_llm "https://github.com/vishnukoushikkumara/dochelper/blob/main/backend/app/llm_client.py"
click node_store "https://github.com/vishnukoushikkumara/dochelper/blob/main/backend/app/mongo_client.py"
click node_dependencies "https://github.com/vishnukoushikkumara/dochelper/blob/main/backend/app/deps.py"
click node_settings "https://github.com/vishnukoushikkumara/dochelper/blob/main/backend/app/config.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_upload_ui,node_library_ui,node_chat_ui,node_chat_details,node_agent_steps,node_user toneBlue
class node_api_client,node_upload_route,node_documents_route,node_chat_route,node_schemas,node_mongodb toneAmber
class node_pdf_parser,node_chunker,node_groq toneMint
class node_agent,node_embedder,node_llm,node_store,node_dependencies,node_settings toneRose
```

## Components

### User interface

- [App shell](https://github.com/vishnukoushikkumara/dochelper/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [PDF upload](https://github.com/vishnukoushikkumara/dochelper/blob/main/frontend/src/components/Upload.jsx): `frontend/src/components/Upload.jsx`
- [Document library](https://github.com/vishnukoushikkumara/dochelper/blob/main/frontend/src/components/Library.jsx): `frontend/src/components/Library.jsx`
- [Chat](https://github.com/vishnukoushikkumara/dochelper/blob/main/frontend/src/components/Chat.jsx): `frontend/src/components/Chat.jsx`
- [Sources and steps](https://github.com/vishnukoushikkumara/dochelper/blob/main/frontend/src/components/Sources.jsx): `frontend/src/components/Sources.jsx`
- [Agent steps view](https://github.com/vishnukoushikkumara/dochelper/blob/main/frontend/src/components/AgentSteps.jsx): `frontend/src/components/AgentSteps.jsx`

### HTTP workflows

- [API client](https://github.com/vishnukoushikkumara/dochelper/blob/main/frontend/src/api.js): `frontend/src/api.js`
- [Upload route](https://github.com/vishnukoushikkumara/dochelper/blob/main/backend/app/routes_upload.py): `backend/app/routes_upload.py`
- [Documents route](https://github.com/vishnukoushikkumara/dochelper/blob/main/backend/app/routes_documents.py): `backend/app/routes_documents.py`
- [Chat route](https://github.com/vishnukoushikkumara/dochelper/blob/main/backend/app/routes_chat.py): `backend/app/routes_chat.py`
- [API schemas](https://github.com/vishnukoushikkumara/dochelper/blob/main/backend/app/schemas.py): `backend/app/schemas.py`

### Document ingestion

- [PDF parser](https://github.com/vishnukoushikkumara/dochelper/blob/main/backend/app/pdf_parser.py): `backend/app/pdf_parser.py`
- [Text chunker](https://github.com/vishnukoushikkumara/dochelper/blob/main/backend/app/chunker.py): `backend/app/chunker.py`

### AI and storage

- [Chat agent graph](https://github.com/vishnukoushikkumara/dochelper/blob/main/backend/app/agent_graph.py): `backend/app/agent_graph.py`
- [Embedding model](https://github.com/vishnukoushikkumara/dochelper/blob/main/backend/app/embeddings.py): `backend/app/embeddings.py`
- [LLM client](https://github.com/vishnukoushikkumara/dochelper/blob/main/backend/app/llm_client.py): `backend/app/llm_client.py`
- [MongoDB store](https://github.com/vishnukoushikkumara/dochelper/blob/main/backend/app/mongo_client.py): `backend/app/mongo_client.py`
- [Service dependencies](https://github.com/vishnukoushikkumara/dochelper/blob/main/backend/app/deps.py): `backend/app/deps.py`
- [Configuration](https://github.com/vishnukoushikkumara/dochelper/blob/main/backend/app/config.py): `backend/app/config.py`

### Other components

- **User**
- **Groq API**
- **MongoDB**

## Connections

- User → PDF upload: selects PDF (evidence: `frontend/src/components/Upload.jsx`)
- User → Chat: asks question (evidence: `frontend/src/components/Chat.jsx`)
- App shell → PDF upload: renders (evidence: `frontend/src/App.jsx`)
- App shell → Document library: renders (evidence: `frontend/src/App.jsx`)
- App shell → Chat: renders (evidence: `frontend/src/App.jsx`)
- App shell → API client: lists documents (evidence: `frontend/src/App.jsx`)
- PDF upload → API client: uploads PDF (evidence: `frontend/src/components/Upload.jsx`)
- Chat → API client: streams chat (evidence: `frontend/src/components/Chat.jsx`)
- Chat → Sources and steps: renders sources (evidence: `frontend/src/components/Chat.jsx`)
- Chat → Agent steps view: renders trace (evidence: `frontend/src/components/Chat.jsx`)
- API client → Upload route: POST /upload (evidence: `frontend/src/api.js`)
- API client → Documents route: GET /documents (evidence: `frontend/src/api.js`)
- API client → Chat route: POST /chat (evidence: `frontend/src/api.js`)
- Upload route → PDF parser: parses PDF (evidence: `backend/app/routes_upload.py`)
- Upload route → Text chunker: chunks text (evidence: `backend/app/routes_upload.py`)
- Upload route → Embedding model: encodes chunks (evidence: `backend/app/routes_upload.py`)
- Upload route → MongoDB store: persists document (evidence: `backend/app/routes_upload.py`)
- Upload route → LLM client: summarizes text (evidence: `backend/app/routes_upload.py`)
- Upload route → Service dependencies: resolves services (evidence: `backend/app/routes_upload.py`)
- Documents route → MongoDB store: lists documents (evidence: `backend/app/routes_documents.py`)
- Documents route → Service dependencies: resolves store (evidence: `backend/app/routes_documents.py`)
- Chat route → Chat agent graph: runs graph (evidence: `backend/app/routes_chat.py`)
- Chat route → Service dependencies: resolves services (evidence: `backend/app/routes_chat.py`)
- Chat route → API schemas: accepts request (evidence: `backend/app/routes_chat.py`)
- Chat agent graph → Embedding model: uses embeddings (evidence: `backend/app/agent_graph.py`)
- Chat agent graph → MongoDB store: searches chunks (evidence: `backend/app/agent_graph.py`)
- Chat agent graph → LLM client: generates answer (evidence: `backend/app/agent_graph.py`)
- Service dependencies → MongoDB store: creates store (evidence: `backend/app/deps.py`)
- Service dependencies → Embedding model: gets embedder (evidence: `backend/app/deps.py`)
- Service dependencies → LLM client: creates client (evidence: `backend/app/deps.py`)
- MongoDB store → MongoDB: reads and writes (evidence: `backend/app/mongo_client.py`)
- LLM client → Groq API: requests completions (evidence: `backend/app/llm_client.py`)
- Service dependencies → Configuration: reads settings (evidence: `backend/app/deps.py`)
