# abirchakrabortty/chatpdf architecture

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

- Interactive diagram: https://gitdiagram.com/abirchakrabortty/chatpdf
- Repository: https://github.com/abirchakrabortty/chatpdf

## Overview

This repository is a Streamlit PDF question-answering app, accompanied by standalone scripts demonstrating progressively more of the LangChain workflow. The main app accepts a PDF, creates a per-document vector store, retrieves relevant chunks for a question, and displays the answer and source chunks while maintaining chat state. The excerpts establish the main app’s vector-store and retrieval-chain behavior; omitted sections limit certainty about some ingestion and UI connections. The standalone modules are independent examples, not demonstrated stages called by the app.

Main entry points: [`app.py`](https://github.com/abirchakrabortty/chatpdf/blob/main/app.py) (Chat interface), [`module_05_rag_chain.py`](https://github.com/abirchakrabortty/chatpdf/blob/main/module_05_rag_chain.py) (Complete RAG demo), [`module_04_connection.py`](https://github.com/abirchakrabortty/chatpdf/blob/main/module_04_connection.py) (Persistent store demo), [`module_01_connection.py`](https://github.com/abirchakrabortty/chatpdf/blob/main/module_01_connection.py) (Direct LLM demo)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["ChatPDF app"]
  node_interface["Chat interface<br/>[app.py]"]
  node_pdf_process["PDF processing<br/>[app.py]"]
  node_vector_store[("PDF vector store<br/>[app.py]")]
  node_retrieval["Chunk retrieval<br/>[app.py]"]
  node_rag_chain["RAG answer chain<br/>[app.py]"]
  node_chat_history["Chat history<br/>[app.py]"]
  node_source_chunks["Source chunks<br/>[app.py]"]
end

subgraph group_examples["Standalone examples"]
  node_basic_llm_demo["Direct LLM demo"]
  node_prompt_demo["Prompt chain demo"]
  node_chunk_demo["PDF chunking demo"]
  node_store_demo["Persistent store demo"]
  node_complete_rag_demo["Complete RAG demo"]
end

subgraph group_services["External services"]
  node_llm_service{{"Groq LLM"}}
  node_embedding_service{{"HuggingFace embeddings"}}
  node_pdf_loader["PDF loader"]
end

node_user(("PDF user"))

node_user -->|"uploads and asks"| node_interface
node_interface -->|"processes PDF"| node_pdf_process
node_pdf_process -->|"loads pages"| node_pdf_loader
node_pdf_process -->|"creates store"| node_vector_store
node_vector_store -->|"embeds chunks"| node_embedding_service
node_interface -->|"retrieves from"| node_vector_store
node_interface -->|"invokes chain"| node_rag_chain
node_rag_chain -->|"generates answer"| node_llm_service
node_interface -->|"stores messages"| node_chat_history
node_interface -->|"shows context"| node_source_chunks
node_basic_llm_demo -->|"invokes"| node_llm_service
node_prompt_demo -->|"calls through chain"| node_llm_service
node_chunk_demo -->|"loads PDF"| node_pdf_loader
node_store_demo -->|"loads PDF"| node_pdf_loader
node_store_demo -->|"creates and searches"| node_vector_store
node_store_demo -->|"embeds chunks"| node_embedding_service
node_complete_rag_demo -->|"loads PDF"| node_pdf_loader
node_complete_rag_demo -->|"creates store"| node_vector_store
node_complete_rag_demo -->|"embeds chunks"| node_embedding_service
node_complete_rag_demo -->|"answers questions"| node_llm_service

click node_interface "https://github.com/abirchakrabortty/chatpdf/blob/main/app.py"
click node_pdf_process "https://github.com/abirchakrabortty/chatpdf/blob/main/app.py"
click node_vector_store "https://github.com/abirchakrabortty/chatpdf/blob/main/app.py"
click node_retrieval "https://github.com/abirchakrabortty/chatpdf/blob/main/app.py"
click node_rag_chain "https://github.com/abirchakrabortty/chatpdf/blob/main/app.py"
click node_chat_history "https://github.com/abirchakrabortty/chatpdf/blob/main/app.py"
click node_source_chunks "https://github.com/abirchakrabortty/chatpdf/blob/main/app.py"
click node_basic_llm_demo "https://github.com/abirchakrabortty/chatpdf/blob/main/module_01_connection.py"
click node_prompt_demo "https://github.com/abirchakrabortty/chatpdf/blob/main/module_02_connection.py"
click node_chunk_demo "https://github.com/abirchakrabortty/chatpdf/blob/main/module_03_connection.py"
click node_store_demo "https://github.com/abirchakrabortty/chatpdf/blob/main/module_04_connection.py"
click node_complete_rag_demo "https://github.com/abirchakrabortty/chatpdf/blob/main/module_05_rag_chain.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_interface,node_pdf_process,node_vector_store,node_retrieval,node_rag_chain,node_chat_history,node_source_chunks,node_user toneBlue
class node_basic_llm_demo,node_prompt_demo,node_chunk_demo,node_store_demo,node_complete_rag_demo toneAmber
class node_llm_service,node_embedding_service,node_pdf_loader toneMint
```

## Components

### ChatPDF app

- [Chat interface](https://github.com/abirchakrabortty/chatpdf/blob/main/app.py): `app.py`
- [PDF processing](https://github.com/abirchakrabortty/chatpdf/blob/main/app.py): `app.py`
- [PDF vector store](https://github.com/abirchakrabortty/chatpdf/blob/main/app.py): `app.py`
- [Chunk retrieval](https://github.com/abirchakrabortty/chatpdf/blob/main/app.py): `app.py`
- [RAG answer chain](https://github.com/abirchakrabortty/chatpdf/blob/main/app.py): `app.py`
- [Chat history](https://github.com/abirchakrabortty/chatpdf/blob/main/app.py): `app.py`
- [Source chunks](https://github.com/abirchakrabortty/chatpdf/blob/main/app.py): `app.py`

### Standalone examples

- [Direct LLM demo](https://github.com/abirchakrabortty/chatpdf/blob/main/module_01_connection.py): `module_01_connection.py`
- [Prompt chain demo](https://github.com/abirchakrabortty/chatpdf/blob/main/module_02_connection.py): `module_02_connection.py`
- [PDF chunking demo](https://github.com/abirchakrabortty/chatpdf/blob/main/module_03_connection.py): `module_03_connection.py`
- [Persistent store demo](https://github.com/abirchakrabortty/chatpdf/blob/main/module_04_connection.py): `module_04_connection.py`
- [Complete RAG demo](https://github.com/abirchakrabortty/chatpdf/blob/main/module_05_rag_chain.py): `module_05_rag_chain.py`

### External services

- **Groq LLM**
- **HuggingFace embeddings**
- **PDF loader**

### Other components

- **PDF user**

## Connections

- PDF user → Chat interface: uploads and asks (evidence: `app.py`)
- Chat interface → PDF processing: processes PDF (evidence: `app.py`)
- PDF processing → PDF loader: loads pages (evidence: `app.py`)
- PDF processing → PDF vector store: creates store (evidence: `app.py`)
- PDF vector store → HuggingFace embeddings: embeds chunks (evidence: `app.py`)
- Chat interface → PDF vector store: retrieves from (evidence: `app.py`)
- Chat interface → RAG answer chain: invokes chain (evidence: `app.py`)
- RAG answer chain → Groq LLM: generates answer (evidence: `app.py`)
- Chat interface → Chat history: stores messages (evidence: `app.py`)
- Chat interface → Source chunks: shows context (evidence: `app.py`)
- Direct LLM demo → Groq LLM: invokes (evidence: `module_01_connection.py`)
- Prompt chain demo → Groq LLM: calls through chain (evidence: `module_02_connection.py`)
- PDF chunking demo → PDF loader: loads PDF (evidence: `module_03_connection.py`)
- Persistent store demo → PDF loader: loads PDF (evidence: `module_04_connection.py`)
- Persistent store demo → PDF vector store: creates and searches (evidence: `module_04_connection.py`)
- Persistent store demo → HuggingFace embeddings: embeds chunks (evidence: `module_04_connection.py`)
- Complete RAG demo → PDF loader: loads PDF (evidence: `module_05_rag_chain.py`)
- Complete RAG demo → PDF vector store: creates store (evidence: `module_05_rag_chain.py`)
- Complete RAG demo → HuggingFace embeddings: embeds chunks (evidence: `module_05_rag_chain.py`)
- Complete RAG demo → Groq LLM: answers questions (evidence: `module_05_rag_chain.py`)
