# itssp00ky/pdf_enhancer architecture

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

- Interactive diagram: https://gitdiagram.com/itssp00ky/pdf_enhancer
- Repository: https://github.com/itssp00ky/pdf_enhancer

## Overview

PDF Enhancer is a local desktop app that takes PDFs and images, lets users choose DPI and preview the first item, then processes pages into a combined, compact PDF. Its principal flow runs from file selection through page loading and image enhancement to export; background workers keep the interface responsive. README-described geometry correction, drag-and-drop, and output compression are represented as capabilities of the single-file runtime. The source is concentrated in main.py; omitted excerpts limit confidence in some internal call relationships.

Main entry points: [`main.py`](https://github.com/itssp00ky/pdf_enhancer/blob/main/main.py) (File selection)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Desktop interface"]
  node_app["Scanner app<br/>[main.py]"]
  node_selection["File selection<br/>[main.py]"]
  node_preview["First-page preview<br/>[main.py]"]
  node_worker["Background workers<br/>[main.py]"]
end

subgraph group_input["Document input"]
  node_source_pages["Page loading<br/>[main.py]"]
  node_pdf_render["PDF rendering<br/>[main.py]"]
  node_image_load["Image loading<br/>[main.py]"]
end

subgraph group_processing["Page processing"]
  node_geometry["Geometry correction<br/>[main.py]"]
  node_enhancement["Binarization<br/>[main.py]"]
  node_page_processing["Page processing<br/>[main.py]"]
end

subgraph group_output["PDF output"]
  node_pdf_export["PDF export<br/>[main.py]"]
  node_output_pdf["Enhanced PDF"]
end

node_user(("User"))

node_user -->|"uses"| node_app
node_app -->|"offers"| node_selection
node_user -->|"selects files"| node_selection
node_user -->|"drops files"| node_selection
node_selection -->|"requests preview"| node_preview
node_selection -->|"starts conversion"| node_worker
node_preview -.->|"previews first item"| node_source_pages
node_worker -->|"iterates pages"| node_source_pages
node_source_pages -->|"renders PDF pages"| node_pdf_render
node_source_pages -->|"loads image files"| node_image_load
node_worker -->|"processes each page"| node_page_processing
node_page_processing -.->|"corrects geometry"| node_geometry
node_page_processing -.->|"enhances contrast"| node_enhancement
node_worker -.->|"exports pages"| node_pdf_export
node_pdf_export -.->|"writes PDF"| node_output_pdf

click node_app "https://github.com/itssp00ky/pdf_enhancer/blob/main/main.py"
click node_selection "https://github.com/itssp00ky/pdf_enhancer/blob/main/main.py"
click node_preview "https://github.com/itssp00ky/pdf_enhancer/blob/main/main.py"
click node_worker "https://github.com/itssp00ky/pdf_enhancer/blob/main/main.py"
click node_source_pages "https://github.com/itssp00ky/pdf_enhancer/blob/main/main.py"
click node_pdf_render "https://github.com/itssp00ky/pdf_enhancer/blob/main/main.py"
click node_image_load "https://github.com/itssp00ky/pdf_enhancer/blob/main/main.py"
click node_geometry "https://github.com/itssp00ky/pdf_enhancer/blob/main/main.py"
click node_enhancement "https://github.com/itssp00ky/pdf_enhancer/blob/main/main.py"
click node_page_processing "https://github.com/itssp00ky/pdf_enhancer/blob/main/main.py"
click node_pdf_export "https://github.com/itssp00ky/pdf_enhancer/blob/main/main.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_selection,node_preview,node_worker,node_user toneBlue
class node_source_pages,node_pdf_render,node_image_load toneAmber
class node_geometry,node_enhancement,node_page_processing toneMint
class node_pdf_export,node_output_pdf toneRose
```

## Components

### Desktop interface

- [Scanner app](https://github.com/itssp00ky/pdf_enhancer/blob/main/main.py): `main.py`
- [File selection](https://github.com/itssp00ky/pdf_enhancer/blob/main/main.py): `main.py`
- [First-page preview](https://github.com/itssp00ky/pdf_enhancer/blob/main/main.py): `main.py`
- [Background workers](https://github.com/itssp00ky/pdf_enhancer/blob/main/main.py): `main.py`

### Document input

- [Page loading](https://github.com/itssp00ky/pdf_enhancer/blob/main/main.py): `main.py`
- [PDF rendering](https://github.com/itssp00ky/pdf_enhancer/blob/main/main.py): `main.py`
- [Image loading](https://github.com/itssp00ky/pdf_enhancer/blob/main/main.py): `main.py`

### Page processing

- [Geometry correction](https://github.com/itssp00ky/pdf_enhancer/blob/main/main.py): `main.py`
- [Binarization](https://github.com/itssp00ky/pdf_enhancer/blob/main/main.py): `main.py`
- [Page processing](https://github.com/itssp00ky/pdf_enhancer/blob/main/main.py): `main.py`

### PDF output

- [PDF export](https://github.com/itssp00ky/pdf_enhancer/blob/main/main.py): `main.py`
- **Enhanced PDF**

### Other components

- **User**

## Connections

- User → Scanner app: uses (evidence: `README.md`)
- Scanner app → File selection: offers (evidence: `main.py`)
- User → File selection: selects files (evidence: `README.md`)
- User → File selection: drops files (evidence: `README.md`)
- File selection → First-page preview: requests preview (evidence: `README.md`)
- File selection → Background workers: starts conversion (evidence: `main.py`)
- First-page preview → Page loading: previews first item (evidence: `main.py`)
- Background workers → Page loading: iterates pages (evidence: `main.py`)
- Page loading → PDF rendering: renders PDF pages (evidence: `main.py`)
- Page loading → Image loading: loads image files (evidence: `main.py`)
- Background workers → Page processing: processes each page (evidence: `main.py`)
- Page processing → Geometry correction: corrects geometry (evidence: `main.py`)
- Page processing → Binarization: enhances contrast (evidence: `main.py`)
- Background workers → PDF export: exports pages (evidence: `main.py`)
- PDF export → Enhanced PDF: writes PDF
