# heartacker/variablebox.avalonia architecture

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

- Interactive diagram: https://gitdiagram.com/heartacker/variablebox.avalonia
- Repository: https://github.com/heartacker/variablebox.avalonia

## Overview

##### Project Type & Purpose
- The project is a UI control library (VariableBox) built for Avalonia UI, targeting cross-platform application development.
- Its purpose is to provide a highly configurable control for numerical and enumeration input (VariableBox and NumericalUpDown), along with MVVM command and event support.
- The README reveals that the control supports styling themes, configurable behaviors, and that it integrates with external theme packages like Semi.Avalonia.

##### Breakdown of the File Structure
- Top-Level Components:
- .github: Contains CI/CD workflows for deployment and packaging
- assets: Stores images and resources (e.g., logos, screenshots)
- demo: Contains various demo projects for different platforms (Android, Browser, Desktop, iOS) and a “default” demo demonstrating the control usage in Avalonia.
- src: Holds the core VariableBox control library with folders for controls, behaviors, converters, themes, and styles.
- Other solution and configuration files that organize the entire project

##### Main Components
A. Core Library (in src/VariableBox):
- This is the heart of the project. It includes:
- Controls: Actual implementations of VariableBox, NumericalUpDown, and related custom controls.
- Behaviors and Converters: Helpers that provide functionality such as behaviors (e.g., value change events) and data conversion.
- Themes & Styles: Various theme implementations (Fluent, Semi, Simple) and styling resources.
- Localization: Locale-specific resource files for supporting multiple languages (e.g., en-us, zh-cn).

B. Demo Applications (in demo/):
- These are separate projects that demonstrate the usage and integration of the VariableBox control:
- Android Demo: Platform-specific (Android).
- Browser Demo: Leverages a browser-hosted Avalonia app.
- Desktop Demo: Standard desktop Avalonia application.
- iOS Demo: iOS-specific project demonstrating control usage.
- A general demo folder also exists to show typical usage with XAML integration and MVVM (with commands and events).

C. Continuous Integration / Deployment:
- Located under .github workflows, these automated pipelines ensure that packaging, testing, and deployment are streamlined.

D. Supporting Documentation & Configuration:
- README, LICENSE, solution files (*.sln, settings files) and global configuration files (global.json, Package.props) that support the build and developer experience.

##### Relationships and Interactions
- The Core Library interacts with Avalonia UI framework and external theme packages (e.g., Semi.Avalonia).
- CI/CD workflows (under .github) trigger build processes that compile both the core library and the demos. Indicate data flow from source control (repository) through CI/CD to deployment packages.
- User interactions in the demos (e.g., clicking buttons, changing values) illustrate the reactive nature (bindings, events, commands) of the controls, meaning the controls raise events or execute commands that the ViewModel layer handles.

##### Architectural Patterns and Design Principles
- MVVM: Usage of commands and events suggests the MVVM pattern is central, especially in the demo projects.
- Separation of Concerns: The core library is well-isolated from demo implementations. Also, themes and styles are modular.
- Extensibility: The demo structure and plugin-like theme integration (Fluent, Semi, and Simple) highlight design for extensibility.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Core VariableBox Library Subgraph
    subgraph "Core VariableBox Library"
        C1("Control Implementations"):::core
        C2("VariableBox Control"):::core
        B1("Behaviors"):::core
        B2("Converters"):::core
        T1("Fluent Theme"):::core
        T2("Semi Theme"):::core
        T3("Simple Theme"):::core
        T4("Theme Resources"):::core
        T5("Styles"):::core
        L1("Localization Resources"):::core
    end

    %% Demo Applications Subgraph
    subgraph "Demo Applications"
        D1("Android Demo"):::demo
        D2("Browser Demo"):::demo
        D3("Desktop Demo"):::demo
        D4("iOS Demo"):::demo
        D5("General Demo"):::demo
    end

    %% CI/CD Pipeline Subgraph
    subgraph "CI/CD Pipeline"
        CI("CI/CD Pipeline"):::cicd
    end

    %% Supporting Documentation & Config Subgraph
    subgraph "Supporting Documentation & Config"
        Doc1("README"):::doc
        Doc2("LICENSE"):::doc
        Doc3("Global Config"):::doc
        Doc4("Solution File"):::doc
        Doc5("Package Props"):::doc
    end

    %% External Dependencies Subgraph
    subgraph "External Dependencies"
        E1("Avalonia UI Framework"):::ext
        E2("Semi.Avalonia Package"):::ext
    end

    %% MVVM Pattern Node
    MV("MVVM Pattern"):::mvvm

    %% Relationships between Demo Applications and Core Library
    D1 -->|"uses"| C1
    D2 -->|"uses"| C1
    D3 -->|"uses"| C1
    D4 -->|"uses"| C1
    D5 -->|"uses"| C1

    %% CI/CD builds both Demos and Core
    CI -->|"builds"| C1
    CI -->|"builds"| D1
    CI -->|"builds"| D2
    CI -->|"builds"| D3
    CI -->|"builds"| D4
    CI -->|"builds"| D5

    %% Internal relationship within Core Library
    C1 -->|"includes"| C2

    %% Core Library integration with External Dependencies
    C1 -->|"integrates"| E1
    T2 -->|"integrates"| E2

    %% Demos trigger MVVM interactions and MVVM controls the core
    D1 -->|"triggers"| MV
    D2 -->|"triggers"| MV
    D3 -->|"triggers"| MV
    D4 -->|"triggers"| MV
    D5 -->|"triggers"| MV
    MV -->|"controls"| C1

    %% Styles for diagram components
    classDef core fill:#FFDDCC,stroke:#B35700,stroke-width:2px;
    classDef demo fill:#D0E6A5,stroke:#6A994E,stroke-width:2px;
    classDef cicd fill:#FFF5BA,stroke:#E3B505,stroke-width:2px;
    classDef doc fill:#C9E4F7,stroke:#0E8388,stroke-width:2px;
    classDef ext fill:#F3C1BF,stroke:#B4161B,stroke-width:2px;
    classDef mvvm fill:#D7CFE2,stroke:#5A189A,stroke-width:2px;

    %% Click Events
    click C1 "https://github.com/heartacker/variablebox.avalonia/tree/main/src/VariableBox/Controls"
    click C2 "https://github.com/heartacker/variablebox.avalonia/tree/main/src/VariableBox/Controls/VariableBox"
    click B1 "https://github.com/heartacker/variablebox.avalonia/tree/main/src/VariableBox/Behaviors"
    click B2 "https://github.com/heartacker/variablebox.avalonia/tree/main/src/VariableBox/Converters"
    click T1 "https://github.com/heartacker/variablebox.avalonia/blob/main/src/VariableBox/Fluent.axaml"
    click T2 "https://github.com/heartacker/variablebox.avalonia/blob/main/src/VariableBox/Semi.axaml"
    click T3 "https://github.com/heartacker/variablebox.avalonia/blob/main/src/VariableBox/Simple.axaml"
    click T4 "https://github.com/heartacker/variablebox.avalonia/tree/main/src/VariableBox/Themes"
    click T5 "https://github.com/heartacker/variablebox.avalonia/tree/main/src/VariableBox/Styles"
    click L1 "https://github.com/heartacker/variablebox.avalonia/tree/main/src/VariableBox/Locale"
    click D1 "https://github.com/heartacker/variablebox.avalonia/blob/main/demo/VariableBox.Demo.Android"
    click D2 "https://github.com/heartacker/variablebox.avalonia/blob/main/demo/VariableBox.Demo.Browser"
    click D3 "https://github.com/heartacker/variablebox.avalonia/blob/main/demo/VariableBox.Demo.Desktop"
    click D4 "https://github.com/heartacker/variablebox.avalonia/blob/main/demo/VariableBox.Demo.iOS"
    click D5 "https://github.com/heartacker/variablebox.avalonia/blob/main/demo/VariableBox.Demo"
    click CI "https://github.com/heartacker/variablebox.avalonia/tree/main/.github/workflows"
    click Doc1 "https://github.com/heartacker/variablebox.avalonia/blob/main/README.md"
    click Doc2 "https://github.com/heartacker/variablebox.avalonia/tree/main/LICENSE"
    click Doc3 "https://github.com/heartacker/variablebox.avalonia/blob/main/global.json"
    click Doc4 "https://github.com/heartacker/variablebox.avalonia/blob/main/VariableBox.sln"
    click Doc5 "https://github.com/heartacker/variablebox.avalonia/blob/main/src/Package.props"
```
