# lambda-client/lambda architecture

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

- Interactive diagram: https://gitdiagram.com/lambda-client/lambda
- Repository: https://github.com/lambda-client/lambda

## Overview

##### Main high-level components
- Core Mod Loader / Bootstrap: Represented by classes such as LambdaCoreMod, LambdaMod, and Loader.kt, which initialize and hook the mod into the Minecraft/Forge lifecycle.
- Mixin Injection Layer: Depicted under the “src/main/java/com/lambda/mixin” package. This layer shows how mixins (e.g., MixinMinecraft, MixinEntity, MixinGuiChat, etc.) are used to intercept and modify Minecraft behavior.
- Plugin System: Located in “src/main/kotlin/com/lambda/client/plugin” with classes like PluginLoader, PluginManager, and PluginClassLoader. This component highlights the visionary plugin architecture that permits external modules to be dynamically loaded without forking the core code.
- Module and Command Systems: Under “src/main/kotlin/com/lambda/client/module” and “src/main/kotlin/com/lambda/client/command.” These parts handle user commands (prefix “;”), module activation/deactivation, and event dispatching through the event bus (src/main/kotlin/com/lambda/client/event and associated eventbus packages).
- GUI Components: Two major GUI facets:
- ClickGUI: For configuration and plugin management (found under “src/main/kotlin/com/lambda/client/gui/clickgui” and “.../component” subpackages).
- HUD GUI: For in-game overlays and displays (found under “src/main/kotlin/com/lambda/client/gui/hudgui”).
- Additionally, there are legacy “mc” GUI elements and “rgui” components.
- Manager and Setting Systems: Show the configuration and organizational code in “src/main/kotlin/com/lambda/client/manager/” and “src/main/kotlin/com/lambda/client/setting/”. These components coordinate module states, settings, and various utilities.
- Utility Classes: This module aggregates common utilities (e.g., graphics rendering, math operations, text formatting, threads, etc.) which are located under “src/main/kotlin/com/lambda/client/util/…” and support the other components.
- External Resources and Assets: The “src/main/resources” tree includes assets such as textures, fonts, shaders, and configuration files (like mixins.lambda.json) which are critical for the mod’s integration with Minecraft’s resource system.

##### Relationships and interactions
- The Core Mod Loader initializes and then hands over control to the mixin and plugin layers.
- The Mixin Injection Layer intercepts Minecraft’s native code and communicates back to the core mod modules for integrated behaviors (for example, modifying rendering, handling events, and overriding default GUIs).
- The Plugin and Module systems are linked; the Plugin Manager loads external plugin jars and integrates them with the Module Manager, which in turn utilizes settings and event buses.
- The Command system is connected with both the module logic and GUI, allowing user input to toggle modules, change settings, and execute custom commands.
- The GUI components display information and allow configuration; they interact with Module and Setting Managers to update changes in real time.
- Managers and Utility classes provide common functions and support the underlying tasks required by commands, events, GUI elements, and plugins.

##### Important architectural patterns/design principles
- Modularity and Extensibility: The plugin system and module architecture promote encapsulated components that can be added, updated, or removed without altering the core logic.
- Mixin-based Code Injection: By using mixins, the mod adapts and modifies the baseline Minecraft behavior without directly altering Minecraft’s code.
- Event-Driven Architecture: The event bus (with asynchronous and synchronous variants) underlies communication between modules, commands, and input systems.
- Separation of Concerns: Clear separation between the core mod initialization, UI, command processing, and backend utilities ensures maintainable and scalable code.

##### Relevant technologies, frameworks, or libraries
- Minecraft Forge for modding.
- Gradle build system and Java 8 (with Kotlin interoperability) as the primary development tools.
- Mixin framework (from SpongePowered or similar) to perform bytecode-level injections.
- Kotlin and Java standard libraries along with various custom utilities for math, graphics, and event handling.

- Clear, labeled components for each major part (Core Mod Loader, Mixin Injection, Plugin System, Command & Module Processing, GUI Components, Manager/Settings, Utility Libraries, and External Assets).

Happy diagramming!

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Core Mod Loader / Bootstrap"
        Core1["LambdaCoreMod"]:::bootstrap
        Core2["LambdaMod"]:::bootstrap
        Core3["Loader"]:::bootstrap
    end

    subgraph "Mixin Injection Layer"
        Mixin["Mixin Injection"]:::mixin
    end

    subgraph "Plugin System"
        PluginLoader["PluginLoader"]:::plugin
        PluginManager["PluginManager"]:::plugin
        PluginClassLoader["PluginClassLoader"]:::plugin
        PluginAPI["Plugin API"]:::plugin
    end

    subgraph "Module & Command Systems"
        ModuleManager["Module Manager"]:::module
        CommandSystem["Command System"]:::module
    end

    subgraph "GUI Components"
        ClickGUI["ClickGUI"]:::gui
        HUDGUI["HUD GUI"]:::gui
        MCGUI["Legacy MC GUI"]:::gui
        RGUI["Alternative RGUI"]:::gui
    end

    subgraph "Event Handling"
        EventBus["Event Bus"]:::event
    end

    subgraph "Manager and Setting Systems"
        Manager["Manager System"]:::manager
        Setting["Setting System"]:::manager
    end

    subgraph "Utility Classes"
        Utility["Utility Classes"]:::utility
    end

    subgraph "External Resources & Assets"
        External["External Assets"]:::external
    end

    %% Connections
    Core1 -->|"init"| Mixin
    Core1 -->|"init"| PluginLoader
    Core1 -->|"init"| ModuleManager

    PluginLoader -->|"loads"| ModuleManager
    PluginManager -->|"manages"| ModuleManager

    ModuleManager -->|"dispatches"| EventBus
    CommandSystem -->|"triggers"| EventBus

    ClickGUI -->|"configures"| ModuleManager
    ClickGUI -->|"updates"| Manager
    HUDGUI -->|"displays"| ModuleManager
    MCGUI -->|"legacyUI"| ModuleManager
    RGUI -->|"legacyUI"| ModuleManager

    Manager -->|"controls"| ModuleManager
    Setting -->|"configures"| ModuleManager

    Utility -->|"supports"| PluginLoader
    Utility -->|"supports"| ModuleManager
    Utility -->|"supports"| CommandSystem

    External -->|"provides"| ClickGUI
    External -->|"provides"| HUDGUI

    %% Click Events
    click Core1 "https://github.com/lambda-client/lambda/blob/master/src/main/kotlin/com/lambda/client/LambdaCoreMod.kt"
    click Core2 "https://github.com/lambda-client/lambda/blob/master/src/main/kotlin/com/lambda/client/LambdaMod.kt"
    click Core3 "https://github.com/lambda-client/lambda/blob/master/src/main/kotlin/com/lambda/client/Loader.kt"
    click Mixin "https://github.com/lambda-client/lambda/tree/master/src/main/java/com/lambda/mixin"
    click PluginLoader "https://github.com/lambda-client/lambda/blob/master/src/main/kotlin/com/lambda/client/plugin/PluginLoader.kt"
    click PluginManager "https://github.com/lambda-client/lambda/blob/master/src/main/kotlin/com/lambda/client/plugin/PluginManager.kt"
    click PluginClassLoader "https://github.com/lambda-client/lambda/blob/master/src/main/kotlin/com/lambda/client/plugin/PluginClassLoader.kt"
    click PluginAPI "https://github.com/lambda-client/lambda/tree/master/src/main/kotlin/com/lambda/client/plugin/api"
    click ModuleManager "https://github.com/lambda-client/lambda/tree/master/src/main/kotlin/com/lambda/client/module"
    click CommandSystem "https://github.com/lambda-client/lambda/tree/master/src/main/kotlin/com/lambda/client/command"
    click ClickGUI "https://github.com/lambda-client/lambda/tree/master/src/main/kotlin/com/lambda/client/gui/clickgui"
    click HUDGUI "https://github.com/lambda-client/lambda/tree/master/src/main/kotlin/com/lambda/client/gui/hudgui"
    click MCGUI "https://github.com/lambda-client/lambda/tree/master/src/main/kotlin/com/lambda/client/gui/mc"
    click RGUI "https://github.com/lambda-client/lambda/tree/master/src/main/kotlin/com/lambda/client/gui/rgui"
    click EventBus "https://github.com/lambda-client/lambda/tree/master/src/main/kotlin/com/lambda/client/event"
    click Manager "https://github.com/lambda-client/lambda/tree/master/src/main/kotlin/com/lambda/client/manager"
    click Setting "https://github.com/lambda-client/lambda/tree/master/src/main/kotlin/com/lambda/client/setting"
    click Utility "https://github.com/lambda-client/lambda/tree/master/src/main/kotlin/com/lambda/client/util"
    click External "https://github.com/lambda-client/lambda/tree/master/src/main/resources"

    %% Styles
    classDef bootstrap fill:#f9d0c4,stroke:#333,stroke-width:2px;
    classDef mixin fill:#d0e1f9,stroke:#333,stroke-width:2px;
    classDef plugin fill:#c7f9d0,stroke:#333,stroke-width:2px;
    classDef module fill:#ffe6ad,stroke:#333,stroke-width:2px;
    classDef gui fill:#efbdff,stroke:#333,stroke-width:2px;
    classDef event fill:#dff9fa,stroke:#333,stroke-width:2px;
    classDef manager fill:#fceabb,stroke:#333,stroke-width:2px;
    classDef utility fill:#d3e0ea,stroke:#333,stroke-width:2px;
    classDef external fill:#e9c5f5,stroke:#333,stroke-width:2px;
```
