# codecortex/smartpdf architecture

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

- Interactive diagram: https://gitdiagram.com/codecortex/smartpdf
- Repository: https://github.com/codecortex/smartpdf

## Overview

This is a Streamlit AI PDF reader. Users upload PDFs, process their text into a searchable vector index, ask questions answered through conversational retrieval, and can separately generate summaries and view document statistics. The app also supports model settings and chat-history download. The README contains screenshots but no written capability details; the architecture is based on the sampled app source, so unsampled integrations are omitted.

Main entry points: [`app.py`](https://github.com/codecortex/smartpdf/blob/main/app.py) (Streamlit app), [`htmlTemplates.py`](https://github.com/codecortex/smartpdf/blob/main/htmlTemplates.py) (Chat templates)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["Streamlit interface"]
  node_app["Streamlit app<br/>[app.py]"]
  node_templates["Chat templates<br/>[htmlTemplates.py]"]
end

subgraph group_documents["Document processing"]
  node_pdf["PDF extraction<br/>[app.py]"]
  node_chunking["Text chunking<br/>[app.py]"]
  node_embeddings["Embeddings model"]
  node_vectorstore[("FAISS index<br/>[app.py]")]
  node_insights["Document insights<br/>[app.py]"]
end

subgraph group_assistant["AI assistance"]
  node_conversation["Retrieval chain<br/>[app.py]"]
  node_memory["Chat memory<br/>[app.py]"]
  node_summarizer["PDF summarizer<br/>[app.py]"]
  node_history["History download<br/>[app.py]"]
end

node_user(("User"))
node_gemini["Google Gemini"]

node_user -->|"uses"| node_app
node_app -->|"renders"| node_templates
node_app -->|"extracts"| node_pdf
node_pdf -->|"passes text"| node_chunking
node_app -->|"splits text"| node_chunking
node_app -->|"builds index"| node_vectorstore
node_vectorstore -->|"embeds chunks"| node_embeddings
node_app -->|"computes stats"| node_insights
node_app -->|"creates and queries"| node_conversation
node_conversation -->|"retrieves context"| node_vectorstore
node_conversation -->|"stores turns"| node_memory
node_conversation -->|"generates answers"| node_gemini
node_app -->|"requests summaries"| node_summarizer
node_summarizer -->|"summarizes text"| node_gemini
node_app -->|"offers download"| node_history
node_history -->|"downloads transcript"| node_user

click node_app "https://github.com/codecortex/smartpdf/blob/main/app.py"
click node_templates "https://github.com/codecortex/smartpdf/blob/main/htmlTemplates.py"
click node_pdf "https://github.com/codecortex/smartpdf/blob/main/app.py"
click node_chunking "https://github.com/codecortex/smartpdf/blob/main/app.py"
click node_vectorstore "https://github.com/codecortex/smartpdf/blob/main/app.py"
click node_insights "https://github.com/codecortex/smartpdf/blob/main/app.py"
click node_conversation "https://github.com/codecortex/smartpdf/blob/main/app.py"
click node_memory "https://github.com/codecortex/smartpdf/blob/main/app.py"
click node_summarizer "https://github.com/codecortex/smartpdf/blob/main/app.py"
click node_history "https://github.com/codecortex/smartpdf/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_app,node_templates,node_user toneBlue
class node_pdf,node_chunking,node_embeddings,node_vectorstore,node_insights toneAmber
class node_conversation,node_memory,node_summarizer,node_history toneMint
class node_gemini toneIndigo
```

## Components

### Streamlit interface

- [Streamlit app](https://github.com/codecortex/smartpdf/blob/main/app.py): `app.py`
- [Chat templates](https://github.com/codecortex/smartpdf/blob/main/htmlTemplates.py): `htmlTemplates.py`

### Document processing

- [PDF extraction](https://github.com/codecortex/smartpdf/blob/main/app.py): `app.py`
- [Text chunking](https://github.com/codecortex/smartpdf/blob/main/app.py): `app.py`
- **Embeddings model**
- [FAISS index](https://github.com/codecortex/smartpdf/blob/main/app.py): `app.py`
- [Document insights](https://github.com/codecortex/smartpdf/blob/main/app.py): `app.py`

### AI assistance

- [Retrieval chain](https://github.com/codecortex/smartpdf/blob/main/app.py): `app.py`
- [Chat memory](https://github.com/codecortex/smartpdf/blob/main/app.py): `app.py`
- [PDF summarizer](https://github.com/codecortex/smartpdf/blob/main/app.py): `app.py`
- [History download](https://github.com/codecortex/smartpdf/blob/main/app.py): `app.py`

### Other components

- **User**
- **Google Gemini**

## Connections

- User → Streamlit app: uses
- Streamlit app → Chat templates: renders
- Streamlit app → PDF extraction: extracts
- PDF extraction → Text chunking: passes text
- Streamlit app → Text chunking: splits text
- Streamlit app → FAISS index: builds index
- FAISS index → Embeddings model: embeds chunks
- Streamlit app → Document insights: computes stats
- Streamlit app → Retrieval chain: creates and queries
- Retrieval chain → FAISS index: retrieves context
- Retrieval chain → Chat memory: stores turns
- Retrieval chain → Google Gemini: generates answers
- Streamlit app → PDF summarizer: requests summaries
- PDF summarizer → Google Gemini: summarizes text
- Streamlit app → History download: offers download
- History download → User: downloads transcript
