# ciwga/pdftoolkit architecture

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

- Interactive diagram: https://gitdiagram.com/ciwga/pdftoolkit
- Repository: https://github.com/ciwga/pdftoolkit

## Overview

##### Project type and purpose
- PDF Toolkit is a Python-based desktop application offering both a GUI and a CLI for manipulating PDF files (merge, extract pages/images, edit metadata, convert images to PDF).
- It comprises three entrypoints: a GUI (`pdftoolkit.py`), a CLI (`pdftoolkit_cli.py`), and a core library module (`pdf_ops.py`).

##### File structure
- Top-level files:
- `pdftoolkit.py`: GUI launcher (Tkinter + drag-and-drop)
- `pdftoolkit_cli.py`: CLI entrypoint
- `pdf_ops.py`: Core PDF operations API
- `requirements.txt`: External dependencies
- No database—uses the local filesystem for reading/writing PDFs, images, JSON metadata.
- External libraries: `PyPDF2`, `pillow`, `tkinterdnd2`.

##### README
- Confirms architecture: separate GUI and CLI, both drive the same core logic.
- Lists features (metadata, page/image extraction, merging, conversion).
- Technology stack: Python 3.7+, PyPDF2, Pillow, TkinterDND2.

##### Detail
- Entrypoints and the core module as separate components.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer"
        GUI["GUI Layer\n(pdftoolkit.py)"]:::ui
        Assets["GUI Assets\n(assets/)"]:::ui
        CLI["CLI Layer\n(pdftoolkit_cli.py)"]:::ui
    end

    %% Core Layer
    Core["Core Logic\n(pdf_ops.py)"]:::core

    %% Infrastructure
    subgraph "Infrastructure"
        Req["requirements.txt"]:::manifest
        subgraph "External Libraries"
            PyPDF2["PyPDF2"]:::ext
            Pillow["Pillow"]:::ext
            DND["tkinterdnd2"]:::ext
        end
        FS[(Filesystem\nPDFs, images, JSON)]:::fs
    end

    %% Connections
    Assets -->|uses icons| GUI
    GUI -->|calls functions| Core
    CLI -->|calls functions| Core
    Core -->|uses| PyPDF2
    Core -->|uses| Pillow
    Core -->|uses| DND
    Core -->|reads/writes| FS
    Req -->|specifies| PyPDF2
    Req -->|specifies| Pillow
    Req -->|specifies| DND

    %% Click Events
    click GUI "https://github.com/ciwga/pdftoolkit/blob/main/pdftoolkit.py"
    click Assets "https://github.com/ciwga/pdftoolkit/tree/main/assets/"
    click CLI "https://github.com/ciwga/pdftoolkit/blob/main/pdftoolkit_cli.py"
    click Core "https://github.com/ciwga/pdftoolkit/blob/main/pdf_ops.py"
    click Req "https://github.com/ciwga/pdftoolkit/blob/main/requirements.txt"

    %% Styles
    classDef ui fill:#cce5ff,stroke:#004085,color:#004085,stroke-width:1px;
    classDef core fill:#d4edda,stroke:#155724,color:#155724,stroke-width:1px;
    classDef ext fill:#fff3cd,stroke:#856404,color:#856404,stroke-width:1px;
    classDef fs fill:#e2e3e5,stroke:#6c757d,color:#6c757d,stroke-width:1px;
    classDef manifest fill:#f8d7da,stroke:#721c24,color:#721c24,stroke-width:1px;
```
