# mecha-org/bevy_mctk architecture

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

- Interactive diagram: https://gitdiagram.com/mecha-org/bevy_mctk
- Repository: https://github.com/mecha-org/bevy_mctk

## Overview

##### Project type and purpose
- This “Bevy MCTK” repository is an open-source UI toolkit for the Bevy game engine written in Rust.
- Its purpose is to provide a collection of core and styled widgets (buttons, sliders, checkboxes, etc.) that can be plugged into any Bevy application.

##### File structure
- Top-level directories:
- assets – themes, fonts, example settings, images
- crates – two sub-crates:
◦ bevy_additional_core_widgets – core/simple widget implementations
◦ bevy_styled_widgets – higher-level widgets with theming support
- examples – standalone Rust apps demonstrating each widget
- Each crate follows an ECS plugin pattern:
- src/lib.rs – entrypoint that registers a Bevy Plugin
- src/{ui,themes} – modular widget subdirectories (builder, components, systems, plugin.rs)
- Cargo.toml and Cargo.lock govern Rust dependencies; LICENSE and README.md cover project metadata.

##### Detailed capture of essential elements
- “Themes Manager” resource reading YAML files and injecting style data into widget systems
- Event flow: user input (mouse/keyboard) → InputSystem → WidgetSystems → style updates → Renderer

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Engine Core
    subgraph "Engine Core"
        BEVYE["Bevy Engine\n(core ECS, Renderer, AssetServer)"]:::engine
    end

    %% Library Crates
    subgraph "Library Crates"
        subgraph "Core Widgets"
            CORE_CRATE["bevy_additional_core_widgets"]:::lib
            CORE_SWITCH["core_switch widget"]:::lib
        end
        subgraph "Styled Widgets"
            STYLED_CRATE["bevy_styled_widgets"]:::lib
            THEMES["Theming Manager & Definitions"]:::lib
            subgraph "UI Modules"
                BTN["Button Module"]:::lib
                CHK["Checkbox Module"]:::lib
                INP["Input Module"]:::lib
                PROG["Progress Module"]:::lib
                RADIO["RadioGroup Module"]:::lib
                SLID["Slider Module"]:::lib
                SWI["Switch Module"]:::lib
                TXT["Text Module"]:::lib
                TOG["Toggle Module"]:::lib
            end
        end
    end

    %% Asset Repository
    ASSET["Asset Repository\n(themes, fonts, images, settings)"]:::asset

    %% Example Applications
    subgraph "Example Applications"
        BTN_EX["Button Demo"]:::example
        CHK_EX["Checkbox Demo"]:::example
        INP_EX["Input Demo"]:::example
        PROG_EX["Progress Demo"]:::example
        RADIO_EX["RadioGroup Demo"]:::example
        SLID_EX["Slider Demo"]:::example
        SWI_EX["Switch Demo"]:::example
        TOG_EX["Toggle Demo"]:::example
        ASSET_EX["Asset Usage Demo"]:::example
    end

    %% Relationships
    BTN_EX -->|"add_plugin"| STYLED_CRATE
    CHK_EX -->|"add_plugin"| STYLED_CRATE
    INP_EX -->|"add_plugin"| STYLED_CRATE
    PROG_EX -->|"add_plugin"| STYLED_CRATE
    RADIO_EX -->|"add_plugin"| STYLED_CRATE
    SLID_EX -->|"add_plugin"| STYLED_CRATE
    SWI_EX -->|"add_plugin"| STYLED_CRATE
    TOG_EX -->|"add_plugin"| STYLED_CRATE
    ASSET_EX -->|"loads assets"| STYLED_CRATE

    CORE_CRATE -->|"registers systems"| BEVYE
    STYLED_CRATE -->|"registers systems & resources"| BEVYE
    STYLED_CRATE -->|"uses themes"| THEMES
    THEMES -->|"reads files"| ASSET
    BEVYE -->|"serves assets"| ASSET
    BEVYE -->|"renders UI"| STYLED_CRATE

    %% UI Modules interactions
    STYLED_CRATE -->|"provides builders, components, systems"| BTN
    STYLED_CRATE -->|"provides builders, components, systems"| CHK
    STYLED_CRATE -->|"provides builders, components, systems"| INP
    STYLED_CRATE -->|"provides builders, components, systems"| PROG
    STYLED_CRATE -->|"provides builders, components, systems"| RADIO
    STYLED_CRATE -->|"provides builders, components, systems"| SLID
    STYLED_CRATE -->|"provides builders, components, systems"| SWI
    STYLED_CRATE -->|"provides builders, components, systems"| TXT
    STYLED_CRATE -->|"provides builders, components, systems"| TOG

    %% Click Events
    click BEVYE "https://github.com/mecha-org/bevy_mctk/blob/main/Cargo.toml"
    click CORE_CRATE "https://github.com/mecha-org/bevy_mctk/blob/main/crates/bevy_additional_core_widgets/src/lib.rs"
    click CORE_SWITCH "https://github.com/mecha-org/bevy_mctk/blob/main/crates/bevy_additional_core_widgets/src/core_switch.rs"
    click STYLED_CRATE "https://github.com/mecha-org/bevy_mctk/blob/main/crates/bevy_styled_widgets/src/lib.rs"
    click THEMES "https://github.com/mecha-org/bevy_mctk/blob/main/crates/bevy_styled_widgets/src/themes/manager.rs"
    click BTN "https://github.com/mecha-org/bevy_mctk/blob/main/crates/bevy_styled_widgets/src/ui/button/plugin.rs"
    click CHK "https://github.com/mecha-org/bevy_mctk/blob/main/crates/bevy_styled_widgets/src/ui/checkbox/plugin.rs"
    click INP "https://github.com/mecha-org/bevy_mctk/blob/main/crates/bevy_styled_widgets/src/ui/input/plugin.rs"
    click PROG "https://github.com/mecha-org/bevy_mctk/blob/main/crates/bevy_styled_widgets/src/ui/progress/plugin.rs"
    click RADIO "https://github.com/mecha-org/bevy_mctk/blob/main/crates/bevy_styled_widgets/src/ui/radio_group/plugin.rs"
    click SLID "https://github.com/mecha-org/bevy_mctk/blob/main/crates/bevy_styled_widgets/src/ui/slider/plugin.rs"
    click SWI "https://github.com/mecha-org/bevy_mctk/blob/main/crates/bevy_styled_widgets/src/ui/switch/plugin.rs"
    click TXT "https://github.com/mecha-org/bevy_mctk/blob/main/crates/bevy_styled_widgets/src/ui/text/plugin.rs"
    click TOG "https://github.com/mecha-org/bevy_mctk/blob/main/crates/bevy_styled_widgets/src/ui/toggle/plugin.rs"
    click BTN_EX "https://github.com/mecha-org/bevy_mctk/blob/main/examples/button.rs"
    click CHK_EX "https://github.com/mecha-org/bevy_mctk/blob/main/examples/checkbox.rs"
    click INP_EX "https://github.com/mecha-org/bevy_mctk/blob/main/examples/input.rs"
    click PROG_EX "https://github.com/mecha-org/bevy_mctk/blob/main/examples/progress.rs"
    click RADIO_EX "https://github.com/mecha-org/bevy_mctk/blob/main/examples/radio_group.rs"
    click SLID_EX "https://github.com/mecha-org/bevy_mctk/blob/main/examples/slider.rs"
    click SWI_EX "https://github.com/mecha-org/bevy_mctk/blob/main/examples/switch.rs"
    click TOG_EX "https://github.com/mecha-org/bevy_mctk/blob/main/examples/toggle.rs"
    click ASSET_EX "https://github.com/mecha-org/bevy_mctk/blob/main/examples/assets.rs"

    %% Styles
    classDef engine fill:#D0E6FF,stroke:#0057B8,color:#000
    classDef lib fill:#DFFFE0,stroke:#2E7D32,color:#000
    classDef asset fill:#FFF9C4,stroke:#F9A825,color:#000
    classDef example fill:#FFE0B2,stroke:#EF6C00,color:#000
```
