# joeliranzo/luango architecture

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

- Interactive diagram: https://gitdiagram.com/joeliranzo/luango
- Repository: https://github.com/joeliranzo/luango

## Overview

##### Project Type & Purpose
- Luango Engine is a lightweight, modular game engine written in Go with embedded Lua scripting (via Gopher-Lua) designed for performance and flexibility. Its purpose is to provide game developers with a simple yet powerful platform that supports modding through Lua scripts.
- The README shows that it handles rendering (using Ebiten), audio (using Beep), input, and a mod loader that automatically loads Lua scripts. Future roadmap items include an ECS system and enhanced modular engine modules.

##### Main Components
a. Engine Core:
– The Go-based core (represented by main.go and go.mod) that bootstraps the application.
– Core engine modules for graphics, input, and audio which, although not neatly separated into individual directories in the file tree, are implied through the README and TECHNICAL documentation.
b. Lua Scripting Integration:
– The embedded Lua interpreter (Gopher-Lua) that supports scripting.
– The Lua API exposing functions (log, debug, play_sound, move_player, etc.) and game hooks like on_start() and on_update() located within the mod/game/init.lua.
c. Mod Loader & Scripting Modules:
– The mod folder (with subdirectories like mod/player, mod/enemy, mod/items, and mod/game) which holds various Lua scripts.
– The mod loader component that scans the mod directory and loads the Lua scripts.
d. Asset Management:
– The assets directory including images (sprites) and sounds (e.g., assets/sounds/sonidito.wav) that the engine will load and render/play as needed.
e. (Planned/Upcoming) Infrastructure:

##### Relationships & Data Flow
- Entry point (main.go) initializing the Engine Core.
- Graphics/Rendering Module (using Ebiten)
- Input Module (using Ebiten’s input handling)
- Audio Module (playing .wav files via Beep)
- Asset management as a supporting service providing images and sounds to the rendering and audio modules.

##### Technologies & Architectural Patterns
- Labels for Go, Lua (Gopher-Lua), Ebiten, and Beep where appropriate.
- Modular, event-driven design and mention that the design is “ECS-ready” (even if the ECS layer is planned) since it influences how components interact.
- Mod loader subsystem that autonomously loads Lua modules from multiple directories (mod/player, mod/enemy, mod/items, etc.).

##### Key Elements to Label
- Each main component should have clear labels (“Engine Core”, “Rendering Module (Ebiten)”, “Input Module (Ebiten)”, “Audio Module (Beep)”, “Lua Scripting Engine”, “Mod Loader”, “Asset Manager”).
- From main.go to each subsystem.
- From Engine Core to Lua (showing initialization and hook invocation).
- From Lua scripts to engine subsystems (indicating how game events like on_start() and on_update() drive behavior).
- Optionally, add annotations for planned features (like ECS) to provide context for future development extensions.

##### Conclusion
– A clear high-level view linking the Go backend application with its various game subsystems.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Engine Core
    subgraph "Engine Core"
        EC["Engine Core (Go)"]:::GoCore
    end

    %% Subsystem Modules
    subgraph "Subsystem Modules"
        R["Rendering Module (Ebiten)"]:::SubModule
        I["Input Module (Ebiten)"]:::SubModule
        A["Audio Module (Beep)"]:::SubModule
    end

    %% Scripting & Mod Loader
    subgraph "Scripting & Mod Loader"
        L["Lua Interpreter (Gopher-Lua)"]:::ScriptModule
        ML["Mod Loader"]:::ScriptModule
        GS["Game Script (mod/game/init.lua)"]:::ScriptModule
        subgraph "Mod Scripts"
            PS["Player Script (mod/player/init.lua)"]:::ScriptModule
            ES["Enemy Script (mod/enemy/slime.lua)"]:::ScriptModule
            IS["Items Script (mod/items/potions.lua)"]:::ScriptModule
        end
    end

    %% Asset Manager
    AM["Asset Manager"]:::AssetModule

    %% Planned Module
    ECS["Planned: ECS System"]:::PlannedModule

    %% Connections from Engine Core to Subsystems
    EC -->|"initializes"| R
    EC -->|"initializes"| I
    EC -->|"initializes"| A
    EC -->|"initializes"| L

    %% Connections within Scripting subsystem
    L -->|"loads"| ML
    ML -->|"loads"| GS
    ML -->|"loads"| PS
    ML -->|"loads"| ES
    ML -->|"loads"| IS

    %% Asset Manager supplies assets to Rendering and Audio
    AM -->|"provides assets"| R
    AM -->|"provides assets"| A

    %% Planned ECS connection
    EC -->|"future integration"| ECS

    %% Styles and Classes
    class EC GoCore
    class R,I,A SubModule
    class L,ML,GS,PS,ES,IS ScriptModule
    class AM AssetModule
    class ECS PlannedModule

    %% Click Events
    click EC "https://github.com/joeliranzo/luango/blob/main/main.go"
    click L "https://github.com/joeliranzo/luango/blob/main/mod/game/init.lua"
    click ML "https://github.com/joeliranzo/luango/tree/main/mod/"
    click PS "https://github.com/joeliranzo/luango/blob/main/mod/player/init.lua"
    click ES "https://github.com/joeliranzo/luango/blob/main/mod/enemy/slime.lua"
    click IS "https://github.com/joeliranzo/luango/blob/main/mod/items/potions.lua"
    click AM "https://github.com/joeliranzo/luango/tree/main/assets/"

    %% Class Definitions
    classDef GoCore fill:#AED6F1,stroke:#1F618D,stroke-width:2px;
    classDef SubModule fill:#A9DFBF,stroke:#196F3D,stroke-width:2px;
    classDef ScriptModule fill:#F9E79F,stroke:#B7950B,stroke-width:2px;
    classDef AssetModule fill:#FAD7A0,stroke:#E67E22,stroke-width:2px;
    classDef PlannedModule fill:#D7BDE2,stroke:#6C3483,stroke-width:2px,stroke-dasharray:5,5;
```
