# code-well0/docchatai architecture

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

- Interactive diagram: https://gitdiagram.com/code-well0/docchatai
- Repository: https://github.com/code-well0/docchatai

## Overview

DocChatAI is a Streamlit document Q&A and report-generation app. Users upload PDFs and build a knowledge base; the app loads and chunks documents, embeds them into a FAISS index, then supports a retrieval-grounded chat workflow and a separate structured-report workflow with text download. The central runtime is concentrated in app.py. The evaluation script is excluded because it is an offline evaluation utility, not part of the user-facing product. Relationships shown are limited to those explicit in the app excerpt and README.

Main entry points: [`app.py`](https://github.com/code-well0/docchatai/blob/main/app.py) (Streamlit UI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingestion["Document ingestion"]
  node_streamlit_ui["Streamlit UI<br/>[app.py]"]
  node_pdf_upload["PDF upload<br/>[app.py]"]
  node_pdf_loading["PDF loading<br/>[app.py]"]
  node_chunking["Document chunking<br/>[app.py]"]
  node_embeddings["HuggingFace embeddings<br/>[app.py]"]
  node_faiss_index[("FAISS vector index<br/>[app.py]")]
end

subgraph group_chat["RAG chat"]
  node_chat_query["Question entry<br/>[app.py]"]
  node_retriever["Vector retriever<br/>[app.py]"]
  node_qa_chain["RAG answer chain<br/>[app.py]"]
  node_gemini["Gemini LLM"]
  node_answer["Contextual answer<br/>[app.py]"]
end

subgraph group_reports["Report generation"]
  node_report_options["Report selection<br/>[app.py]"]
  node_report_chain["Summary report chain<br/>[app.py]"]
  node_report_output["Generated report<br/>[app.py]"]
  node_download["Text download<br/>[app.py]"]
end

node_user(("User"))

node_user -->|"uses"| node_streamlit_ui
node_streamlit_ui -->|"offers"| node_pdf_upload
node_pdf_upload -->|"loads PDFs"| node_pdf_loading
node_pdf_loading -->|"splits documents"| node_chunking
node_chunking -->|"indexes chunks"| node_faiss_index
node_embeddings -->|"embeds chunks"| node_faiss_index
node_streamlit_ui -->|"accepts question"| node_chat_query
node_chat_query -->|"queries"| node_retriever
node_faiss_index -->|"provides search"| node_retriever
node_retriever -->|"supplies context"| node_qa_chain
node_qa_chain -->|"generates answer"| node_gemini
node_qa_chain -->|"returns"| node_answer
node_streamlit_ui -->|"offers"| node_report_options
node_report_options -->|"starts"| node_report_chain
node_report_chain -->|"generates report"| node_gemini
node_report_chain -->|"returns"| node_report_output
node_report_output -->|"downloads as text"| node_download
node_user -->|"downloads"| node_download

click node_streamlit_ui "https://github.com/code-well0/docchatai/blob/main/app.py"
click node_pdf_upload "https://github.com/code-well0/docchatai/blob/main/app.py"
click node_pdf_loading "https://github.com/code-well0/docchatai/blob/main/app.py"
click node_chunking "https://github.com/code-well0/docchatai/blob/main/app.py"
click node_embeddings "https://github.com/code-well0/docchatai/blob/main/app.py"
click node_faiss_index "https://github.com/code-well0/docchatai/blob/main/app.py"
click node_chat_query "https://github.com/code-well0/docchatai/blob/main/app.py"
click node_retriever "https://github.com/code-well0/docchatai/blob/main/app.py"
click node_qa_chain "https://github.com/code-well0/docchatai/blob/main/app.py"
click node_answer "https://github.com/code-well0/docchatai/blob/main/app.py"
click node_report_options "https://github.com/code-well0/docchatai/blob/main/app.py"
click node_report_chain "https://github.com/code-well0/docchatai/blob/main/app.py"
click node_report_output "https://github.com/code-well0/docchatai/blob/main/app.py"
click node_download "https://github.com/code-well0/docchatai/blob/main/app.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_streamlit_ui,node_pdf_upload,node_pdf_loading,node_chunking,node_embeddings,node_faiss_index,node_user toneBlue
class node_chat_query,node_retriever,node_qa_chain,node_gemini,node_answer toneAmber
class node_report_options,node_report_chain,node_report_output,node_download toneMint
```

## Components

### Document ingestion

- [Streamlit UI](https://github.com/code-well0/docchatai/blob/main/app.py): `app.py`
- [PDF upload](https://github.com/code-well0/docchatai/blob/main/app.py): `app.py`
- [PDF loading](https://github.com/code-well0/docchatai/blob/main/app.py): `app.py`
- [Document chunking](https://github.com/code-well0/docchatai/blob/main/app.py): `app.py`
- [HuggingFace embeddings](https://github.com/code-well0/docchatai/blob/main/app.py): `app.py`
- [FAISS vector index](https://github.com/code-well0/docchatai/blob/main/app.py): `app.py`

### RAG chat

- [Question entry](https://github.com/code-well0/docchatai/blob/main/app.py): `app.py`
- [Vector retriever](https://github.com/code-well0/docchatai/blob/main/app.py): `app.py`
- [RAG answer chain](https://github.com/code-well0/docchatai/blob/main/app.py): `app.py`
- **Gemini LLM**
- [Contextual answer](https://github.com/code-well0/docchatai/blob/main/app.py): `app.py`

### Report generation

- [Report selection](https://github.com/code-well0/docchatai/blob/main/app.py): `app.py`
- [Summary report chain](https://github.com/code-well0/docchatai/blob/main/app.py): `app.py`
- [Generated report](https://github.com/code-well0/docchatai/blob/main/app.py): `app.py`
- [Text download](https://github.com/code-well0/docchatai/blob/main/app.py): `app.py`

### Other components

- **User**

## Connections

- User → Streamlit UI: uses (evidence: `README.md`)
- Streamlit UI → PDF upload: offers (evidence: `app.py`)
- PDF upload → PDF loading: loads PDFs (evidence: `app.py`)
- PDF loading → Document chunking: splits documents (evidence: `app.py`)
- Document chunking → FAISS vector index: indexes chunks (evidence: `app.py`)
- HuggingFace embeddings → FAISS vector index: embeds chunks (evidence: `app.py`)
- Streamlit UI → Question entry: accepts question (evidence: `app.py`)
- Question entry → Vector retriever: queries (evidence: `app.py`)
- FAISS vector index → Vector retriever: provides search (evidence: `app.py`)
- Vector retriever → RAG answer chain: supplies context (evidence: `app.py`)
- RAG answer chain → Gemini LLM: generates answer (evidence: `app.py`)
- RAG answer chain → Contextual answer: returns (evidence: `app.py`)
- Streamlit UI → Report selection: offers (evidence: `app.py`)
- Report selection → Summary report chain: starts (evidence: `app.py`)
- Summary report chain → Gemini LLM: generates report (evidence: `app.py`)
- Summary report chain → Generated report: returns (evidence: `app.py`)
- Generated report → Text download: downloads as text (evidence: `app.py`)
- User → Text download: downloads (evidence: `README.md`)
