# minevn/minevn-library architecture

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

- Interactive diagram: https://gitdiagram.com/minevn/minevn-library
- Repository: https://github.com/minevn/minevn-library

## Overview

##### Main Components
- Core Library Modules: This includes the centralized utility code (found under minevnlib-master) responsible for database access, connection pooling (supporting H2, MySQL, MariaDB via HikariCP), scheduling (CronTimer), and other common utilities.
- Bukkit Module (minevnlib-bukkit): Contains classes for plugin initialization on Bukkit-based servers, the GUI API (for menu handling, inventory GUIs), command DSL, event listeners, and configuration helpers.
- Bungee Module (minevnlib-bungee): Responsible for providing similar library functionality within the BungeeCord environment.
- Plugin Tests (minevnlib-plugin): Includes unit tests that validate core functionalities.
- Build & CI/CD Tools: The Gradle build files, GitHub workflows, and configuration files indicate a continuous integration pipeline and build process used to compile and package the project.

##### Component Relationships and Interactions
- The Core Library (minevnlib-master) provides common functions and database operations; both the Bukkit and Bungee modules depend on these common utilities.
- The minevnlib-bukkit module implements the GUI API, command handling, and event listening functionality by extending from a custom superclass (MineVNPlugin) that itself is part of the broader library architecture.
- How the migration component (BukkitDBMigrator) interacts with the database connection pool (from the core library). Also, include the file system structure illustration for migrations (e.g., resource/db/migrations and the SQL files named by version).

##### Architectural Patterns and Design Principles
- MVC Orientation: Clearly denote separation between controllers (command/event handling in the Bukkit module), views (GUI API elements), and model (DAO and database schema management).
- Dependency Inversion: Indicate that the higher-level modules (Bukkit/Bungee) depend on abstractions provided by the core library, easing integration and maintenance.
- Build/Deployment Pipeline: Optionally note the CI configuration (.github/workflows) for build automation.

##### Relevant Technologies and Frameworks
- Programming Language: Kotlin (with interoperability to Java)
- Database Connections: HikariCP for connection pooling and support for H2, MySQL, MariaDB.
- External Libraries: Gson for JSON operations and any other libraries referenced in the README.
- Minecraft Server Versions: A note indicating that the library has been tested on Minecraft 1.12.2, 1.20.4, etc.
- Build Tools: Gradle (with both Kotlin script files and wrapper scripts).

##### Specific Elements
- Detail on Interaction Points: Where the system supports transactions and migrations, include annotations or callouts illustrating these design elements.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer"
        UI["User_Commands/Interaction"]:::presentation
        GUI["GUI_API (Bukkit)"]:::presentation
        CMD["Command/Event_Handler (Bukkit)"]:::presentation
    end

    %% Business Logic Layer
    subgraph "Business Logic Layer"
        BukkitCore["MineVNPlugin (Bukkit Core)"]:::business
        Bungee["Bungee Module"]:::business
    end

    %% Data Access Layer
    subgraph "Data Access Layer"
        CoreLib["Core Library Modules"]:::data
        DAO["DAO Layer"]:::data
        Pool["Connection Pool (HikariCP)"]:::data
        Migrator["Database Migration (BukkitDBMigrator)"]:::data
        Cron["CronTimer"]:::data
    end

    %% Integration & Testing
    subgraph "Integration & Testing"
        Tests["Plugin Tests"]:::integration
        CI["Build & CI/CD Tools"]:::integration
    end

    %% Relationships between layers
    UI -->|"triggers"| GUI
    UI -->|"triggers"| CMD

    GUI -->|"sends_event"| BukkitCore
    CMD -->|"sends_command"| BukkitCore

    BukkitCore -->|"initDatabase"| CoreLib
    BukkitCore -->|"use_DAO"| DAO

    CoreLib -->|"manages_pool"| Pool
    CoreLib -->|"schedules"| Cron

    Migrator -->|"migrates_with"| Pool

    Bungee -->|"uses"| CoreLib

    CI -->|"builds"| CoreLib
    CI -->|"builds"| BukkitCore
    CI -->|"builds"| Bungee
    CI -->|"builds"| DAO
    CI -->|"runs_tests"| Tests

    Tests -->|"validates"| CoreLib
    Tests -->|"validates"| BukkitCore
    Tests -->|"validates"| Bungee

    %% Click Events
    click CoreLib "https://github.com/minevn/minevn-library/tree/master/minevnlib-master/src/main/java/net/minevn/libs"
    click BukkitCore "https://github.com/minevn/minevn-library/blob/master/minevnlib-bukkit/src/main/java/net/minevn/libs/bukkit/MineVNPlugin.kt"
    click GUI "https://github.com/minevn/minevn-library/tree/master/minevnlib-bukkit/src/main/java/net/minevn/guiapi"
    click Bungee "https://github.com/minevn/minevn-library/tree/master/minevnlib-bungee/src/main/java/net/minevn/libs/bungee"
    click Tests "https://github.com/minevn/minevn-library/tree/master/minevnlib-plugin/src/test/java/net/minevn"
    click CI "https://github.com/minevn/minevn-library/blob/master/build.gradle.kts"

    %% Styles
    classDef presentation fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef business fill:#90EE90,stroke:#000,stroke-width:2px;
    classDef data fill:#FFFF99,stroke:#000,stroke-width:2px;
    classDef integration fill:#D3D3D3,stroke:#000,stroke-width:2px;
```
