# sharpedmimishee/schematics architecture

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

- Interactive diagram: https://gitdiagram.com/sharpedmimishee/schematics
- Repository: https://github.com/sharpedmimishee/schematics

## Overview

##### Project type and purpose
- This “Schematics” repo is a small Rust-based game/mod application that uses macroquad for real-time rendering and mlua for Lua scripting.
- It loads custom “schemapacks” (cell machine definitions), manages game features (cells, functions, registers), and drives multiple UI scenes (menus, play screen, credits).

##### File structure
- Top-level:
- Cargo.toml / Cargo.lock (Rust project manifest and locks)
- src/ (all Rust source code)
- schemapacks/ (external cell-machine definitions and test scripts)
- .github/workflows/rust.yml (CI build)
- src/:
- main.rs – application entrypoint & event loop
- assets/ – fonts, textures, UI assets
- scene/ – separate scenes (main menu, options, play screen, credits)
- features/ – core game logic modules (cell, celltype, functions, register)
- scene.rs – scene manager/dispatcher glue
- README highlights two main dependencies: macroquad (rendering + input + audio) and mlua (Lua VM).

##### README for additional insights
- Confirms it’s a standalone application, not a web service.
- Emphasizes mod-pack extensibility (schemapacks) and credits for art assets.

a. Main components to represent:
1. Application Core (main.rs)
2. Event Loop & Scheduler
3. Rendering Engine (macroquad)
4. Input System (macroquad)
5. Audio System (macroquad)
6. Scene Manager (scene.rs + scene/*)
7. Asset Manager (assets/* loader)
8. Feature Modules (features/*)
9. Lua Scripting Engine (mlua)
10. Schemapack Loader (schemapacks/*)
b. Relationships and interactions:
- The Event Loop orchestrates calls to Input → Update → Render each frame.
- Input System feeds raw events into the Scene Manager.
- Scene Manager delegates to the active Scene (playscreen, mainmenu, etc.).
- Scenes invoke Feature Modules for game logic (cell updates, function execution).
- Feature Modules may invoke Lua scripts (via the mlua engine) or respond to them.
- Asset Manager delivers textures/fonts/UI assets to the Rendering Engine.
- Schemapack Loader feeds definitions into Feature Modules and/or Lua.
- Audio System is called by Scenes or Features to play sounds.
c. Architectural patterns and design principles:
- Modularization by responsibility: assets, scenes, features, scripting.
- Separation of concerns: rendering vs. game logic vs. scripting.
- Plugin/mod-pack architecture: external schemapacks loaded at runtime.
d. Key technologies:
- Rust & Cargo (build)
- macroquad (OpenGL wrapper for graphics, input, audio)
- mlua (embedded Lua VM)
- Lua scripts in schemapacks for extensibility

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Core Layer
    subgraph "Core"
        main["Application Core"]:::core
        el["Event Loop & Scheduler"]:::core
    end

    %% Infrastructure Layer
    subgraph "Infrastructure"
        re["Rendering Engine (macroquad)"]:::infra
        inpt["Input System (macroquad)"]:::infra
        aud["Audio System (macroquad)"]:::infra
        lua["Lua Scripting Engine (mlua)"]:::infra
    end

    %% Managers Layer
    subgraph "Managers"
        sm["Scene Manager"]:::manager
        am["Asset Manager"]:::manager
        spl["Schemapack Loader"]:::manager
    end

    %% Scenes Layer
    subgraph "Scenes"
        menu["Main Menu"]:::scene
        opts["Options"]:::scene
        play["Play Screen"]:::scene
        credits["Credits"]:::scene
        setts["Play Settings"]:::scene
    end

    %% Logic Layer
    subgraph "Game Logic"
        fm["Feature Modules"]:::logic
    end

    %% Connections
    main --> el
    el -->|Input events| inpt
    el -->|Update tick| sm
    el -->|Render call| re

    inpt --> sm
    sm --> menu
    sm --> opts
    sm --> play
    sm --> credits
    sm --> setts

    menu -->|game logic calls| fm
    opts -->|game logic calls| fm
    play -->|game logic calls| fm
    credits -->|game logic calls| fm
    setts -->|game logic calls| fm

    fm -->|Script call| lua
    lua -->|Return values| fm

    spl -->|Load definitions| fm
    spl -->|Provide scripts| lua

    am -->|Texture request| re

    menu -->|Play sound| aud
    opts -->|Play sound| aud
    play -->|Play sound| aud
    credits -->|Play sound| aud
    setts -->|Play sound| aud

    %% Click Events
    click main "https://github.com/sharpedmimishee/schematics/blob/main/src/main.rs"
    click el "https://github.com/sharpedmimishee/schematics/blob/main/src/main.rs"
    click re "https://github.com/sharpedmimishee/schematics/blob/main/src/scene/textures.rs"
    click inpt "https://github.com/sharpedmimishee/schematics/blob/main/src/main.rs"
    click aud "https://github.com/sharpedmimishee/schematics/blob/main/src/main.rs"
    click sm "https://github.com/sharpedmimishee/schematics/blob/main/src/scene.rs"
    click menu "https://github.com/sharpedmimishee/schematics/blob/main/src/scene/mainmenu.rs"
    click opts "https://github.com/sharpedmimishee/schematics/blob/main/src/scene/options.rs"
    click play "https://github.com/sharpedmimishee/schematics/blob/main/src/scene/playscreen.rs"
    click credits "https://github.com/sharpedmimishee/schematics/blob/main/src/scene/credits.rs"
    click setts "https://github.com/sharpedmimishee/schematics/blob/main/src/scene/playsettings.rs"
    click am "https://github.com/sharpedmimishee/schematics/tree/main/src/assets/"
    click fm "https://github.com/sharpedmimishee/schematics/tree/main/src/features/"
    click lua "https://github.com/sharpedmimishee/schematics/blob/main/schemapacks/default/q/test.lua"
    click spl "https://github.com/sharpedmimishee/schematics/tree/main/schemapacks/"

    %% Styles
    classDef core fill:#f9f,stroke:#333,stroke-width:1px;
    classDef infra fill:#aaf,stroke:#333,stroke-width:1px;
    classDef manager fill:#ccf,stroke:#333,stroke-width:1px;
    classDef scene fill:#ffc,stroke:#333,stroke-width:1px;
    classDef logic fill:#fcf,stroke:#333,stroke-width:1px;
```
