# kishorebala896/docuchat architecture

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

- Interactive diagram: https://gitdiagram.com/kishorebala896/docuchat
- Repository: https://github.com/kishorebala896/docuchat

## Overview

DocuChat lets a user upload a PDF, then chat with it using answers grounded in document passages and page citations. The API accepts uploads and starts ingestion; ingestion extracts and chunks text, embeds it, indexes it, and creates a summary. For questions, the API coordinates hybrid retrieval, an abstention decision, and LLM answer generation, while persisting conversation history. The UI, optional Celery/Redis ingestion, provider choices, and document inspection are additional product capabilities. Relationships for unsampled endpoint details follow README documentation; uncertain internal calls are omitted.

Main entry points: [`backend/main.py`](https://github.com/kishorebala896/docuchat/blob/main/backend/main.py) (FastAPI), [`backend/pipeline.py`](https://github.com/kishorebala896/docuchat/blob/main/backend/pipeline.py) (Ingestion pipeline), [`backend/retrieval.py`](https://github.com/kishorebala896/docuchat/blob/main/backend/retrieval.py) (Hybrid retrieval), [`backend/llm.py`](https://github.com/kishorebala896/docuchat/blob/main/backend/llm.py) (LLM answers and summaries)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["User experience"]
  node_ui["Streamlit UI<br/>[app.py]"]
end

subgraph group_api["API and orchestration"]
  node_api_service["FastAPI<br/>[main.py]"]
  node_schemas["API schemas<br/>[schemas.py]"]
  node_config["Configuration<br/>[config.py]"]
  node_debug["Debug stops<br/>[debug.py]"]
end

subgraph group_ingest["Document ingestion"]
  node_ingestion["Ingestion pipeline<br/>[pipeline.py]"]
  node_worker["Celery worker<br/>[worker.py]"]
  node_embeddings["Embedding providers<br/>[embeddings.py]"]
end

subgraph group_qa["Grounded Q&amp;A and storage"]
  node_vectors[("Vector index<br/>[vectorstore.py]")]
  node_retrieval["Hybrid retrieval<br/>[retrieval.py]"]
  node_generation["LLM answers and summaries<br/>[llm.py]"]
  node_relational[("Relational data<br/>[models.py]")]
  node_db_access["Database access<br/>[database.py]"]
end

node_user(("User"))
node_queue["Redis broker"]
node_pdf["PDF document"]
node_llm_provider{{"LLM provider"}}
node_embedding_provider{{"Hosted embedding provider"}}

node_user -->|"uses"| node_ui
node_ui -->|"calls API"| node_api_service
node_user -->|"uploads"| node_pdf
node_api_service -->|"starts ingestion"| node_ingestion
node_ingestion -->|"parses and chunks"| node_pdf
node_ingestion -->|"embeds chunks"| node_embeddings
node_ingestion -->|"indexes chunks"| node_vectors
node_ingestion -->|"creates summary"| node_generation
node_api_service -.->|"dispatches optionally"| node_worker
node_api_service -->|"stores document and chat state"| node_relational
node_db_access -->|"maps SQL tables"| node_relational
node_worker -->|"uses broker"| node_queue
node_api_service -->|"retrieves for questions"| node_retrieval
node_retrieval -->|"embeds query"| node_embeddings
node_retrieval -->|"searches dense index"| node_vectors
node_retrieval -->|"supplies passages"| node_generation
node_api_service -->|"requests grounded answer"| node_generation
node_generation -->|"calls configured provider"| node_llm_provider
node_embeddings -.->|"calls when configured"| node_embedding_provider
node_api_service -->|"validates API shapes"| node_schemas
node_api_service -->|"reads settings"| node_config
node_ingestion -->|"reads settings"| node_config
node_ui -->|"supports named stop"| node_debug

click node_ui "https://github.com/kishorebala896/docuchat/blob/main/frontend/app.py"
click node_api_service "https://github.com/kishorebala896/docuchat/blob/main/backend/main.py"
click node_schemas "https://github.com/kishorebala896/docuchat/blob/main/backend/schemas.py"
click node_config "https://github.com/kishorebala896/docuchat/blob/main/backend/config.py"
click node_debug "https://github.com/kishorebala896/docuchat/blob/main/backend/debug.py"
click node_ingestion "https://github.com/kishorebala896/docuchat/blob/main/backend/pipeline.py"
click node_worker "https://github.com/kishorebala896/docuchat/blob/main/backend/worker.py"
click node_embeddings "https://github.com/kishorebala896/docuchat/blob/main/backend/embeddings.py"
click node_vectors "https://github.com/kishorebala896/docuchat/blob/main/backend/vectorstore.py"
click node_retrieval "https://github.com/kishorebala896/docuchat/blob/main/backend/retrieval.py"
click node_generation "https://github.com/kishorebala896/docuchat/blob/main/backend/llm.py"
click node_relational "https://github.com/kishorebala896/docuchat/blob/main/backend/models.py"
click node_db_access "https://github.com/kishorebala896/docuchat/blob/main/backend/database.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_ui,node_user toneBlue
class node_api_service,node_schemas,node_config,node_debug,node_queue toneAmber
class node_ingestion,node_worker,node_embeddings toneMint
class node_vectors,node_retrieval,node_generation,node_relational,node_db_access toneRose
class node_pdf,node_llm_provider,node_embedding_provider toneIndigo
```

## Components

### User experience

- [Streamlit UI](https://github.com/kishorebala896/docuchat/blob/main/frontend/app.py): `frontend/app.py`

### API and orchestration

- [FastAPI](https://github.com/kishorebala896/docuchat/blob/main/backend/main.py): `backend/main.py`
- [API schemas](https://github.com/kishorebala896/docuchat/blob/main/backend/schemas.py): `backend/schemas.py`
- [Configuration](https://github.com/kishorebala896/docuchat/blob/main/backend/config.py): `backend/config.py`
- [Debug stops](https://github.com/kishorebala896/docuchat/blob/main/backend/debug.py): `backend/debug.py`

### Document ingestion

- [Ingestion pipeline](https://github.com/kishorebala896/docuchat/blob/main/backend/pipeline.py): `backend/pipeline.py`
- [Celery worker](https://github.com/kishorebala896/docuchat/blob/main/backend/worker.py): `backend/worker.py`
- [Embedding providers](https://github.com/kishorebala896/docuchat/blob/main/backend/embeddings.py): `backend/embeddings.py`

### Grounded Q&A and storage

- [Vector index](https://github.com/kishorebala896/docuchat/blob/main/backend/vectorstore.py): `backend/vectorstore.py`
- [Hybrid retrieval](https://github.com/kishorebala896/docuchat/blob/main/backend/retrieval.py): `backend/retrieval.py`
- [LLM answers and summaries](https://github.com/kishorebala896/docuchat/blob/main/backend/llm.py): `backend/llm.py`
- [Relational data](https://github.com/kishorebala896/docuchat/blob/main/backend/models.py): `backend/models.py`
- [Database access](https://github.com/kishorebala896/docuchat/blob/main/backend/database.py): `backend/database.py`

### Other components

- **User**
- **Redis broker**
- **PDF document**
- **LLM provider**
- **Hosted embedding provider**

## Connections

- User → Streamlit UI: uses (evidence: `README.md`)
- Streamlit UI → FastAPI: calls API (evidence: `README.md`)
- User → PDF document: uploads (evidence: `README.md`)
- FastAPI → Ingestion pipeline: starts ingestion (evidence: `README.md`)
- Ingestion pipeline → PDF document: parses and chunks (evidence: `README.md`)
- Ingestion pipeline → Embedding providers: embeds chunks (evidence: `README.md`)
- Ingestion pipeline → Vector index: indexes chunks (evidence: `backend/pipeline.py`)
- Ingestion pipeline → LLM answers and summaries: creates summary (evidence: `README.md`)
- FastAPI → Celery worker: dispatches optionally (evidence: `backend/main.py`)
- FastAPI → Relational data: stores document and chat state (evidence: `README.md`)
- Database access → Relational data: maps SQL tables (evidence: `backend/models.py`)
- Celery worker → Redis broker: uses broker (evidence: `backend/worker.py`)
- FastAPI → Hybrid retrieval: retrieves for questions (evidence: `README.md`)
- Hybrid retrieval → Embedding providers: embeds query (evidence: `README.md`)
- Hybrid retrieval → Vector index: searches dense index (evidence: `README.md`)
- Hybrid retrieval → LLM answers and summaries: supplies passages (evidence: `README.md`)
- FastAPI → LLM answers and summaries: requests grounded answer (evidence: `README.md`)
- LLM answers and summaries → LLM provider: calls configured provider (evidence: `README.md`)
- Embedding providers → Hosted embedding provider: calls when configured (evidence: `README.md`)
- FastAPI → API schemas: validates API shapes (evidence: `README.md`)
- FastAPI → Configuration: reads settings (evidence: `backend/main.py`)
- Ingestion pipeline → Configuration: reads settings (evidence: `backend/pipeline.py`)
- Streamlit UI → Debug stops: supports named stop (evidence: `backend/debug.py`)
