# vijaykumargadm/pdf-reader architecture

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

- Interactive diagram: https://gitdiagram.com/vijaykumargadm/pdf-reader
- Repository: https://github.com/vijaykumargadm/pdf-reader

## Overview

pdf-reader is a local PDF summarization and document-chat application with Streamlit and CLI entry points. Users provide PDFs, which are extracted, cleaned, optionally OCR-transcribed, chunked, summarized, and optionally analyzed for structure and quotes. The UI also supports citation-grounded RAG chat and displays token and estimated-cost accounting. The README documents capabilities whose implementation files were not sampled; their edges are cited to that documentation rather than implying source inspection.

Main entry points: [`pipeline.py`](https://github.com/vijaykumargadm/pdf-reader/blob/main/pipeline.py) (Summary orchestration), [`app.py`](https://github.com/vijaykumargadm/pdf-reader/blob/main/app.py) (Streamlit UI), [`summarizer.py`](https://github.com/vijaykumargadm/pdf-reader/blob/main/summarizer.py) (Map-reduce summaries), [`rag.py`](https://github.com/vijaykumargadm/pdf-reader/blob/main/rag.py) (Retrieval and grounded chat)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["User interfaces"]
  node_streamlit["Streamlit UI<br/>[app.py]"]
  node_cli["Command-line interface<br/>[cli.py]"]
end

subgraph group_document["PDF processing"]
  node_pipeline["Summary orchestration<br/>[pipeline.py]"]
  node_extract["Extraction and cleaning<br/>[pdf_processor.py]"]
  node_ocr["Page rendering and OCR<br/>[pdf_processor.py]"]
  node_chunk["Page-aware chunking<br/>[pdf_processor.py]"]
end

subgraph group_generation["Model generation"]
  node_mapreduce["Map-reduce summaries<br/>[summarizer.py]"]
  node_analysis["Structure analysis<br/>[summarizer.py]"]
  node_quotes["Verbatim quotes<br/>[summarizer.py]"]
  node_prompts["Prompt templates<br/>[prompts.py]"]
end

subgraph group_chat["Document chat"]
  node_rag["Retrieval and grounded chat<br/>[rag.py]"]
  node_chroma[("Persistent Chroma index")]
end

subgraph group_support["Configuration and accounting"]
  node_config["Settings and model pricing<br/>[config.py]"]
  node_ledger["Token and cost ledger<br/>[utils.py]"]
  node_logging["Logging and key masking<br/>[logging_setup.py]"]
end

node_user(("PDF user"))
node_gemini{{"Google Gemini"}}

node_user -->|"uploads PDFs"| node_streamlit
node_user -->|"submits PDF"| node_cli
node_streamlit -->|"summarizes uploads"| node_pipeline
node_cli -->|"runs summary"| node_pipeline
node_pipeline -->|"extracts pages"| node_extract
node_pipeline -->|"renders sparse pages"| node_ocr
node_pipeline -->|"chunks pages"| node_chunk
node_pipeline -->|"requests summaries"| node_mapreduce
node_pipeline -->|"requests analysis"| node_analysis
node_pipeline -->|"requests quotes"| node_quotes
node_mapreduce -->|"uses templates"| node_prompts
node_analysis -->|"uses templates"| node_prompts
node_quotes -->|"uses templates"| node_prompts
node_mapreduce -->|"generates summaries"| node_gemini
node_analysis -->|"analyzes document"| node_gemini
node_quotes -->|"extracts quotes"| node_gemini
node_ocr -->|"transcribes pages"| node_gemini
node_streamlit -->|"builds index and chats"| node_rag
node_rag -->|"stores vectors"| node_chroma
node_rag -->|"embeds and answers"| node_gemini
node_pipeline -->|"formats run cost"| node_ledger
node_mapreduce -->|"records usage"| node_ledger
node_streamlit -->|"loads settings"| node_config
node_streamlit -->|"configures logging"| node_logging
node_pipeline -->|"loads settings"| node_config

click node_streamlit "https://github.com/vijaykumargadm/pdf-reader/blob/main/app.py"
click node_cli "https://github.com/vijaykumargadm/pdf-reader/blob/main/cli.py"
click node_pipeline "https://github.com/vijaykumargadm/pdf-reader/blob/main/pipeline.py"
click node_extract "https://github.com/vijaykumargadm/pdf-reader/blob/main/pdf_processor.py"
click node_ocr "https://github.com/vijaykumargadm/pdf-reader/blob/main/pdf_processor.py"
click node_chunk "https://github.com/vijaykumargadm/pdf-reader/blob/main/pdf_processor.py"
click node_mapreduce "https://github.com/vijaykumargadm/pdf-reader/blob/main/summarizer.py"
click node_analysis "https://github.com/vijaykumargadm/pdf-reader/blob/main/summarizer.py"
click node_quotes "https://github.com/vijaykumargadm/pdf-reader/blob/main/summarizer.py"
click node_prompts "https://github.com/vijaykumargadm/pdf-reader/blob/main/prompts.py"
click node_rag "https://github.com/vijaykumargadm/pdf-reader/blob/main/rag.py"
click node_config "https://github.com/vijaykumargadm/pdf-reader/blob/main/config.py"
click node_ledger "https://github.com/vijaykumargadm/pdf-reader/blob/main/utils.py"
click node_logging "https://github.com/vijaykumargadm/pdf-reader/blob/main/logging_setup.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,node_cli,node_user toneBlue
class node_pipeline,node_extract,node_ocr,node_chunk toneAmber
class node_mapreduce,node_analysis,node_quotes,node_prompts toneMint
class node_rag,node_chroma toneRose
class node_config,node_ledger,node_logging,node_gemini toneIndigo
```

## Components

### User interfaces

- [Streamlit UI](https://github.com/vijaykumargadm/pdf-reader/blob/main/app.py): `app.py`
- [Command-line interface](https://github.com/vijaykumargadm/pdf-reader/blob/main/cli.py): `cli.py`

### PDF processing

- [Summary orchestration](https://github.com/vijaykumargadm/pdf-reader/blob/main/pipeline.py): `pipeline.py`
- [Extraction and cleaning](https://github.com/vijaykumargadm/pdf-reader/blob/main/pdf_processor.py): `pdf_processor.py`
- [Page rendering and OCR](https://github.com/vijaykumargadm/pdf-reader/blob/main/pdf_processor.py): `pdf_processor.py`
- [Page-aware chunking](https://github.com/vijaykumargadm/pdf-reader/blob/main/pdf_processor.py): `pdf_processor.py`

### Model generation

- [Map-reduce summaries](https://github.com/vijaykumargadm/pdf-reader/blob/main/summarizer.py): `summarizer.py`
- [Structure analysis](https://github.com/vijaykumargadm/pdf-reader/blob/main/summarizer.py): `summarizer.py`
- [Verbatim quotes](https://github.com/vijaykumargadm/pdf-reader/blob/main/summarizer.py): `summarizer.py`
- [Prompt templates](https://github.com/vijaykumargadm/pdf-reader/blob/main/prompts.py): `prompts.py`

### Document chat

- [Retrieval and grounded chat](https://github.com/vijaykumargadm/pdf-reader/blob/main/rag.py): `rag.py`
- **Persistent Chroma index**

### Configuration and accounting

- [Settings and model pricing](https://github.com/vijaykumargadm/pdf-reader/blob/main/config.py): `config.py`
- [Token and cost ledger](https://github.com/vijaykumargadm/pdf-reader/blob/main/utils.py): `utils.py`
- [Logging and key masking](https://github.com/vijaykumargadm/pdf-reader/blob/main/logging_setup.py): `logging_setup.py`

### Other components

- **PDF user**
- **Google Gemini**

## Connections

- PDF user → Streamlit UI: uploads PDFs (evidence: `README.md`)
- PDF user → Command-line interface: submits PDF (evidence: `README.md`)
- Streamlit UI → Summary orchestration: summarizes uploads (evidence: `app.py`)
- Command-line interface → Summary orchestration: runs summary (evidence: `README.md`)
- Summary orchestration → Extraction and cleaning: extracts pages (evidence: `pipeline.py`)
- Summary orchestration → Page rendering and OCR: renders sparse pages (evidence: `pipeline.py`)
- Summary orchestration → Page-aware chunking: chunks pages (evidence: `pipeline.py`)
- Summary orchestration → Map-reduce summaries: requests summaries (evidence: `pipeline.py`)
- Summary orchestration → Structure analysis: requests analysis (evidence: `pipeline.py`)
- Summary orchestration → Verbatim quotes: requests quotes (evidence: `pipeline.py`)
- Map-reduce summaries → Prompt templates: uses templates (evidence: `summarizer.py`)
- Structure analysis → Prompt templates: uses templates (evidence: `summarizer.py`)
- Verbatim quotes → Prompt templates: uses templates (evidence: `summarizer.py`)
- Map-reduce summaries → Google Gemini: generates summaries (evidence: `README.md`)
- Structure analysis → Google Gemini: analyzes document (evidence: `README.md`)
- Verbatim quotes → Google Gemini: extracts quotes (evidence: `README.md`)
- Page rendering and OCR → Google Gemini: transcribes pages (evidence: `README.md`)
- Streamlit UI → Retrieval and grounded chat: builds index and chats (evidence: `app.py`)
- Retrieval and grounded chat → Persistent Chroma index: stores vectors (evidence: `README.md`)
- Retrieval and grounded chat → Google Gemini: embeds and answers (evidence: `README.md`)
- Summary orchestration → Token and cost ledger: formats run cost (evidence: `pipeline.py`)
- Map-reduce summaries → Token and cost ledger: records usage (evidence: `summarizer.py`)
- Streamlit UI → Settings and model pricing: loads settings (evidence: `app.py`)
- Streamlit UI → Logging and key masking: configures logging (evidence: `app.py`)
- Summary orchestration → Settings and model pricing: loads settings (evidence: `pipeline.py`)
