# yente0603/huffman-packr architecture

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

- Interactive diagram: https://gitdiagram.com/yente0603/huffman-packr
- Repository: https://github.com/yente0603/huffman-packr

## Overview

##### Project type and purpose
- This is a C++ open-source compression tool (“Huffman-packr”) that provides:
- A CLI (Makefile-based) for Linux
- A cross-platform GUI (Qt6 + CMake)
- Core purpose: compress/decompress arbitrary files using Huffman coding, with separate log files for metadata.

##### File structure
- Top level:
- Makefile, CMakeLists.txt → two build paths (CLI vs. GUI)
- README, LICENSE
- / & src/:
- core headers and implementations (config, file, table, tree, utils)
- src/main.cpp → CLI entrypoint
- src/qt/ → GUI entrypoints, UI definition (mainQt.cpp, mainWindow.{hpp,cpp,ui})
- No database or web components—pure local processing and file I/O.
- Logging outputs under output/tmp (via code, not shown in tree).

##### README insights
- Describes two “frontends” (CLI vs GUI) sharing the same core library.
- Enumerates external dependencies: C++11/17, Qt6 modules, OpenGL libs.
- Mentions future consolidation of metadata into file headers.

##### Detail
- Break the core into sub-components (tree builder, table generator, util, file).
- Configuration flow from frontends to core.
- Log file outputs as a separate node.
- Cross-cutting concerns (e.g., error handling, memory management).

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Presentation Layer"
        CLI["CLI Module\n(src/main.cpp)"]:::presentation
        MainQt["GUI Entry\n(src/qt/mainQt.cpp)"]:::presentation
        MainWindowCpp["GUI UI Logic\n(src/qt/mainWindow.cpp)"]:::presentation
        MainWindowUI["GUI UI Definition\n(src/qt/mainWindow.ui)"]:::presentation
        MainWindowHpp["GUI UI Header\n(include/qt/mainWindow.hpp)"]:::presentation
    end

    subgraph "Core Library"
        Config["Configuration\n(include/config.hpp, src/config.cpp)"]:::core
        subgraph "HuffmanEngine"
            Tree["Tree Builder\n(include/tree.hpp, src/tree.cpp)"]:::core
            Table["Code Table Generator\n(include/table.hpp, src/table.cpp)"]:::core
            Utils["Utilities\n(include/utils.hpp, src/utils.cpp)"]:::core
            FileComp["File I/O\n(include/file.hpp, src/file.cpp)"]:::core
        end
    end

    subgraph "Infrastructure"
        FileSys["Filesystem (I/O)"]:::infra
        LogSys["Logging Sub-system"]:::infra
    end

    subgraph "Build & Deployment"
        Make["Makefile"]:::build
        CMake["CMakeLists.txt"]:::build
        CLIbin["CLI Binary\n(HuffmanTool)"]:::build
        GUIbin["GUI Binary\n(HuffmanToolGUI)"]:::build
    end

    subgraph "External Libraries"
        Qt6["Qt6"]:::external
        STL["STL / C++"]:::external
        OpenGL["OpenGL"]:::external
    end

    %% Presentation to Core
    CLI -->|"initialize(config)"| Config
    CLI -->|"encode(data)"| Tree
    MainQt -->|"initialize(config)"| Config
    MainQt -->|"encode(data)"| Tree
    MainWindowCpp -->|"invoke UI actions"| Config
    MainWindowCpp -->|"invoke UI actions"| Tree
    MainWindowUI -->|"UI definition"| MainWindowCpp
    MainWindowHpp -->|"UI header"| MainWindowCpp

    %% Core internal flows
    Config -->|"supply settings"| Tree
    Config -->|"supply settings"| Table
    Config -->|"supply settings"| Utils
    Config -->|"supply settings"| FileComp
    Tree -->|"build tree"| Table
    Table -->|"generate codes"| Utils
    Utils -->|"pack bits"| FileComp
    FileComp -->|"read/write files"| FileSys
    Utils -->|"emit logs"| LogSys

    %% Build flows
    Make -->|"build"| CLIbin
    CMake -->|"build"| GUIbin
    Make -.-> CLI
    CMake -.-> MainQt

    %% Infrastructure to external
    Qt6 --> GUIbin
    STL --> Config
    STL --> Tree
    STL --> Table
    STL --> Utils
    STL --> FileComp
    OpenGL --> Qt6

    %% Styling
    classDef presentation fill:#a8f0c6,stroke:#2d572c,color:#000
    classDef core fill:#a1c8f0,stroke:#1f3a93,color:#000
    classDef infra fill:#d3d3d3,stroke:#4a4a4a,color:#000
    classDef build fill:#f0c68a,stroke:#927800,color:#000
    classDef external fill:#f5e6a9,stroke:#a27b00,color:#000

    %% Click Events
    click CLI "https://github.com/yente0603/huffman-packr/blob/main/src/main.cpp"
    click Make "https://github.com/yente0603/huffman-packr/tree/main/Makefile"
    click CMake "https://github.com/yente0603/huffman-packr/blob/main/CMakeLists.txt"
    click MainQt "https://github.com/yente0603/huffman-packr/blob/main/src/qt/mainQt.cpp"
    click MainWindowCpp "https://github.com/yente0603/huffman-packr/blob/main/src/qt/mainWindow.cpp"
    click MainWindowUI "https://github.com/yente0603/huffman-packr/blob/main/src/qt/mainWindow.ui"
    click MainWindowHpp "https://github.com/yente0603/huffman-packr/blob/main/include/qt/mainWindow.hpp"
    click Config "https://github.com/yente0603/huffman-packr/blob/main/include/config.hpp"
    click Config "https://github.com/yente0603/huffman-packr/blob/main/src/config.cpp"
    click FileComp "https://github.com/yente0603/huffman-packr/blob/main/include/file.hpp"
    click FileComp "https://github.com/yente0603/huffman-packr/blob/main/src/file.cpp"
    click Tree "https://github.com/yente0603/huffman-packr/blob/main/include/tree.hpp"
    click Tree "https://github.com/yente0603/huffman-packr/blob/main/src/tree.cpp"
    click Table "https://github.com/yente0603/huffman-packr/blob/main/include/table.hpp"
    click Table "https://github.com/yente0603/huffman-packr/blob/main/src/table.cpp"
    click Utils "https://github.com/yente0603/huffman-packr/blob/main/include/utils.hpp"
    click Utils "https://github.com/yente0603/huffman-packr/blob/main/src/utils.cpp"
```
