# thedarkcolour/kotlinforforge architecture

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

- Interactive diagram: https://gitdiagram.com/thedarkcolour/kotlinforforge
- Repository: https://github.com/thedarkcolour/kotlinforforge

## Overview

##### Main Components
- Modules for each function:
- kfflang (Kotlin Language Loader): Provides support classes (such as KotlinLanguageProvider, KotlinModContainer, KotlinModLoadingContext) and integration with Forge’s mod loading system.
- kfflib (Kotlin Library): Contains utility functions and integration utilities like event bus helpers, vector math utilities, logging, and deferred registration.
- kffmod (Kotlin Mod API): Acts as the bridge between your custom mod code and the Forge mod loader.
- Variants by Loader:
- The “forge” directory houses the standard Forge implementation.
- The “neoforge” directory houses the variant for NeoForge.
- Additional Combined/Integrated projects: The “combined” folder (and its own sub-modules) shows how one might merge modules for unified distribution.

##### Relationships & Interactions
- The build system (Gradle) orchestrates the multi-module structure.
- kfflang uses or exposes capabilities that allow object declarations to be recognized as mods/events by interacting with the underlying Forge API.
- kfflib provides utility functions (e.g., vector utilities, deferred register helpers) that are needed by kfflang and kffmod.
- kffmod leverages both kfflang and kfflib to simplify the mod development process.
- External Interaction: The system integrates with external dependencies such as the Kotlin standard library, Kotlin reflection, JSON serialization libraries, and the Minecraft Forge API.
- There is a clear separation between the code for different mod loader variants (Forge vs. NeoForge). Each variant’s directory contains parallel structures (kfflang, kfflib, kffmod) with subtle differences regarding how the integration with the specific mod loader is performed.

##### Important Architectural Patterns and Design Principles
- Modular Architecture: The project is broken into independent but interrelated submodules. This allows for individual modules (language support, utility functions, mod API) to be updated or extended independently.
- Abstraction & Separation of Concerns: Each module has a single focus – language loading, supporting utilities, or mod integration. This is reinforced in the README by how integration instructions are separated into distinct Gradle dependencies based on mod loader variants.
- Extensibility: The library is designed to be merged into existing projects. The modularized approach makes it easier for developers to integrate only the parts they need.

##### Relevant Technologies & Frameworks
- Gradle (build system) – as seen with numerous build.gradle.kts files.
- Kotlin (the primary language), including its standard library, reflection, coroutine, and serialization features.
- Minecraft Forge API – for mod loading.
- Optional components for NeoForge integration.

- A “Gradle Build System” block that connects to all modules indicating build dependency and organization.
- kfflang provides language extension support to kffmod.
- kfflib supports both kfflang and kffmod with utility functions.
- Including a side-by-side comparison showing how the “forge” and “neoforge” directories mirror one another yet target different mod loading interfaces.

##### Final Touches
- Do not over-simplify by just lumping modules together; even small submodules (such as “Forging utilities” in kfflib) can be grouped under their parent module.

– The Gradle build system orchestrating the project.
– External blocks for Kotlin and Forge APIs.

## Diagram (Mermaid)

```mermaid
graph TD
    GB["Gradle Build System"]:::build

    subgraph "Forge Variant"
        direction TB
        F_L["KFF Language Module"]:::module
        F_LIB["KFF Library Module"]:::module
        F_MOD["KFF Mod Module"]:::module
    end

    subgraph "NeoForge Variant"
        direction TB
        NF_L["KFF Language Module"]:::module
        NF_LIB["KFF Library Module"]:::module
        NF_MOD["KFF Mod Module"]:::module
    end

    subgraph "Combined Distribution"
        direction TB
        C_L["KFF Language Module"]:::combined
        C_LIB["KFF Library Module"]:::combined
        C_MOD["KFF Mod Module"]:::combined
    end

    subgraph "External Ecosystem"
        direction TB
        E_KSL["Kotlin Std Lib"]:::external
        E_REF["Kotlin Reflection"]:::external
        E_JSON["JSON Serialization"]:::external
        E_COR["Coroutines"]:::external
        E_FORGE["Minecraft Forge API"]:::external
    end

    %% Gradle builds all modules
    GB --> F_L
    GB --> F_LIB
    GB --> F_MOD
    GB --> NF_L
    GB --> NF_LIB
    GB --> NF_MOD
    GB --> C_L
    GB --> C_LIB
    GB --> C_MOD

    %% Internal interactions within Forge Variant
    F_L -->|"provides_support"| F_MOD
    F_LIB -->|"supports"| F_L
    F_LIB -->|"supports"| F_MOD

    %% Internal interactions within NeoForge Variant
    NF_L -->|"provides_support"| NF_MOD
    NF_LIB -->|"supports"| NF_L
    NF_LIB -->|"supports"| NF_MOD

    %% External dependencies for Forge Variant
    E_FORGE --> F_L
    E_FORGE --> F_MOD
    E_KSL --> F_LIB
    E_KSL --> F_L
    E_KSL --> F_MOD
    E_REF --> F_LIB
    E_COR --> F_LIB
    E_JSON --> F_LIB

    %% External dependencies for NeoForge Variant
    E_FORGE --> NF_L
    E_FORGE --> NF_MOD
    E_KSL --> NF_LIB
    E_KSL --> NF_L
    E_KSL --> NF_MOD
    E_REF --> NF_LIB
    E_COR --> NF_LIB
    E_JSON --> NF_LIB

    %% External dependencies for Combined Distribution
    E_FORGE --> C_L
    E_FORGE --> C_MOD
    E_KSL --> C_LIB
    E_KSL --> C_L
    E_KSL --> C_MOD
    E_REF --> C_LIB
    E_COR --> C_LIB
    E_JSON --> C_LIB

    %% Click Events for Component Mapping
    click F_L "https://github.com/thedarkcolour/kotlinforforge/tree/5.x/forge/kfflang"
    click F_LIB "https://github.com/thedarkcolour/kotlinforforge/tree/5.x/forge/kfflib"
    click F_MOD "https://github.com/thedarkcolour/kotlinforforge/tree/5.x/forge/kffmod"
    click NF_L "https://github.com/thedarkcolour/kotlinforforge/tree/5.x/neoforge/kfflang"
    click NF_LIB "https://github.com/thedarkcolour/kotlinforforge/tree/5.x/neoforge/kfflib"
    click NF_MOD "https://github.com/thedarkcolour/kotlinforforge/tree/5.x/neoforge/kffmod"
    click C_L "https://github.com/thedarkcolour/kotlinforforge/tree/5.x/combined/kfflang"
    click C_LIB "https://github.com/thedarkcolour/kotlinforforge/tree/5.x/combined/kfflib"
    click C_MOD "https://github.com/thedarkcolour/kotlinforforge/tree/5.x/combined/kffmod"
    click GB "https://github.com/thedarkcolour/kotlinforforge/blob/5.x/build.gradle.kts"

%% Styling
classDef module fill:#a7d8f0,stroke:#0791d1,stroke-width:2px;
classDef build fill:#f9d5bb,stroke:#e29578,stroke-width:2px;
classDef external fill:#dcd3e7,stroke:#a6a2c7,stroke-width:2px;
classDef combined fill:#ffe0b5,stroke:#ffa500,stroke-width:2px;
```
