# achang0611/moneycardkotlinreloaded architecture

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

- Interactive diagram: https://gitdiagram.com/achang0611/moneycardkotlinreloaded
- Repository: https://github.com/achang0611/moneycardkotlinreloaded

## Overview

##### Main Components
- Plugin Entry Point & Configuration:
– The plugin.yml in src/main/resources defines metadata and the entry point.
– The main class (for instance, MoneyCardKotlin.kt) is where the plugin is bootstrapped.
- Minecraft API Integration Layer:
– This includes the classes under the “minecraft” package (e.g., ChatFormatter, InventoryEditor, Permissions, Sender) and sub-components like Commands and Events.
– Commands are organized under commands (with executors such as GetCard, GiveCard, ReloadPlugin) and event listeners (Atomic event handlers like AntiCardCrafting, AntiCardTrading, CardChangeToMoneyEvent) which interface directly with Minecraft’s server API.
- Domain Business Logic Layer:
– Found in the “logic” package, this layer holds classes like Bank, CardConverter, CardDetector, CardFactory, CardInfoValidator, etc.
– It encapsulates the core functionalities, data processing, and rules for handling “cards” (including persistent data handling via MoneyCardPersistentData.kt).
- Utility Components:
– The “utils” package provides helper classes for tasks such as error handling, JSON management (JsonManager), resource I/O, and string formatting.
- Resources & Configuration:
– Several JSON files (card_item_setting.json, create_card_rules.json, message.json) provide configuration and rules that the plugin uses at runtime.
– Build and project configuration files (gradle.build.kts, settings.gradle.kts, etc.) support the build and deployment process.

##### Relationships and Interactions
- The Plugin Entry Point initializes and registers the components in the Minecraft API Integration layer.
- When Minecraft events occur (e.g., a player issuing a command or an in-game event like crafting), the respective event listeners or command executors are triggered.
- These handlers then delegate to the Domain Business Logic layer (logic package) to process the request (for example, validating a card using CardInfoValidator or creating a card through CardFactory).
- The business logic might in turn interact with the Utility layer for tasks like reading JSON configuration, logging errors, or formatting strings.
- Finally, changes to game state or card data are applied back to the Minecraft environment via the integration layer.

##### Recognize Key Architectural Patterns
- Layered Architecture: Clear separation between the Minecraft-specific integration (controllers/handlers) and core business logic.
- Modularity: Separation of concerns between command handling, game event processing, and card management logic.
- Extensibility: The design (separating logic, commands, events, and utilities) supports easy future expansion. For example, adding new card types or event handlers without intermixing concerns.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Plugin Initialization
    subgraph "Plugin Initialization"
        P1["MoneyCardKotlin (Main)"]
        P2["plugin.yml"]
    end

    %% Minecraft API Integration Layer
    subgraph "Minecraft API Integration"
        %% Commands and Executors
        subgraph "Commands"
            C1["MoneyCardCommand"]
            C2["GetCard Executor"]
            C3["GiveCard Executor"]
            C4["ReloadPlugin Executor"]
        end
        %% Utility Facets
        subgraph "Utility Facets"
            U1["ChatFormatter"]
            U2["InventoryEditor"]
            U3["Permissions"]
            U4["Sender"]
        end
        %% Event Listeners
        subgraph "Event Listeners"
            E1["AntiCardCrafting"]
            E2["AntiCardTrading"]
            E3["CardChangeToMoneyEvent"]
        end
    end

    %% Domain Business Logic Layer
    subgraph "Domain Business Logic"
        L1["Bank"]
        L2["CardConverter"]
        L3["CardDetector"]
        L4["CardFactory"]
        L5["CardInfoValidator"]
        L6["MoneyCardPersistentData"]
        L7["MoneyCardData"]
        L8["ItemSetting Formatter"]
    end

    %% Utility Components
    subgraph "Utility Components"
        Uti1["Error Management"]
        Uti2["JSON Manager"]
        Uti3["Resource I/O"]
        Uti4["String Formatter"]
    end

    %% Resources & Build Configuration
    subgraph "Resources & Build Configuration"
        %% Runtime Resources
        subgraph "Resources"
            R1["card_item_setting.json"]
            R2["create_card_rules.json"]
            R3["message.json"]
        end
        %% Build Files
        subgraph "Build Files"
            B1["build.gradle.kts"]
            B2["settings.gradle.kts"]
            B3["gradle/wrapper"]
        end
    end

    %% Relationships

    %% Plugin Initialization registers integration components
    P1 -->|"init"| C1
    P1 -->|"init"| U1
    P1 -->|"init"| E1

    %% Integration delegates commands to Business Logic
    C1 -->|"delegate"| L4
    C2 -->|"delegate"| L4
    C3 -->|"delegate"| L4
    C4 -->|"delegate"| L4
    E1 -->|"trigger"| L4
    E2 -->|"trigger"| L4
    E3 -->|"trigger"| L4

    %% Business Logic interactions with Utility Components
    L1 -->|"uses"| Uti2
    L2 -->|"uses"| Uti2
    L3 -->|"uses"| Uti2
    L4 -->|"uses"| Uti2
    L5 -->|"uses"| Uti4
    L6 -->|"uses"| Uti3
    L7 -->|"uses"| Uti3
    L8 -->|"uses"| Uti4

    %% Resources feed Business Logic
    R1 -->|"configures"| L4
    R2 -->|"configures"| L4
    R3 -->|"configures"| L5

    %% Business Logic updates Minecraft environment via Integration facets
    L4 -->|"updates"| U2
    L5 -->|"updates"| U3

    %% Build configuration influences Plugin Initialization
    B1 -->|"build"| P1
    B2 -->|"build"| P1
    B3 -->|"build"| P1

    %% Class Definitions for styling
    classDef plugin fill:#ADD8E6,stroke:#0000FF,stroke-width:2px;
    classDef integration fill:#87CEFA,stroke:#1E90FF,stroke-width:2px;
    classDef logic fill:#90EE90,stroke:#008000,stroke-width:2px;
    classDef utility fill:#FFDAB9,stroke:#FF8C00,stroke-width:2px;
    classDef resources fill:#FFB6C1,stroke:#FF69B4,stroke-width:2px;
    classDef build fill:#DDA0DD,stroke:#9400D3,stroke-width:2px;

    %% Assign classes
    class P1,P2 plugin;
    class C1,C2,C3,C4,U1,U2,U3,U4,E1,E2,E3 integration;
    class L1,L2,L3,L4,L5,L6,L7,L8 logic;
    class Uti1,Uti2,Uti3,Uti4 utility;
    class R1,R2,R3 resources;
    class B1,B2,B3 build;

    %% Click Events for Plugin Entry Point & Configuration
    click P1 "https://github.com/achang0611/moneycardkotlinreloaded/blob/master/src/main/kotlin/com/vm/plugin/MoneyCardKotlin.kt"
    click P2 "https://github.com/achang0611/moneycardkotlinreloaded/blob/master/src/main/resources/plugin.yml"

    %% Click Events for Minecraft API Integration Layer - Commands and Executors
    click C1 "https://github.com/achang0611/moneycardkotlinreloaded/blob/master/src/main/kotlin/com/vm/plugin/minecraft/commands/MoneyCardCommand.kt"
    click C2 "https://github.com/achang0611/moneycardkotlinreloaded/blob/master/src/main/kotlin/com/vm/plugin/minecraft/commands/executors/GetCard.kt"
    click C3 "https://github.com/achang0611/moneycardkotlinreloaded/blob/master/src/main/kotlin/com/vm/plugin/minecraft/commands/executors/GiveCard.kt"
    click C4 "https://github.com/achang0611/moneycardkotlinreloaded/blob/master/src/main/kotlin/com/vm/plugin/minecraft/commands/executors/ReloadPlugin.kt"

    %% Click Events for Minecraft API Integration Layer - Utility Facets
    click U1 "https://github.com/achang0611/moneycardkotlinreloaded/blob/master/src/main/kotlin/com/vm/plugin/minecraft/ChatFormatter.kt"
    click U2 "https://github.com/achang0611/moneycardkotlinreloaded/blob/master/src/main/kotlin/com/vm/plugin/minecraft/InventoryEditor.kt"
    click U3 "https://github.com/achang0611/moneycardkotlinreloaded/blob/master/src/main/kotlin/com/vm/plugin/minecraft/Permissions.kt"
    click U4 "https://github.com/achang0611/moneycardkotlinreloaded/blob/master/src/main/kotlin/com/vm/plugin/minecraft/Sender.kt"

    %% Click Events for Minecraft API Integration Layer - Event Listeners
    click E1 "https://github.com/achang0611/moneycardkotlinreloaded/blob/master/src/main/kotlin/com/vm/plugin/minecraft/events/AntiCardCrafting.kt"
    click E2 "https://github.com/achang0611/moneycardkotlinreloaded/blob/master/src/main/kotlin/com/vm/plugin/minecraft/events/AntiCardTrading.kt"
    click E3 "https://github.com/achang0611/moneycardkotlinreloaded/blob/master/src/main/kotlin/com/vm/plugin/minecraft/events/CardChangeToMoneyEvent.kt"

    %% Click Events for Domain Business Logic Layer
    click L1 "https://github.com/achang0611/moneycardkotlinreloaded/blob/master/src/main/kotlin/com/vm/plugin/logic/Bank.kt"
    click L2 "https://github.com/achang0611/moneycardkotlinreloaded/blob/master/src/main/kotlin/com/vm/plugin/logic/CardConverter.kt"
    click L3 "https://github.com/achang0611/moneycardkotlinreloaded/blob/master/src/main/kotlin/com/vm/plugin/logic/CardDetector.kt"
    click L4 "https://github.com/achang0611/moneycardkotlinreloaded/blob/master/src/main/kotlin/com/vm/plugin/logic/CardFactory.kt"
    click L5 "https://github.com/achang0611/moneycardkotlinreloaded/blob/master/src/main/kotlin/com/vm/plugin/logic/CardInfoValidator.kt"
    click L6 "https://github.com/achang0611/moneycardkotlinreloaded/blob/master/src/main/kotlin/com/vm/plugin/logic/MoneyCardPersistentData.kt"
    click L7 "https://github.com/achang0611/moneycardkotlinreloaded/blob/master/src/main/kotlin/com/vm/plugin/logic/MoneyCardData.kt"
    click L8 "https://github.com/achang0611/moneycardkotlinreloaded/blob/master/src/main/kotlin/com/vm/plugin/logic/ItemSettingFormatter.kt"

    %% Click Events for Utility Components
    click Uti1 "https://github.com/achang0611/moneycardkotlinreloaded/blob/master/src/main/kotlin/com/vm/plugin/utils/Error.kt"
    click Uti2 "https://github.com/achang0611/moneycardkotlinreloaded/blob/master/src/main/kotlin/com/vm/plugin/utils/JsonManager.kt"
    click Uti3 "https://github.com/achang0611/moneycardkotlinreloaded/blob/master/src/main/kotlin/com/vm/plugin/utils/ResourceIO.kt"
    click Uti4 "https://github.com/achang0611/moneycardkotlinreloaded/blob/master/src/main/kotlin/com/vm/plugin/utils/StringFormatter.kt"

    %% Click Events for Resources & Build Configuration
    click R1 "https://github.com/achang0611/moneycardkotlinreloaded/blob/master/src/main/resources/card_item_setting.json"
    click R2 "https://github.com/achang0611/moneycardkotlinreloaded/blob/master/src/main/resources/create_card_rules.json"
    click R3 "https://github.com/achang0611/moneycardkotlinreloaded/blob/master/src/main/resources/message.json"
    click B1 "https://github.com/achang0611/moneycardkotlinreloaded/blob/master/build.gradle.kts"
    click B2 "https://github.com/achang0611/moneycardkotlinreloaded/blob/master/settings.gradle.kts"
    click B3 "https://github.com/achang0611/moneycardkotlinreloaded/tree/master/gradle/wrapper/"
```
