# ptom76/storagebox-fabric architecture

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

## Overview

##### Project Type and Purpose
- The README points to a CurseForge page, confirming that it is a Minecraft mod. The file structure indicates that it handles both client-side and server-side aspects, and it makes use of mixins to modify Minecraft’s engine behavior.

##### Analysis of the File Structure
- Top-level directories include configuration files (gradle-related files), the build system (Gradle scripts), and a primary source tree under “src/main”.
- StorageBoxMod (likely the initialization class registering the mod’s features).
- StorageBoxClient and StorageBoxServer, which handle client-side and server-side operations respectively.
- StorageBoxScreen and StorageBoxScreenHandler, which are responsible for the GUI.
- Additional utility classes like ModConfig, StorageBoxInventory, StorageBoxUtil, and recipe serializers.
- The “mixin” subdirectory contains several mixin classes that modify or extend vanilla Minecraft behavior (e.g., ItemEntityAccessor, ItemModelManagerMixin). These are crucial for integrating seamlessly with the game.
- The “resources” directory comprises assets (textures, models, language files) and data files (recipes in JSON format) which are used to configure in-game items and their behavior.
- Additionally, there is a Fabric mod descriptor (fabric.mod.json) and related mixin configuration files that dictate how the mixins are applied.

a. Main Components to Include:
- Fabric Mod Loader: Represent the Minecraft mod loading framework.
- Core Mod Initialization and Configuration:
- StorageBoxMod: Central entry point that bootstraps the mod.
- ModConfig: Handles configuration settings.
- Client-side Operations:
- StorageBoxClient
- StorageBoxScreen and StorageBoxScreenHandler: Represent the GUI components.
- Item model classes and hooks (e.g., ItemModelManagerHooks) affecting rendering.
- Server-side Operations:
- StorageBoxServer: Manages game logic on the server side.
- Inventory and item logic (StorageBoxInventory, StorageBoxItem, StorageBoxSlot).
- Data Management:
- Recipe serializers (StorageBoxRecipeSerializer, auto collection recipes).
- JSON resources under data and assets which define recipes, models, translations, and textures.
- Mixin Components:
- Various mixins (e.g., ItemPickupMixin, ItemStackComponentizationFixMixin) that intercept or modify vanilla Minecraft behavior.
- External Systems:
- Gradle Build System for compiling and packaging the mod.
- GitHub workflows for CI/CD (under .github directory).

b. Relationships and Interactions:
- Initialization flow from StorageBoxMod to both client-side (StorageBoxClient, GUI components) and server-side (StorageBoxServer, Inventory management) components.
- Data flow from resource files (assets and data JSON files) into components like StorageBoxRecipeSerializer.
- Configuration flow from ModConfig to various mod parts.

c. Architectural Patterns and Design Principles:
- Separation of Concerns: Clear distinction between client-side (UI, rendering) and server-side (game logic) operations.
- Use of mixins: Aspect-oriented programming style to modify behavior of existing classes without modifying their source.
- Config-driven Behavior: XML/JSON files (recipes, models, translations) allow easy customization without code changes.
- Modular Structure: Independent classes and packages for different functionalities (e.g., API interfaces, mixins, utility classes).

d. Key Technologies and Frameworks:
- Java (primary programming language).
- Fabric API and associated modding libraries.
- Gradle (build automation).
- Mixin framework (for runtime modifications of Minecraft code).
- JSON resource files for assets and data configurations.

##### Specific Elements
- Clear labels: Ensure each component, such as “StorageBoxMod”, “StorageBoxClient”, “StorageBoxServer”, “StorageBoxRecipeSerializer”, and “Mixin Handlers” are clearly labeled.
- Annotations highlighting the role of external systems such as the Gradle build process and GitHub workflows for CI/CD.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Fabric Integration
    subgraph "Fabric Integration"
        FM1["Fabric Mod Descriptor"]
        FM2["Mixin Config Client"]
        FM3["Mixin Config"]
    end

    %% Core Initialization and Configuration
    subgraph "Core Initialization and Configuration"
        C1["StorageBoxMod"]
        C2["ModConfig"]
    end

    %% Client-side Operations
    subgraph "Client-side Operations"
        CL1["StorageBoxClient"]
        CL2["StorageBoxScreen"]
        CL3["StorageBoxScreenHandler"]
        CL4["ItemModelManagerHooks"]
    end

    %% Server-side Operations
    subgraph "Server-side Operations"
        SV1["StorageBoxServer"]
        SV2["StorageBoxInventory"]
        SV3["StorageBoxItem"]
        SV4["StorageBoxSlot"]
    end

    %% Data Management
    subgraph "Data Management"
        D1["StorageBoxRecipeSerializer"]
        D2["Assets"]
        D3["Data"]
    end

    %% Mixin Components
    subgraph "Mixin Components"
        M1["ItemEntityAccessor"]
        M2["ItemModelManagerMixin"]
        M3["ItemPickupMixin"]
        M4["ItemStackComponentizationFixMixin"]
        M5["KeyBindingAccessor"]
    end

    %% External Systems
    subgraph "External Systems"
        EX1["Gradle Build System"]
        EX2["CI/CD Workflows"]
    end

    %% Connections: Fabric Integration -> Core Initialization
    FM1 -->|"loads mod"| C1
    FM2 --> C1
    FM3 --> C1

    %% Configuration influences core mod
    C2 --> C1

    %% Core Initialization to Client-side Operations
    C1 -->|"initializes"| CL1
    C1 -->|"initializes"| SV1

    %% Client-side internal flow
    CL1 -->|"triggers GUI"| CL2
    CL2 --> CL3
    CL1 --> CL4

    %% Server-side internal flow
    SV1 --> SV2
    SV1 --> SV3
    SV2 --> SV4

    %% Data flows into recipe serializer
    D2 --> D1
    D3 --> D1

    %% Mixins influencing components (dashed arrows)
    M2 ---|"modifies rendering"| CL4
    M3 ---|"alters game logic"| SV3
    M1 ---|"adjusts item behavior"| SV3
    M4 ---|"fixes inventory issues"| SV2
    M5 ---|"affects client input"| CL1

    %% External Systems integration
    EX1 -->|"builds mod"| C1
    EX2 --> EX1

    %% Class definitions for color styling
    classDef fabric fill:#cfe2f3,stroke:#0b5394,stroke-width:2px;
    classDef core fill:#f4cccc,stroke:#b45f06,stroke-width:2px;
    classDef client fill:#c9daf8,stroke:#1155cc,stroke-width:2px;
    classDef server fill:#d9ead3,stroke:#38761d,stroke-width:2px;
    classDef data fill:#ffe599,stroke:#bf9000,stroke-width:2px;
    classDef mixin fill:#ead1dc,stroke:#741b47,stroke-width:2px;
    classDef external fill:#fff2cc,stroke:#b2a61d,stroke-width:2px;

    %% Apply classes
    class FM1,FM2,FM3 fabric;
    class C1,C2 core;
    class CL1,CL2,CL3,CL4 client;
    class SV1,SV2,SV3,SV4 server;
    class D1,D2,D3 data;
    class M1,M2,M3,M4,M5 mixin;
    class EX1,EX2 external;

    %% Click Events for Fabric Integration
    click FM1 "https://github.com/ptom76/storagebox-fabric/blob/1.21.5/src/main/resources/fabric.mod.json"
    click FM2 "https://github.com/ptom76/storagebox-fabric/blob/1.21.5/src/main/resources/storagebox.client.mixins.json"
    click FM3 "https://github.com/ptom76/storagebox-fabric/blob/1.21.5/src/main/resources/storagebox.mixins.json"

    %% Click Events for Core Initialization and Configuration
    click C1 "https://github.com/ptom76/storagebox-fabric/blob/1.21.5/src/main/java/net/pitan76/storagebox/StorageBoxMod.java"
    click C2 "https://github.com/ptom76/storagebox-fabric/blob/1.21.5/src/main/java/net/pitan76/storagebox/ModConfig.java"

    %% Click Events for Client-side Operations
    click CL1 "https://github.com/ptom76/storagebox-fabric/blob/1.21.5/src/main/java/net/pitan76/storagebox/StorageBoxClient.java"
    click CL2 "https://github.com/ptom76/storagebox-fabric/blob/1.21.5/src/main/java/net/pitan76/storagebox/StorageBoxScreen.java"
    click CL3 "https://github.com/ptom76/storagebox-fabric/blob/1.21.5/src/main/java/net/pitan76/storagebox/StorageBoxScreenHandler.java"
    click CL4 "https://github.com/ptom76/storagebox-fabric/blob/1.21.5/src/main/java/net/pitan76/storagebox/ItemModelManagerHooks.java"

    %% Click Events for Server-side Operations
    click SV1 "https://github.com/ptom76/storagebox-fabric/blob/1.21.5/src/main/java/net/pitan76/storagebox/StorageBoxServer.java"
    click SV2 "https://github.com/ptom76/storagebox-fabric/blob/1.21.5/src/main/java/net/pitan76/storagebox/StorageBoxInventory.java"
    click SV3 "https://github.com/ptom76/storagebox-fabric/blob/1.21.5/src/main/java/net/pitan76/storagebox/StorageBoxItem.java"
    click SV4 "https://github.com/ptom76/storagebox-fabric/blob/1.21.5/src/main/java/net/pitan76/storagebox/StorageBoxSlot.java"

    %% Click Events for Data Management
    click D1 "https://github.com/ptom76/storagebox-fabric/blob/1.21.5/src/main/java/net/pitan76/storagebox/StorageBoxRecipeSerializer.java"
    click D2 "https://github.com/ptom76/storagebox-fabric/tree/1.21.5/src/main/resources/assets/storagebox/"
    click D3 "https://github.com/ptom76/storagebox-fabric/tree/1.21.5/src/main/resources/data/storagebox/"

    %% Click Events for Mixin Components
    click M1 "https://github.com/ptom76/storagebox-fabric/blob/1.21.5/src/main/java/net/pitan76/storagebox/mixin/ItemEntityAccessor.java"
    click M2 "https://github.com/ptom76/storagebox-fabric/blob/1.21.5/src/main/java/net/pitan76/storagebox/mixin/ItemModelManagerMixin.java"
    click M3 "https://github.com/ptom76/storagebox-fabric/blob/1.21.5/src/main/java/net/pitan76/storagebox/mixin/ItemPickupMixin.java"
    click M4 "https://github.com/ptom76/storagebox-fabric/blob/1.21.5/src/main/java/net/pitan76/storagebox/mixin/ItemStackComponentizationFixMixin.java"
    click M5 "https://github.com/ptom76/storagebox-fabric/blob/1.21.5/src/main/java/net/pitan76/storagebox/mixin/KeyBindingAccessor.java"

    %% Click Events for External Systems
    click EX1 "https://github.com/ptom76/storagebox-fabric/blob/1.21.5/build.gradle"
    click EX2 "https://github.com/ptom76/storagebox-fabric/blob/1.21.5/.github/workflows/main.yml"
```
