# auxilor/libreforge architecture

> Architecture diagram of the GitHub repository auxilor/libreforge, 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/auxilor/libreforge
- Repository: https://github.com/auxilor/libreforge

## Overview

##### Main Components
- Loader Module: Represented by the “loader” directory. This is where the entry point of the plugin is defined (LibreforgePlugin and LibreforgeLoader classes). It is responsible for initializing the plugin, loading configurations (from YAML files such as config.yml, chains.yml, etc.), and setting up the environment.
- Core Module: This is the heart of libreforge and is divided among submodules (common, legacy, modern). Under “core/common” you find the primary business logic, including:
– Commands: Responsible for interacting with in-game commands (see the commands package with CommandLibreforge, CommandPointsGive, etc.).
– Conditions: A rich set of classes that define when an effect may fire (organized under conditions, with many implementations).
– Effects: Modules that define what actions to execute (e.g., EffectAddDamage, EffectGiveXp, etc., along with dedicated sub-packages for animations, bossbars, particles, and more).
– Triggers: Mechanisms to detect game events and then dispatch configured actions.
– Filters, Counters, Mutators, and Placeholders: Each acts as a building block for the engine to process modifications and data flow, influencing when and how effects are applied.
– Configs: YAML configuration parsing and mapping (in configs packages). This is where the “scripting” aspect is tied into the engine.
- Gradle Plugin: Found under “gradle-plugin”. This is used to facilitate the build and, possibly, the distribution of the project.
- Library/JAR Dependencies: The “lib” directory shows external jars (such as AxEnvoy, FancyNpcs, TAB, etc.) that libreforge leverages for integrations.

##### Relationships and Data Flows
- Within the Core, split the engine into “Effects”, “Conditions”, “Triggers”, “Commands”, and “Filters”. Show that commands can trigger effects (often via conditions being checked first) and that triggers are responsible for detecting in-game events that route to conditions and then fire effects.
- That the system supports multiple modes (legacy and modern) in the Core, so include distinct sections for “legacy proxy” and “modern proxy” implementations, showing that there is a translation layer in between (as seen in subpackages under core/legacy/proxy and core/modern/proxy).

##### Architectural Patterns and Design Principles
- Modular Architecture: Emphasize the separation into loader, core (with further modular subdivisions), gradle plugin, and integration libraries. Each module should be a clearly demarcated unit of responsibility.
- Plugin/Extension Pattern: The integrations and the plugin loader indicate a pluggable design. You might represent this using “adapter” symbols for integrations.
- Configuration-Driven Behavior: Many components react to YAML configuration data. Mark these configuration dependencies clearly and show how resource files (found in core/common/src/main/resources) are used.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Initialization/Loader
    subgraph "Initialization/Loader"
        L1["Plugin Entry Point"]:::loader
        L2["Load YAML Config (config.yml, chains.yml, etc.)"]:::loader
        L1 --> L2
    end

    %% Connection from Loader to Core Engine
    L2 -->|"PassConfigData"| CoreEngine

    %% Core Engine subdivisions
    subgraph "Core Engine"
        CoreEngine["Core Engine"]:::core
        Command["Commands"]:::core
        Condition["Conditions"]:::core
        Effect["Effects"]:::core
        Trigger["Triggers"]:::core
        Config["Configs"]:::core
        Other["Filters/Counters/Mutators/Placeholders"]:::core
        Legacy["Legacy Proxy"]:::core
        Modern["Modern Proxy"]:::core

        %% Internal relationships
        CoreEngine --> Command
        CoreEngine --> Condition
        CoreEngine --> Effect
        CoreEngine --> Trigger
        CoreEngine --> Config
        CoreEngine --> Other
        CoreEngine --> Legacy
        CoreEngine --> Modern

        %% Event-driven flow
        Trigger -->|"Check"| Condition
        Condition -->|"Execute"| Effect
    end

    %% Core calls Integrations
    CoreEngine -->|"CallsIntegrations"| Integrations

    %% External Integrations
    subgraph "External Integrations & Dependencies"
        Integrations["Integrations"]:::integration
        External["External Plugins/Systems"]:::integration
        Integrations -->|"Adapter"| External
    end

    %% Build & Distribution
    subgraph "Build & Distribution"
        Gradle["Gradle Plugin"]:::build
        Libs["Library/JAR Dependencies"]:::build
        Gradle --> Libs
    end

    %% Click Events for Loader and Core components
    click L1 "https://github.com/auxilor/libreforge/tree/master/loader/src/main/kotlin/com/willfp/libreforge/loader"
    click CoreEngine "https://github.com/auxilor/libreforge/tree/master/core/common"
    click Legacy "https://github.com/auxilor/libreforge/tree/master/core/legacy"
    click Modern "https://github.com/auxilor/libreforge/tree/master/core/modern"
    click Integrations "https://github.com/auxilor/libreforge/tree/master/core/common/src/main/kotlin/com/willfp/libreforge/integrations"
    click Gradle "https://github.com/auxilor/libreforge/tree/master/gradle-plugin"
    click Libs "https://github.com/auxilor/libreforge/tree/master/lib"
    click Command "https://github.com/auxilor/libreforge/tree/master/core/common/src/main/kotlin/com/willfp/libreforge/commands"
    click Condition "https://github.com/auxilor/libreforge/tree/master/core/common/src/main/kotlin/com/willfp/libreforge/conditions"
    click Effect "https://github.com/auxilor/libreforge/tree/master/core/common/src/main/kotlin/com/willfp/libreforge/effects"
    click Trigger "https://github.com/auxilor/libreforge/tree/master/core/common/src/main/kotlin/com/willfp/libreforge/triggers"
    click Config "https://github.com/auxilor/libreforge/tree/master/core/common/src/main/kotlin/com/willfp/libreforge/configs"
    click Other "https://github.com/auxilor/libreforge/tree/master/core/common/src/main/kotlin/com/willfp/libreforge/filters"

    %% Styles
    classDef loader fill:#a2d2ff,stroke:#000,stroke-width:2px;
    classDef core fill:#bde0fe,stroke:#000,stroke-width:2px;
    classDef integration fill:#ffafcc,stroke:#000,stroke-width:2px;
    classDef build fill:#caffbf,stroke:#000,stroke-width:2px;
```
