# maosanhioro/pdfbinder architecture

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

- Interactive diagram: https://gitdiagram.com/maosanhioro/pdfbinder
- Repository: https://github.com/maosanhioro/pdfbinder

## Overview

##### Project Type and Purpose
- This is a standalone desktop GUI tool written in Python for Windows.
- It provides two main features: merging multiple PDFs into one and extracting specified pages into a new PDF.
- It uses tkinter for the user interface, PyPDF2 for PDF manipulation, and PyInstaller to bundle everything into a single Windows EXE.

##### File Structure Analysis
- Top-level scripts:
- pdfbinder_gui.py – the main entry point and UI controller
- pdf_merger.py – business logic for combining PDFs
- pdf_page_extractor.py – business logic for extracting pages
- build_exe_windows.bat / build_exe.sh – packaging scripts
- Support files: README.md, Windows_Setup_Guide.md, batch files for Windows setup, build_exe scripts for cross-platform packaging.
- Virtual environment directory (.venv) and .gitignore for dependency isolation and source control hygiene.

##### Key Insights from README
- Architecture is simple and monolithic: UI layer orchestrates two core modules.
- Dependencies: Python 3.6+, PyPDF2, tkinter, PyInstaller.
- Distribution: built as a single EXE on Windows, no external Python install required.
- Target user: non-technical employees who need an intuitive GUI.

a. Main Components
- UI Layer (Tkinter) – pdfbinder_gui.py
- Business Logic Layer – pdf_merger.py, pdf_page_extractor.py
- PDF Library – PyPDF2 (third-party)
- File System – Local folders for input/output
- Packaging Layer – PyInstaller bundle (dist/PdfBinder.exe)
- Build Scripts – batch and shell scripts for packaging
b. Relationships and Interactions
- UI Layer invokes Business Logic Layer when the user clicks “Merge” or “Extract.”
- Business Logic Layer calls PyPDF2 functions to manipulate PDF streams.
- Results are written to the File System.
- Build Scripts package UI Layer, Business Logic, PyPDF2, and Python runtime into an EXE.
c. Architectural Patterns and Principles
- Separation of Concerns: UI, business logic, and external library code are kept in separate modules.
- Monolithic Desktop App: all modules run in a single process.
- Batch-driven Packaging: scripts encapsulate build steps.
d. Key Technologies and Frameworks
- Python 3.13 runtime
- tkinter (UI)
- PyPDF2 (PDF processing)
- PyInstaller (EXE bundling)
- Windows OS and default fonts (Yu Gothic UI)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Actors and UI
    User["User"]:::actor
    pdfbinder_gui["pdfbinder_gui.py"]:::ui

    %% Business Logic
    pdf_merger["pdf_merger.py"]:::logic
    pdf_page_extractor["pdf_page_extractor.py"]:::logic

    %% Third-Party Library
    PyPDF2["PyPDF2"]:::third

    %% File System
    FS["Local File System"]:::fs

    %% Support Files
    subgraph "Support Files"
        README["README.md"]:::doc
        SetupGuide["Windows_Setup_Guide.md"]:::doc
        Venv[".venv/"]:::dev
        Gitignore[".gitignore"]:::dev
    end

    %% Packaging Workflow
    subgraph "Packaging Workflow"
        windows_script["build_exe_windows.bat"]:::script
        unix_script["build_exe.sh"]:::script
        PyInstaller["PyInstaller"]:::third
        exe["dist/PdfBinder.exe"]:::artifact
    end

    %% Relationships
    User -->|launches| pdfbinder_gui
    pdfbinder_gui -->|calls Merge| pdf_merger
    pdfbinder_gui -->|calls Extract| pdf_page_extractor
    pdf_merger -->|uses| PyPDF2
    pdf_page_extractor -->|uses| PyPDF2
    PyPDF2 -->|reads\/writes| FS

    windows_script -->|invokes| PyInstaller
    unix_script -->|invokes| PyInstaller
    PyInstaller -->|outputs| exe

    %% Click Events
    click pdfbinder_gui "https://github.com/maosanhioro/pdfbinder/blob/main/pdfbinder_gui.py"
    click pdf_merger "https://github.com/maosanhioro/pdfbinder/blob/main/pdf_merger.py"
    click pdf_page_extractor "https://github.com/maosanhioro/pdfbinder/blob/main/pdf_page_extractor.py"
    click windows_script "https://github.com/maosanhioro/pdfbinder/blob/main/build_exe_windows.bat"
    click unix_script "https://github.com/maosanhioro/pdfbinder/blob/main/build_exe.sh"
    click README "https://github.com/maosanhioro/pdfbinder/blob/main/README.md"
    click SetupGuide "https://github.com/maosanhioro/pdfbinder/blob/main/Windows_Setup_Guide.md"
    click Venv "https://github.com/maosanhioro/pdfbinder/tree/main/.venv/"
    click Gitignore "https://github.com/maosanhioro/pdfbinder/blob/main/.gitignore"

    %% Styles
    classDef actor fill:#FFD580,stroke:#D99600,color:#000;
    classDef ui fill:#A5D8FF,stroke:#2B7BB9,color:#000;
    classDef logic fill:#C6EFAA,stroke:#469108,color:#000;
    classDef third fill:#E0E0E0,stroke:#8A8A8A,color:#000;
    classDef fs fill:#FCE5CD,stroke:#D18B00,color:#000;
    classDef script fill:#EAD1DC,stroke:#C0007A,color:#000;
    classDef artifact fill:#FFE599,stroke:#BF9000,color:#000;
    classDef doc fill:#FFF2CC,stroke:#D6B656,color:#000;
    classDef dev fill:#D9D9D9,stroke:#7F7F7F,color:#000;
```
