# uatomicboolean/slint-template architecture

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

- Interactive diagram: https://gitdiagram.com/uatomicboolean/slint-template
- Repository: https://github.com/uatomicboolean/slint-template

## Overview

##### Project Type and Purpose
- This is a single-binary desktop GUI application written in Rust, using Slint for the UI layer.

##### Main Architectural Components
a. Rust Core (Business Logic & App Entry)
- File: src/main.rs
- build.rs (build-time resource bundler)
- Cargo.toml (dependency & metadata)
b. UI Layer (Slint Definitions)
- ui/app-window.slint (main window)
- ui/components (sidebar, layout components)
- ui/pages (logical pages/views)
- ui/widgets (custom widgets like buttons, menus)
- ui/theme (theme variables & style structs)
- ui/windows (auxiliary windows)
- ui/assets (fonts, images)
c. Internationalization (i18n)
- lang/*.po and .pot files
- Loaded at runtime by Slint
d. Resources
- winresources configured via Cargo.toml
e. Packaging & Distribution
- .github/workflows/*.yaml (CI jobs for Linux, Windows, macOS-Intel/ARM)
- dist/ (generated installers & executables)
f. External Dependencies & Services
- Slint runtime library
- Cargo/Rust toolchain
- GitHub Actions runners
- Platform installer toolchains (e.g. WiX on Windows, pkgbuild on macOS)

##### Relationships & Data Flows
- The Rust Core initializes the Slint engine, loads UI definitions and translations.
- UI events (button clicks, user input) propagate to Rust Core via Slint’s callback mechanism.
- Rust Core may read/write resources or configuration (not shown in this template).
- build.rs at compile time bundles assets (fonts, images, translation files) into the binary.
- CI/CD workflows trigger on Git tag push → build for each platform → package into installers → publish release (artifacts pushed to dist/).
- At runtime, the user interacts with the UI; the single executable contains all embedded resources.

##### Architectural Patterns & Design Principles
- Layered separation:
- UI (Slint) <→> Application Logic (Rust)
- Componentization: UI broken into reusable components, pages, widgets.
- Resource embedding: build.rs + Cargo metadata ensure a self-contained binary.
- CI/CD as an independent pipeline orchestrating multi-platform builds.
- Convention-over-configuration: project is a template—folder structure organizes concerns.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Rust Core
    subgraph "Rust Core"
        direction TB
        RC["Rust Core\n(src/main.rs)"]:::core
        BS["build.rs"]:::script
        CM["Cargo.toml"]:::script
        BIN["Binary Executable"]:::core
    end

    %% UI Layer
    subgraph "UI Layer"
        direction TB
        MW["Main Window\n(ui/app-window.slint)"]:::ui
        subgraph "Components"
            COMP["ui/components"]:::ui
        end
        subgraph "Pages"
            PAGES["ui/pages"]:::ui
        end
        subgraph "Widgets"
            WID["ui/widgets"]:::ui
        end
        subgraph "Theme"
            TS["theme-structs.slint"]:::ui
            TV["variables.slint"]:::ui
        end
        subgraph "Auxiliary Windows"
            AW["ui/windows"]:::ui
        end
        subgraph "Assets"
            AF["fonts"]:::resource
            AI["images"]:::resource
        end
    end

    %% Translations
    subgraph "Translations"
        direction TB
        L1["en.po"]:::resource
        L2["slint-template.pot"]:::resource
    end

    %% Static Resources
    RES["res"]:::resource

    %% CI/CD Pipeline
    subgraph "CI/CD Pipeline"
        direction TB
        GH["GitHub Actions"]:::external
        LNX["linux.yaml"]:::external
        WIN["windows.yaml"]:::external
        MI["macos_intel.yaml"]:::external
        MA["macos_arm.yaml"]:::external
        GH -->|"trigger build"| LNX
        GH -->|"trigger build"| WIN
        GH -->|"trigger build"| MI
        GH -->|"trigger build"| MA
        LNX & WIN & MI & MA -->|"publish installers"| DIST["dist"]:::resource
    end

    %% User
    USER["User"]:::external

    %% Relationships
    BS -->|"bundle assets"| BIN
    CM -->|"metadata"| BIN
    RC -->|"compile into"| BIN
    BIN -->|"load .slint files"| MW
    BIN -->|"load translations"| L1
    BIN -->|"load translations"| L2
    MW -->|"user events"| RC
    USER -->|"interact"| MW

    %% Click Events
    click RC "https://github.com/uatomicboolean/slint-template/blob/main/src/main.rs"
    click BS "https://github.com/uatomicboolean/slint-template/blob/main/build.rs"
    click CM "https://github.com/uatomicboolean/slint-template/blob/main/Cargo.toml"
    click MW "https://github.com/uatomicboolean/slint-template/blob/main/ui/app-window.slint"
    click COMP "https://github.com/uatomicboolean/slint-template/tree/main/ui/components"
    click PAGES "https://github.com/uatomicboolean/slint-template/tree/main/ui/pages"
    click WID "https://github.com/uatomicboolean/slint-template/tree/main/ui/widgets"
    click TS "https://github.com/uatomicboolean/slint-template/blob/main/ui/theme/theme-structs.slint"
    click TV "https://github.com/uatomicboolean/slint-template/blob/main/ui/theme/variables.slint"
    click AW "https://github.com/uatomicboolean/slint-template/tree/main/ui/windows"
    click AF "https://github.com/uatomicboolean/slint-template/tree/main/ui/assets/fonts"
    click AI "https://github.com/uatomicboolean/slint-template/tree/main/ui/assets/images"
    click L1 "https://github.com/uatomicboolean/slint-template/blob/main/lang/en/LC_MESSAGES/slint-template.po"
    click L2 "https://github.com/uatomicboolean/slint-template/blob/main/lang/slint-template.pot"
    click RES "https://github.com/uatomicboolean/slint-template/tree/main/res"
    click LNX "https://github.com/uatomicboolean/slint-template/blob/main/.github/workflows/linux.yaml"
    click WIN "https://github.com/uatomicboolean/slint-template/blob/main/.github/workflows/windows.yaml"
    click MI "https://github.com/uatomicboolean/slint-template/blob/main/.github/workflows/macos_intel.yaml"
    click MA "https://github.com/uatomicboolean/slint-template/blob/main/.github/workflows/macos_arm.yaml"
    click DIST "https://github.com/uatomicboolean/slint-template/tree/main/dist"

    %% Styles
    classDef core fill:#9f6,stroke:#393,stroke-width:2px
    classDef ui fill:#6bf,stroke:#039,stroke-width:2px
    classDef resource fill:#fb6,stroke:#f90,stroke-width:2px
    classDef external fill:#ccc,stroke:#888,stroke-width:2px
    classDef script fill:#d9b,stroke:#a85,stroke-width:2px
```
