# john-nagle/ui-mock architecture

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

- Interactive diagram: https://gitdiagram.com/john-nagle/ui-mock
- Repository: https://github.com/john-nagle/ui-mock

## Overview

##### Project Type and Purpose
- This is a Rust-based library plus example binary that provides a mockup of a game-style 2D menu interface over a 3D world. It’s intended as a test fixture for a metaverse client, demonstrating how to integrate a non-intrusive 2D overlay (menus, dialogs) on top of a Rend3-powered 3D scene with Egui for GUI widgets.
- Key indicators:
- README describes a “mockup and test fixture for a game-type user interface,” 2D overlay atop a 3D world.
- Uses safe Rust with Rend3 (3D) and Egui (2D overlay).
- Cargo.toml + src folder + examples/ui-mock suggest a library crate plus an example binary.

##### File Structure Analysis
- Top-level:
- Cargo.toml, README.md: Rust project manifest and documentation.
- src/: main library code and modules.
- src/assets/: JSON definitions (grids.json), images, locales (menus.json, translations).
- src/basicintl.rs: core internationalization support.
- src/lib.rs: library entry point exporting modules.
- src/examples/ui-mock/: standalone example binary named ui-mock:
- main.rs launches window, sets up Rend3/Egui.
- examplesupport.rs, libdialog/: a dialog-system submodule with multiple dialog variants (login, stats, grids, etc.).
- No separate backend or database—this is purely client-side UI simulation.

##### README Insights
- Describes runtime behavior (windowed/fullscreen, auto-hide menus).
- Mentions core technologies: Rend3, Egui.
- Emphasizes a “clean screen when possible,” minimal obtrusiveness.

a. Main Components
1. Example Application (ui-mock binary)
2. Core UI Library
- Asset Manager (loads JSON, images, locales)
- Internationalization Module (basicintl)
- State Manager (guistate)
- Dialog System (libdialog in example)
3. Rendering Backends
- Rend3 (3D engine)
- Egui (2D overlay)
4. Input Handling
- Mouse/keyboard events → event switch (examples/ui-mock/libdialog/eventswitch)
5. Configuration & Assets
- JSON files in assets/grids.json, menus.json, locale data
- Images in assets/images
b. Relationships and Interactions
- Example App initializes Rend3 window and Egui context.
- Asset Manager loads configuration and image assets, passes data to UI Modules.
- Input events flow into the Event Switch, which updates the State Manager.
- State Manager invokes UI Modules to build Egui panels/widgets.
- Egui renders 2D overlays; Rend3 renders underlying 3D scene (empty/test scene).
- Internationalization module provides localized strings to menus/dialogs.
c. Architectural Patterns and Principles
- Modular separation: each UI concern in its own Rust module.
- Model-View-Controller style:
- Model = application state (guistate)
- View = Egui GUI modules
- Controller = input event switch, guiutil helpers
- Dependency injection: example binary wires library components to Rend3/Egui backends.
d. Technologies, Frameworks, Libraries
- Rust (100% safe)
- Cargo (build & dependency management)
- Rend3 for 3D rendering
- Egui for immediate-mode GUI overlay
- Serde/JSON for asset parsing (implicit in JSON files)
- Winit (implied for windowing & input)

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Example Application"
        UIApp["ui-mock Binary"]:::binary
        ExSupport["Example Support Utilities"]:::library
        UIApp --> ExSupport
    end

    subgraph "Library Core"
        LibEntry["Library Entry Point"]:::library
        AssetMgr["Asset Manager"]:::asset
        Intl["Internationalization Module"]:::library
        StateMgr["State Manager"]:::library
        Menus["Menus Module"]:::library
        NoMenu["No Menu Module"]:::library
        NavArrows["Navigation Arrows Module"]:::library
        PieMenu["Pie Menu Module"]:::library
        StatGraph["Stat Graph Module"]:::library
        GUIUtil["GUI Utilities"]:::library
        subgraph "Dialog System"
            DialogSys["Dialog System"]:::library
            Events["Input Event Switch"]:::controller
            UIInfo["UI Information Helper"]:::library
            DialogVariants["Dialog Variants"]:::library
        end
    end

    subgraph "Rendering Backends"
        Rend3["Rend3 Engine"]:::external
        Egui["Egui Overlay"]:::external
    end

    subgraph "Assets"
        Assets["Asset Store"]:::asset
    end

    %% Relationships
    UIApp -->|"initializes"| Rend3
    UIApp -->|"initializes"| Egui
    UIApp -->|"uses"| LibEntry
    ExSupport -->|"supports"| DialogSys

    Assets -->|"provides data"| AssetMgr
    AssetMgr -->|"loads JSON/images/locales"| Menus
    AssetMgr -->|"loads JSON/images/locales"| PieMenu
    AssetMgr -->|"loads JSON/images/locales"| StatGraph
    AssetMgr -->|"loads JSON/images/locales"| NavArrows
    AssetMgr -->|"loads JSON/images/locales"| NoMenu
    AssetMgr -->|"loads JSON/images/locales"| DialogVariants

    Intl -->|"provides strings"| Menus
    Intl -->|"provides strings"| DialogSys

    Events -->|"updates"| StateMgr
    UIApp -->|"captures input"| Events

    StateMgr -->|"triggers"| Menus
    StateMgr -->|"triggers"| PieMenu
    StateMgr -->|"triggers"| StatGraph
    StateMgr -->|"triggers"| NavArrows
    StateMgr -->|"triggers"| NoMenu
    StateMgr -->|"triggers"| DialogSys

    Menus -->|"builds UI"| Egui
    PieMenu -->|"builds UI"| Egui
    StatGraph -->|"builds UI"| Egui
    NavArrows -->|"builds UI"| Egui
    NoMenu -->|"builds UI"| Egui
    DialogSys -->|"builds UI"| Egui

    Rend3 -->|"renders scene"| Screen["Screen Output"]:::output
    Egui -->|"renders overlay"| Screen

    %% Click Events
    click UIApp "https://github.com/john-nagle/ui-mock/blob/main/src/examples/ui-mock/main.rs"
    click ExSupport "https://github.com/john-nagle/ui-mock/blob/main/src/examples/ui-mock/examplesupport.rs"
    click DialogSys "https://github.com/john-nagle/ui-mock/blob/main/src/examples/ui-mock/libdialog/mod.rs"
    click DialogVariants "https://github.com/john-nagle/ui-mock/tree/main/src/examples/ui-mock/libdialog/dialogs/"
    click Events "https://github.com/john-nagle/ui-mock/blob/main/src/examples/ui-mock/libdialog/eventswitch.rs"
    click UIInfo "https://github.com/john-nagle/ui-mock/blob/main/src/examples/ui-mock/libdialog/uiinfo.rs"
    click LibEntry "https://github.com/john-nagle/ui-mock/blob/main/src/lib.rs"
    click AssetMgr "https://github.com/john-nagle/ui-mock/tree/main/src/assets/"
    click Intl "https://github.com/john-nagle/ui-mock/blob/main/src/basicintl.rs"
    click StateMgr "https://github.com/john-nagle/ui-mock/blob/main/src/guistate.rs"
    click Menus "https://github.com/john-nagle/ui-mock/blob/main/src/guimenus.rs"
    click NoMenu "https://github.com/john-nagle/ui-mock/blob/main/src/menunone.rs"
    click NavArrows "https://github.com/john-nagle/ui-mock/blob/main/src/navarrows.rs"
    click PieMenu "https://github.com/john-nagle/ui-mock/blob/main/src/piemenu.rs"
    click StatGraph "https://github.com/john-nagle/ui-mock/blob/main/src/statgraph.rs"
    click GUIUtil "https://github.com/john-nagle/ui-mock/blob/main/src/guiutil.rs"

    %% Styles
    classDef binary fill:#c2f0c2,stroke:#4CAF50,stroke-width:2px;
    classDef library fill:#dae8fc,stroke:#6c8ebf,stroke-width:2px;
    classDef external fill:#f8cecc,stroke:#b85450,stroke-width:2px,stroke-dasharray: 5 5;
    classDef asset fill:#fff2cc,stroke:#d6b656,stroke-width:2px,stroke-dasharray: 2 2;
    classDef controller fill:#e1d5e7,stroke:#9673a6,stroke-width:2px;
    classDef output fill:#d5e8d4,stroke:#82b366,stroke-width:2px,stroke-dasharray: 4 2;
```
