# gabrielmakedrive/juntarpdflocal architecture

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

- Interactive diagram: https://gitdiagram.com/gabrielmakedrive/juntarpdflocal
- Repository: https://github.com/gabrielmakedrive/juntarpdflocal

## Overview

##### Main Components
- GUI Layer: Representing the user interface built using Tkinter. This includes buttons (e.g., “Adicionar PDF”, “Remover PDF”, “Juntar PDFs”), the list widget for displaying selected PDFs, and controls for reordering the PDFs.
- PDF Processing Module: The core functionality where the merging logic happens using PyPDF2. This includes:
- File selection handler – validating selected files are proper PDFs.
- File ordering logic – managing the list order based on user actions.
- PDF merging and saving logic – integrating the selected PDFs into a single output file.
- Application Entry Point: The main.py file which initializes the application, sets up the GUI, and ties in the processing functions.
- Build and Distribution Modules: Although not part of runtime architecture, the PyInstaller build process (represented by main.spec, build/, and dist/) is important to show how source code is packaged into an executable.

##### Relationships and Interactions
- The processing module, upon merging, interacts with the file system, confirming file types and writing the final PDF output.
- The main.py file ties both layers together by initializing the GUI and setting up event listeners that bind user actions to PDF processing functions.
- Optionally, include the PyInstaller layer (build and dist directories) as an external packaging pipeline that takes the source code as input to produce the final distributable executable.

##### Architectural Patterns and Design Principles
- Modular design: Show distinct modules for handling PDF selection, ordering, and merging, which enhances maintainability and allows for easy future extensions.
- Packaging pipeline: Illustrate that the application is designed to be portable through PyInstaller by outlining the build process separately.

##### Relevant Technologies
- Tkinter for the UI.
- PyPDF2 for PDF operations.
- Python as the development language.
- PyInstaller for creating the executable (packaging layer).

## Diagram (Mermaid)

```mermaid
graph TD
    %% Runtime Application
    subgraph "Runtime Application"
        User["User"]:::external
        AppEntry["Application Entry (main.py)"]:::backend
        GUI["GUI Layer (Tkinter)"]:::frontend
        PDFModule["PDF Processing Module (PyPDF2)"]:::backend
        FileOps["File System Operations (Merge & Save)"]:::backend

        User -->|"launches"| AppEntry
        AppEntry -->|"initializes"| GUI
        AppEntry -->|"bindsFunctionsTo"| PDFModule
        GUI -->|"triggersActions"| PDFModule
        PDFModule -->|"writesOutputTo"| FileOps
    end

    %% Packaging Process
    subgraph "Packaging Process (PyInstaller)"
        Spec["Packaging Spec (main.spec)"]:::packaging
        BuildDir["Build Directory (build/)"]:::packaging
        DistDir["Distribution Directory (dist/)"]:::packaging

        Spec -->|"buildsInto"| BuildDir
        BuildDir -->|"distributesTo"| DistDir
    end

    %% Connection between Application and Packaging
    AppEntry -->|"packagedVia"| Spec

    %% Click Events
    click AppEntry "https://github.com/gabrielmakedrive/juntarpdflocal/blob/main/main.py"
    click GUI "https://github.com/gabrielmakedrive/juntarpdflocal/blob/main/main.py"
    click PDFModule "https://github.com/gabrielmakedrive/juntarpdflocal/blob/main/main.py"
    click Spec "https://github.com/gabrielmakedrive/juntarpdflocal/blob/main/main.spec"
    click BuildDir "https://github.com/gabrielmakedrive/juntarpdflocal/tree/main/build/"
    click DistDir "https://github.com/gabrielmakedrive/juntarpdflocal/tree/main/dist/"

    %% Styles
    classDef external fill:#f9e79f,stroke:#7d6608,stroke-width:2px;
    classDef frontend fill:#aed6f1,stroke:#2471a3,stroke-width:2px;
    classDef backend fill:#abebc6,stroke:#1e8449,stroke-width:2px;
    classDef packaging fill:#f9d79f,stroke:#b9770e,stroke-width:2px;
```
