# cadox8/pa architecture

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

- Interactive diagram: https://gitdiagram.com/cadox8/pa
- Repository: https://github.com/cadox8/pa

## Overview

##### Main Components
- PA-Core: This is the central module that contains shared functionality and APIs. It handles core commands, user management, and communication with the MySQL database.
- PA-Bungee: Acts as the network layer using BungeeCord to coordinate server transitions between different game modes.
- Game Mode Plugins: Several Maven modules represent individual game modes (e.g., PA-Antium, PA-Creativo, PA-Lobby, PA-NexusSiege, PA-Rage, PA-SafariNet, PA-Survival, PA-TOA). Each contains its own plugin.yml (registering as a Spigot plugin) along with commands, events, tasks, managers, and specific business logic.
- External Dependencies & Third-Party Libraries: These include APIs and utilities like Inventivetalent’s BossBar and ParticleAPI, Reflection utilities, and other libraries (e.g., ViaVersion) as noted in the README.
- Database: A MySQL database is used for storing user data (passwords, game stats, etc.), with a provided schema (mysql.sql).

##### Relationships and Interactions
- The PA-Core module acts as an API provider that is deployed on every server, enabling consistent user management and data handling.
- PA-Bungee connects to and routes players between the various game mode servers. It must interact with external services (BungeeCord proxy) and provide communication channels.
- Each game mode plugin (for example, PA-Lobby, PA-Survival, etc.) interfaces with PA-Core for shared functionality while implementing its own commands, events, and game-specific logic.
- All modules interact with the MySQL database via PA-Core’s MySQL utility class to read/write user and game data.
- External libraries provide extended functionality (e.g., in-game visual effects, reflection-based dynamic operations).

##### Architectural Patterns and Design Principles
- Plugin Architecture: Each game mode module is self-contained with its own event listeners, commands, and managers—illustrate these as distinct blocks while noting they share common infrastructure provided by PA-Core.
- Layered Interaction: Separate the network (PA-Bungee) from the application logic (game mode modules and PA-Core) and the data layer (MySQL).
- Reuse and Extension Points: Clearly mark the shared APIs in PA-Core and any “extension” hooks where game modes build upon core functionality.
- Use of External APIs: Emphasize integration points with third-party libraries such as Inventivetalent tools and ViaVersion, which may be shown as external components that plug into PA-Core and individual game mode modules.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Network Layer"
        PA_Bungee["PA-Bungee (Network Proxy)"]:::network
    end

    subgraph "Game Server Instances"
        direction TB
        PA_Antium["PA-Antium (Antium Plugin)"]:::plugin
        PA_Creativo["PA-Creativo (Creativo Plugin)"]:::plugin
        PA_Lobby["PA-Lobby (Lobby Plugin)"]:::plugin
        PA_NexusSiege["PA-NexusSiege (NexusSiege Plugin)"]:::plugin
        PA_Rage["PA-Rage (Rage Games Plugin)"]:::plugin
        PA_SafariNet["PA-SafariNet (SafariNet Plugin)"]:::plugin
        PA_Survival["PA-Survival (Survival Plugin)"]:::plugin
        PA_TOA["PA-TOA (TOA Plugin)"]:::plugin
    end

    subgraph "Core Services"
        PA_Core["PA-Core (Core API & Database Interface)"]:::core
    end

    subgraph "Data Layer"
        Database["MySQL Database"]:::database
    end

    External["External Libraries (BossBar,Particle,Reflection)"]:::external

    %% Arrows for network routing from PA-Bungee to game plugins
    PA_Bungee -->|"routes"| PA_Antium
    PA_Bungee -->|"routes"| PA_Creativo
    PA_Bungee -->|"routes"| PA_Lobby
    PA_Bungee -->|"routes"| PA_NexusSiege
    PA_Bungee -->|"routes"| PA_Rage
    PA_Bungee -->|"routes"| PA_SafariNet
    PA_Bungee -->|"routes"| PA_Survival
    PA_Bungee -->|"routes"| PA_TOA

    %% Arrows for game plugins calling core API
    PA_Antium -->|"callsAPI"| PA_Core
    PA_Creativo -->|"callsAPI"| PA_Core
    PA_Lobby -->|"callsAPI"| PA_Core
    PA_NexusSiege -->|"callsAPI"| PA_Core
    PA_Rage -->|"callsAPI"| PA_Core
    PA_SafariNet -->|"callsAPI"| PA_Core
    PA_Survival -->|"callsAPI"| PA_Core
    PA_TOA -->|"callsAPI"| PA_Core

    %% Arrow from core to database
    PA_Core -->|"writesTo"| Database

    %% Integration with External Dependencies
    PA_Core ---|"integrates"| External
    PA_Antium ---|"integrates"| External
    PA_Creativo ---|"integrates"| External
    PA_Lobby ---|"integrates"| External
    PA_NexusSiege ---|"integrates"| External
    PA_Rage ---|"integrates"| External
    PA_SafariNet ---|"integrates"| External
    PA_Survival ---|"integrates"| External
    PA_TOA ---|"integrates"| External

    %% Click Events
    click PA_Core "https://github.com/cadox8/pa/tree/master/PA-Core/src/es/projectalpha/pa/core/"
    click PA_Bungee "https://github.com/cadox8/pa/tree/master/PA-Bungee/src/es/projectalpha/pa/bungee/"
    click PA_Antium "https://github.com/cadox8/pa/tree/master/PA-Antium/src/es/projectalpha/pa/antium/"
    click PA_Creativo "https://github.com/cadox8/pa/tree/master/PA-Creativo/src/es/projectalpha/pa/cr/"
    click PA_Lobby "https://github.com/cadox8/pa/tree/master/PA-Lobby/src/es/projectalpha/pa/lobby/"
    click PA_NexusSiege "https://github.com/cadox8/pa/tree/master/PA-NexusSiege/src/es/projectalpha/pa/nexus/"
    click PA_Rage "https://github.com/cadox8/pa/tree/master/PA-Rage/src/es/projectalpha/pa/rage/"
    click PA_SafariNet "https://github.com/cadox8/pa/tree/master/PA-SafariNet/src/es/projectalpha/pa/sn/"
    click PA_Survival "https://github.com/cadox8/pa/tree/master/PA-Survival/src/es/projectalpha/pa/sur/"
    click PA_TOA "https://github.com/cadox8/pa/tree/master/PA-TOA/src/es/projectalpha/pa/toa/"
    click External "https://github.com/cadox8/pa/tree/master/PA-Core/src/org/inventivetalent/"
    click Database "https://github.com/cadox8/pa/blob/master/mysql.sql"

    %% Styles
    classDef network fill:#e0f7fa,stroke:#006064,stroke-width:2px;
    classDef core fill:#ffccbc,stroke:#bf360c,stroke-width:2px;
    classDef plugin fill:#c8e6c9,stroke:#2e7d32,stroke-width:2px;
    classDef external fill:#fff9c4,stroke:#f57f17,stroke-width:2px;
    classDef database fill:#d1c4e9,stroke:#512da8,stroke-width:2px;
```
