# gugeldot/image-to-pdf architecture

> Architecture diagram of the GitHub repository gugeldot/image-to-pdf, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/gugeldot/image-to-pdf
- Repository: https://github.com/gugeldot/image-to-pdf

## Overview

##### Project type and purpose
- This is a desktop image‑to‑PDF conversion tool with a vintage GUI look, implemented in Python.
- Purpose: let users select a folder of images, define order and output PDF name, manage settings via a config file, and generate logs—all without uploading data online.

##### File structure
- Top‑level:
- ImgToPdfV7_GUI_Build/ – packaged Windows executable + runtime library + images
- source/ – pure‑Python source code and assets
- requirements.txt – Python dependencies
- README.md, LICENSE, .gitignore
- source/ contents:
- ImgToPdfGUI.py – main GUI entry point
- lib/ImgToPdf_V7.py – core conversion and merging logic
- config.json – default settings schema
- imgTpdf.log – runtime log file
- source/requirements.txt – same as top‑level requirements
- Build directory:
- ImgToPdfGUI.exe – compiled with PyInstaller
- lib/ImgToPdf_V7.py – bundled library
- Imgs/ – sample or bundled images

##### Key architectural insights from README
- GUI layer drives file‑selection, ordering, triggering conversion/merge.
- Core library (ImgToPdf_V7.py) handles:
- image validation
- PDF creation/merging
- config regeneration
- logging
- Config and logging are file‑based and reside alongside the executable or in source dir.

##### Main components
a. GUI Layer (ImgToPdfGUI.py / ImgToPdfGUI.exe)
b. Core Processing Library (ImgToPdf_V7.py)
c. File System
- Input Folder (images)
- Output PDF
- Config file (config.json)
- Log file (imgTpdf.log)
d. External Dependencies
- PIL / Pillow (image operations)
- PyPDF2 or reportlab (PDF generation)
- PyInstaller (build-time)
e. Build Artifacts
- Executable bundle
- Bundled library + assets

##### Relationships and data flow
- GUI → calls → Core Library
- Core Library ↔ reads/writes ↔ Config File
- Core Library ↔ reads ↔ Input Images
- Core Library → writes → Output PDF
- Core Library → appends → Log File
- Build Process (PyInstaller) → packages → GUI + Library + Assets → Executable

##### Architectural patterns and design principles
- Separation of concerns: UI logic separated from business logic.
- File‑based configuration and logging.
- Single responsibility for core conversion library.
- Simple layered architecture: Presentation → Processing → Persistence (file system).

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% GUI Layer
    subgraph "GUI Layer"
        GUI_Source["ImgToPdfGUI.py"]:::runtime
        GUI_Exe["ImgToPdfGUI.exe"]:::runtime
    end

    %% Core Library Layer
    subgraph "Core Library"
        Core_Source["ImgToPdf_V7.py (source)"]:::runtime
        Core_Bundled["ImgToPdf_V7.py (bundled)"]:::runtime
    end

    %% File System Layer
    subgraph "File System"
        Config["config.json"]:::fs
        Log["imgTpdf.log"]:::fs
        Input_Src["Imgs/ (source)"]:::fs
        Input_Build["Imgs/ (build)"]:::fs
        Output_PDF["Output PDF"]:::fs
        Icons["icons/"]:::fs
        Req_Root["requirements.txt"]:::fs
        Req_Source["source/requirements.txt"]:::fs
        Readme["README.md"]:::fs
        License["LICENSE"]:::fs
    end

    %% Build Process
    subgraph "Build Process"
        PyInstaller["PyInstaller"]:::build
        Build_Dir["ImgToPdfV7_GUI_Build/"]:::build
    end

    %% Relationships
    GUI_Source -->|"calls"| Core_Source
    GUI_Exe -->|"calls"| Core_Bundled
    Core_Source -->|"reads"| Input_Src
    Core_Source -->|"writes"| Output_PDF
    Core_Source -->|"appends"| Log
    Core_Source <-->|"reads/writes"| Config
    Core_Bundled -->|"reads"| Input_Build
    Core_Bundled -->|"writes"| Output_PDF
    Core_Bundled -->|"appends"| Log
    Core_Bundled <-->|"reads/writes"| Config

    PyInstaller -->|"packages"| Build_Dir
    Build_Dir --> GUI_Exe
    Build_Dir --> Core_Bundled
    Build_Dir --> Input_Build

    %% Click Events
    click GUI_Source "https://github.com/gugeldot/image-to-pdf/blob/main/source/ImgToPdfGUI.py"
    click GUI_Exe "https://github.com/gugeldot/image-to-pdf/blob/main/ImgToPdfV7_GUI_Build/ImgToPdfGUI.exe"
    click Core_Source "https://github.com/gugeldot/image-to-pdf/blob/main/source/lib/ImgToPdf_V7.py"
    click Core_Bundled "https://github.com/gugeldot/image-to-pdf/blob/main/ImgToPdfV7_GUI_Build/lib/ImgToPdf_V7.py"
    click Config "https://github.com/gugeldot/image-to-pdf/blob/main/source/config.json"
    click Log "https://github.com/gugeldot/image-to-pdf/blob/main/source/imgTpdf.log"
    click Input_Src "https://github.com/gugeldot/image-to-pdf/tree/main/source/Imgs/"
    click Input_Build "https://github.com/gugeldot/image-to-pdf/tree/main/ImgToPdfV7_GUI_Build/Imgs/"
    click Build_Dir "https://github.com/gugeldot/image-to-pdf/tree/main/ImgToPdfV7_GUI_Build/"
    click Req_Root "https://github.com/gugeldot/image-to-pdf/blob/main/requirements.txt"
    click Req_Source "https://github.com/gugeldot/image-to-pdf/blob/main/source/requirements.txt"
    click Icons "https://github.com/gugeldot/image-to-pdf/tree/main/icons/"
    click Readme "https://github.com/gugeldot/image-to-pdf/blob/main/README.md"
    click License "https://github.com/gugeldot/image-to-pdf/tree/main/LICENSE"

    %% Styles
    classDef runtime fill:#ADD8E6,stroke:#000,stroke-width:1px
    classDef fs fill:#90EE90,stroke:#000,stroke-width:1px
    classDef build fill:#FFA500,stroke:#000,stroke-width:1px
```
