# voilelab/goimgpack architecture

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

- Interactive diagram: https://gitdiagram.com/voilelab/goimgpack
- Repository: https://github.com/voilelab/goimgpack

## Overview

##### Main Components
- User Interface (UI) Component:
- This is evident from files like FyneApp.toml and elements within “imgpack” (e.g., dialog.go, preference_dialog.go).
- It leverages the Fyne library for rendering the desktop GUI.
- Application Logic / Image Packing Operations:
- The “imgpack” directory includes files such as app.go, conf.go, imgstable.go, and enabled.go that encapsulate core operations such as image addition, duplicating, removal, reordering, etc.
- Image Processing Utilities:
- In “internal/imgutil”, functions for decoding, reading, and saving images are implemented.
- “internal/util” provides supporting utility functions for error handling, formatting, and numeric manipulations.
- Main Entry Point:
- The “main.go” file serves as the starting point for initializing the application.
- CI/CD / Build Configuration:
- The .github/workflows directory with GitHub Actions configuration (release-artifact.yml) ensures automated builds and releases, which supports the overall deployment/publishing architecture.

##### Component Interactions
- The UI layer (powered by Fyne) receives user input (e.g., clicking buttons to add or manipulate images) and passes commands to the business logic.
- The business logic within the “imgpack” package orchestrates commands like image manipulation and format conversion.
- These operations rely on the utilities in “internal/imgutil” and “internal/util” to process individual image files.
- The workflow from main.go initializes the application, setting up the UI and linking event handlers to the corresponding functions in the business logic layer.
- The GitHub Actions in the .github directory are used during the build and release phases to package the app (e.g., with commands like “fyne package -os darwin” for macOS).

##### Architectural Patterns & Design Principles
- Separation of Concerns: Different directories handle distinct responsibilities (UI, business logic, low-level image processing, and utilities).
- Layered Architecture: The project clearly decouples UI (Fyne-driven components), core image operations (imgpack), and the supporting functions (internal packages).
- Modularity & Extensibility: Functions are broken into multiple files and packages, making it easy to extend features like support for additional image formats or new image operations.

##### Relevant Technologies
- Programming language: Go, as indicated by go.mod and related Go files.
- Desktop UI: Fyne (noted especially by FyneApp.toml and packaging instructions in the README).
- CI/CD: GitHub Actions for automated releases.
- Formats: Support for various image file types, ZIP/CBZ archives, and PDF processing.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Application Entry"
        MainEntry("Application Entry (main.go)"):::entry
    end

    subgraph "User Interface (Fyne)"
        UI_Config("Fyne Config"):::ui
        UI_Dialog("Dialog Component"):::ui
        UI_Pref("Preference Dialog"):::ui
    end

    subgraph "Image Packing Module (imgpack)"
        BL_Core("Application Core"):::logic
        BL_Config("Configuration & Feature Toggle"):::logic
        BL_Table("Image Table"):::logic
        BL_Pref("User Preferences"):::logic
    end

    subgraph "Image Processing Utilities"
        UTIL_Decode("Image Decode"):::util
        UTIL_Read("Image Read"):::util
        UTIL_Imgs("Image Manipulation"):::util
        UTIL_Save("Image Save"):::util
        UTIL_Digits("Utility Digits"):::util
        UTIL_Err("Error Handling"):::util
        UTIL_Format("Formatting"):::util
    end

    subgraph "CI/CD Pipeline"
        CICD("GitHub Actions"):::cicd
    end

    %% Connections
    MainEntry -->|"initializes"| UI_Config
    MainEntry -->|"initializes"| BL_Core
    UI_Config -->|"triggers"| BL_Core
    UI_Dialog -->|"triggers"| BL_Core
    UI_Pref -->|"triggers"| BL_Pref
    BL_Core -->|"calls"| UTIL_Decode
    BL_Core -->|"calls"| UTIL_Read
    BL_Core -->|"calls"| UTIL_Imgs
    BL_Core -->|"calls"| UTIL_Save
    BL_Config -->|"utilizes"| UTIL_Err
    BL_Config -->|"utilizes"| UTIL_Format
    BL_Table -->|"manipulates"| UTIL_Imgs
    CICD -->|"packages"| MainEntry

    %% Click Events for User Interface (Fyne)
    click UI_Config "https://github.com/voilelab/goimgpack/blob/main/FyneApp.toml"
    click UI_Dialog "https://github.com/voilelab/goimgpack/blob/main/imgpack/dialog.go"
    click UI_Pref "https://github.com/voilelab/goimgpack/blob/main/imgpack/preference_dialog.go"

    %% Click Events for Application Logic / Image Packing Operations
    click BL_Core "https://github.com/voilelab/goimgpack/blob/main/imgpack/app.go"
    click BL_Config "https://github.com/voilelab/goimgpack/blob/main/imgpack/conf.go"
    click BL_Config "https://github.com/voilelab/goimgpack/blob/main/imgpack/enabled.go"
    click BL_Table "https://github.com/voilelab/goimgpack/blob/main/imgpack/imgstable/imgstable.go"
    click BL_Pref "https://github.com/voilelab/goimgpack/blob/main/imgpack/preference.go"

    %% Click Events for Image Processing Utilities (imgutil)
    click UTIL_Decode "https://github.com/voilelab/goimgpack/blob/main/internal/imgutil/decode.go"
    click UTIL_Read "https://github.com/voilelab/goimgpack/blob/main/internal/imgutil/read.go"
    click UTIL_Imgs "https://github.com/voilelab/goimgpack/blob/main/internal/imgutil/imgs.go"
    click UTIL_Save "https://github.com/voilelab/goimgpack/blob/main/internal/imgutil/save.go"

    %% Click Events for Image Processing Utilities (util)
    click UTIL_Digits "https://github.com/voilelab/goimgpack/blob/main/internal/util/digits.go"
    click UTIL_Err "https://github.com/voilelab/goimgpack/blob/main/internal/util/errors.go"
    click UTIL_Format "https://github.com/voilelab/goimgpack/blob/main/internal/util/format.go"

    %% Click Event for Main Entry Point
    click MainEntry "https://github.com/voilelab/goimgpack/blob/main/main.go"

    %% Click Event for CI/CD Pipeline
    click CICD "https://github.com/voilelab/goimgpack/blob/main/.github/workflows/release-artifact.yml"

    %% Styles
    classDef ui fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef logic fill:#90EE90,stroke:#000,stroke-width:2px;
    classDef util fill:#FFA500,stroke:#000,stroke-width:2px;
    classDef entry fill:#FFFF99,stroke:#000,stroke-width:2px;
    classDef cicd fill:#DDA0DD,stroke:#000,stroke-width:2px;
```
