# jagratadeb/docchat architecture

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

- Interactive diagram: https://gitdiagram.com/jagratadeb/docchat
- Repository: https://github.com/jagratadeb/docchat

## Overview

DocChat is a Streamlit document-question-answering app. Users enter through Home, upload up to five PDF, TXT, or Markdown files in Chat, prepare them for local per-file search, ask a question, and see a grounded answer with available file/page references. The main runtime is concentrated in `app_pages/chat.py` and `rag_pipeline.py`; the graph separates its ingestion, indexing, retrieval, and generation stages. Architecture and Privacy & Security are user-facing informational pages. Pipeline details are based on the sampled source and README; unsampled styling and page internals are represented only at the supported module level.

Main entry points: [`app_pages/chat.py`](https://github.com/jagratadeb/docchat/blob/main/app_pages/chat.py) (Chat workspace), [`app.py`](https://github.com/jagratadeb/docchat/blob/main/app.py) (Streamlit navigation), [`rag_pipeline.py`](https://github.com/jagratadeb/docchat/blob/main/rag_pipeline.py) (Answer generation), [`styles.py`](https://github.com/jagratadeb/docchat/blob/main/styles.py) (Shared styling)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_navigation["Navigation and pages"]
  node_app["Streamlit navigation<br/>[app.py]"]
  node_home["Home page<br/>[home.py]"]
  node_architecture["Architecture page<br/>[architecture.py]"]
  node_security["Privacy &amp; Security<br/>[security.py]"]
end

subgraph group_chat["Chat workflow"]
  node_chat_ui["Chat workspace<br/>[chat.py]"]
  node_ingestion["File ingestion<br/>[rag_pipeline.py]"]
  node_session["Visit session state<br/>[chat.py]"]
  node_sources["Answer references<br/>[chat.py]"]
end

subgraph group_retrieval["Local retrieval"]
  node_chunking["Text chunking<br/>[rag_pipeline.py]"]
  node_embeddings["Local embeddings<br/>[rag_pipeline.py]"]
  node_faiss[("Per-file FAISS indexes<br/>[rag_pipeline.py]")]
  node_retrieval_step["Per-file search<br/>[rag_pipeline.py]"]
end

subgraph group_generation["Answer generation"]
  node_llm_setup["Groq model setup<br/>[rag_pipeline.py]"]
  node_groq{{"Groq chat model"}}
  node_answer["Answer generation<br/>[rag_pipeline.py]"]
end

subgraph group_presentation["Presentation and guidance"]
  node_styles["Shared styling<br/>[styles.py]"]
end

node_user(("User"))

node_user -->|"opens app"| node_app
node_app -->|"routes to"| node_home
node_app -->|"routes to"| node_chat_ui
node_app -->|"routes to"| node_architecture
node_app -->|"routes to"| node_security
node_home -->|"switches page"| node_chat_ui
node_user -->|"uploads and asks"| node_chat_ui
node_chat_ui -->|"loads files"| node_ingestion
node_ingestion -->|"provides documents"| node_chunking
node_chunking -->|"requests vectors"| node_embeddings
node_chunking -->|"builds indexes"| node_faiss
node_chat_ui -->|"builds model"| node_llm_setup
node_chat_ui -->|"submits question"| node_answer
node_answer -->|"retrieves context"| node_retrieval_step
node_retrieval_step -->|"searches each index"| node_faiss
node_answer -->|"invokes model"| node_groq
node_llm_setup -->|"configures client"| node_groq
node_answer -->|"returns answer and sources"| node_chat_ui
node_chat_ui -->|"stores chat history"| node_session
node_chat_ui -->|"shows source parts"| node_sources
node_chat_ui -->|"applies styling"| node_styles
node_home -->|"applies styling"| node_styles
node_architecture -->|"applies styling"| node_styles
node_security -->|"applies styling"| node_styles

click node_app "https://github.com/jagratadeb/docchat/blob/main/app.py"
click node_home "https://github.com/jagratadeb/docchat/blob/main/app_pages/home.py"
click node_chat_ui "https://github.com/jagratadeb/docchat/blob/main/app_pages/chat.py"
click node_architecture "https://github.com/jagratadeb/docchat/blob/main/app_pages/architecture.py"
click node_security "https://github.com/jagratadeb/docchat/blob/main/app_pages/security.py"
click node_ingestion "https://github.com/jagratadeb/docchat/blob/main/rag_pipeline.py"
click node_chunking "https://github.com/jagratadeb/docchat/blob/main/rag_pipeline.py"
click node_embeddings "https://github.com/jagratadeb/docchat/blob/main/rag_pipeline.py"
click node_faiss "https://github.com/jagratadeb/docchat/blob/main/rag_pipeline.py"
click node_retrieval_step "https://github.com/jagratadeb/docchat/blob/main/rag_pipeline.py"
click node_llm_setup "https://github.com/jagratadeb/docchat/blob/main/rag_pipeline.py"
click node_answer "https://github.com/jagratadeb/docchat/blob/main/rag_pipeline.py"
click node_session "https://github.com/jagratadeb/docchat/blob/main/app_pages/chat.py"
click node_sources "https://github.com/jagratadeb/docchat/blob/main/app_pages/chat.py"
click node_styles "https://github.com/jagratadeb/docchat/blob/main/styles.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_home,node_architecture,node_security,node_user toneBlue
class node_chat_ui,node_ingestion,node_session,node_sources toneAmber
class node_chunking,node_embeddings,node_faiss,node_retrieval_step toneMint
class node_llm_setup,node_groq,node_answer toneRose
class node_styles toneIndigo
```

## Components

### Navigation and pages

- [Streamlit navigation](https://github.com/jagratadeb/docchat/blob/main/app.py): `app.py`
- [Home page](https://github.com/jagratadeb/docchat/blob/main/app_pages/home.py): `app_pages/home.py`
- [Architecture page](https://github.com/jagratadeb/docchat/blob/main/app_pages/architecture.py): `app_pages/architecture.py`
- [Privacy & Security](https://github.com/jagratadeb/docchat/blob/main/app_pages/security.py): `app_pages/security.py`

### Chat workflow

- [Chat workspace](https://github.com/jagratadeb/docchat/blob/main/app_pages/chat.py): `app_pages/chat.py`
- [File ingestion](https://github.com/jagratadeb/docchat/blob/main/rag_pipeline.py): `rag_pipeline.py`
- [Visit session state](https://github.com/jagratadeb/docchat/blob/main/app_pages/chat.py): `app_pages/chat.py`
- [Answer references](https://github.com/jagratadeb/docchat/blob/main/app_pages/chat.py): `app_pages/chat.py`

### Local retrieval

- [Text chunking](https://github.com/jagratadeb/docchat/blob/main/rag_pipeline.py): `rag_pipeline.py`
- [Local embeddings](https://github.com/jagratadeb/docchat/blob/main/rag_pipeline.py): `rag_pipeline.py`
- [Per-file FAISS indexes](https://github.com/jagratadeb/docchat/blob/main/rag_pipeline.py): `rag_pipeline.py`
- [Per-file search](https://github.com/jagratadeb/docchat/blob/main/rag_pipeline.py): `rag_pipeline.py`

### Answer generation

- [Groq model setup](https://github.com/jagratadeb/docchat/blob/main/rag_pipeline.py): `rag_pipeline.py`
- **Groq chat model**
- [Answer generation](https://github.com/jagratadeb/docchat/blob/main/rag_pipeline.py): `rag_pipeline.py`

### Presentation and guidance

- [Shared styling](https://github.com/jagratadeb/docchat/blob/main/styles.py): `styles.py`

### Other components

- **User**

## Connections

- User → Streamlit navigation: opens app (evidence: `app.py`)
- Streamlit navigation → Home page: routes to (evidence: `app.py`)
- Streamlit navigation → Chat workspace: routes to (evidence: `app.py`)
- Streamlit navigation → Architecture page: routes to (evidence: `app.py`)
- Streamlit navigation → Privacy & Security: routes to (evidence: `app.py`)
- Home page → Chat workspace: switches page (evidence: `app_pages/home.py`)
- User → Chat workspace: uploads and asks (evidence: `app_pages/chat.py`)
- Chat workspace → File ingestion: loads files (evidence: `app_pages/chat.py`)
- File ingestion → Text chunking: provides documents (evidence: `rag_pipeline.py`)
- Text chunking → Local embeddings: requests vectors (evidence: `rag_pipeline.py`)
- Text chunking → Per-file FAISS indexes: builds indexes (evidence: `rag_pipeline.py`)
- Chat workspace → Groq model setup: builds model (evidence: `app_pages/chat.py`)
- Chat workspace → Answer generation: submits question (evidence: `app_pages/chat.py`)
- Answer generation → Per-file search: retrieves context (evidence: `rag_pipeline.py`)
- Per-file search → Per-file FAISS indexes: searches each index (evidence: `rag_pipeline.py`)
- Answer generation → Groq chat model: invokes model (evidence: `rag_pipeline.py`)
- Groq model setup → Groq chat model: configures client (evidence: `rag_pipeline.py`)
- Answer generation → Chat workspace: returns answer and sources (evidence: `app_pages/chat.py`)
- Chat workspace → Visit session state: stores chat history (evidence: `app_pages/chat.py`)
- Chat workspace → Answer references: shows source parts (evidence: `app_pages/chat.py`)
- Chat workspace → Shared styling: applies styling (evidence: `app_pages/chat.py`)
- Home page → Shared styling: applies styling (evidence: `app_pages/home.py`)
- Architecture page → Shared styling: applies styling (evidence: `app_pages/architecture.py`)
- Privacy & Security → Shared styling: applies styling (evidence: `app_pages/security.py`)
