# xuges/minui architecture

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

- Interactive diagram: https://gitdiagram.com/xuges/minui
- Repository: https://github.com/xuges/minui

## Overview

##### Project type and purpose
- This is a header-only, cross-platform GUI library (“MinUI”) aimed at installer and small-tool UIs.
- Purpose: provide a minimal widget set (Label, Button, Image, Progress) with Anti-Aliasing, HiDPI support, Dark-Mode, Custom styles. It exposes everything through a single C++ header (minui.hpp).

##### File structure
- Top-level:
- LICENSE.md, README.md – docs and overview
- doc/ – design sketches, GIF demos, theme merge image
- example/ – a sample executable and source (main.cpp) plus logo BMP data
- minui.hpp – the entire library in one file
- No multi-module folders; all core code lives in minui.hpp. example/ shows a minimal client using the library.

##### README for additional insights
- Confirms cross-platform targets: Windows (GDI) and Linux (GTK3/4).
- Lists widget types and features.

##### Elements
- “Client Application” (example/main.cpp)
- “Platform Abstraction Layer”
- “GDI Backend” and “GTK3/4 Backend”
- “Operating System”
- Client → Core API calls
- Core Rendering → Abstraction Layer
- Abstraction Layer → Specific Backend
- Backend → OS graphics/event APIs
- OS events → Backend → Abstraction → Core → Client
- Blue for Core Library
- Green for Platform Abstraction/Backends
- Orange for Client
- Gray for OS

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    ClientApp["Client Application"]:::client
    BMPDark["logo.dark.bmp.data"]:::client
    BMPLight["logo.light.bmp.data"]:::client

    %% Core Library
    subgraph "MinUI Core Library"
        WidgetLayer["Widget Layer\n(Label, Button, Image, Progress)"]:::core
        StyleEngine["Style Engine\n(themes, dark-mode, custom styling)"]:::core
        RenderingEngine["Rendering Engine\n(vector/AA, layout, DPI scaling)"]:::core
        ResourceLoader["Resource Loader\n(BMP decoding)"]:::core
        Abstraction["Platform Abstraction Layer\n(uniform API for drawing/events/windowing)"]:::abstraction
    end

    %% Platform Backends
    subgraph "Platform Backends"
        GDIBak["Windows GDI Backend"]:::backend
        GTKBak["Linux GTK3/4 Backend"]:::backend
    end

    %% OS
    OS["OS Graphics & Events"]:::os

    %% Documentation
    subgraph "Documentation"
        Doc["Design Sketches & GIFs"]:::docs
        Readme["README.md"]:::docs
        License["LICENSE.md"]:::docs
    end

    %% Sample Executable
    Exec["Sample Executable"]:::client

    %% Relationships
    ClientApp -->|"uses API"| WidgetLayer
    ClientApp -->|"loads BMP"| ResourceLoader
    ClientApp --> BMPDark
    ClientApp --> BMPLight

    WidgetLayer -->|"layout/paint"| RenderingEngine
    WidgetLayer -->|"requests styling"| StyleEngine
    ResourceLoader --> WidgetLayer
    StyleEngine --> RenderingEngine
    RenderingEngine --> Abstraction

    Abstraction -->|"draw/event APIs"| GDIBak
    Abstraction -->|"draw/event APIs"| GTKBak

    GDIBak --> OS
    GTKBak --> OS

    OS -->|"events"| GDIBak
    OS -->|"events"| GTKBak

    GDIBak -->|"backend events"| Abstraction
    GTKBak -->|"backend events"| Abstraction

    Abstraction -->|"dispatch event"| WidgetLayer
    WidgetLayer -->|"callback onClick()"| ClientApp

    %% Sample Executable link
    ClientApp --> Exec

    %% Click Events
    click ClientApp "https://github.com/xuges/minui/blob/main/example/main.cpp"
    click BMPDark "https://github.com/xuges/minui/blob/main/example/logo.dark.bmp.data"
    click BMPLight "https://github.com/xuges/minui/blob/main/example/logo.light.bmp.data"
    click WidgetLayer "https://github.com/xuges/minui/blob/main/minui.hpp"
    click StyleEngine "https://github.com/xuges/minui/blob/main/minui.hpp"
    click RenderingEngine "https://github.com/xuges/minui/blob/main/minui.hpp"
    click ResourceLoader "https://github.com/xuges/minui/blob/main/minui.hpp"
    click Abstraction "https://github.com/xuges/minui/blob/main/minui.hpp"
    click GDIBak "https://github.com/xuges/minui/blob/main/minui.hpp"
    click GTKBak "https://github.com/xuges/minui/blob/main/minui.hpp"
    click Doc "https://github.com/xuges/minui/tree/main/doc/"
    click Readme "https://github.com/xuges/minui/blob/main/README.md"
    click License "https://github.com/xuges/minui/blob/main/LICENSE.md"
    click Exec "https://github.com/xuges/minui/blob/main/example/example.exe"

    %% Styles
    classDef client fill:#ffcc99,stroke:#333,stroke-width:1px
    classDef core fill:#cce5ff,stroke:#333,stroke-width:1px
    classDef abstraction fill:#ccffcc,stroke:#333,stroke-width:1px
    classDef backend fill:#ccffcc,stroke:#333,stroke-width:1px
    classDef os fill:#dddddd,stroke:#333,stroke-width:1px
    classDef docs fill:#f2f2f2,stroke:#333,stroke-width:1px
```
