# pgmdev/pgm architecture

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

- Interactive diagram: https://gitdiagram.com/pgmdev/pgm
- Repository: https://github.com/pgmdev/pgm

## Overview

##### High-Level Architecture Overview

a. Core System
- PGM Plugin Core (central component)
- Match Management System
- Management System
- Player Management System

b. Module System
- Game Modes (e.g., Blitz, CTF, Control Points)
- Features (e.g., Spawns, Teams, Filters)
- Utilities (e.g., Commands, Events)

c. Platform Layer
- Modern Platform Implementation
- SportPaper Platform Implementation

##### Key Components

a. Core Components:
**[PGMPlugin] --> [MatchManager]**
**[MatchManager] --> [MapLibrary]**
**[MatchManager] --> [PlayerManager]**

b. Match System:
**[Match] <--> [MatchModules]**
**[Match] <--> [Teams/Parties]**
**[Match] <--> [Players]**

c. System:
**[MapLibrary] --> [MapContext]**
**[MapContext] --> [MapModules]**
**[MapContext] --> [Features]**

##### Module Integration
How different modules interact:
**[Core] <--> [Filters]**
**[Core] <--> [Regions]**
**[Core] <--> [Goals]**

##### Platform Abstraction
Demonstrate the platform independence:
**[PGM Core] <--> [Platform API]**
**[Platform API] --> [Modern Platform]**
**[Platform API] --> [SportPaper Platform]**

##### Important Relationships to Highlight

- Match Lifecycle Management:
**[MatchManager] --> [Match States]**
**[Match States]: Loading -> Running -> Finished**

- Player Management:
**[MatchPlayer] --> [Party/Team]**
**[MatchPlayer] --> [Statistics]**
**[MatchPlayer] --> [Settings]**

##### Implementation Details to Note
- Separation between API interfaces and implementations
- Async vs sync operations
- Extension points for custom modules

**[Platform Layer]**
- ↑
**[Core Systems]**
- ↑
**[Game Modules]**
- ↑
**[Utilities/Support]**

## Diagram (Mermaid)

```mermaid
graph TB
    %% Core Components
    PGMPlugin["PGM Plugin Core"]:::core
    MatchManager["Match Manager"]:::core
    MapLibrary["Map Library"]:::core
    PlayerManager["Player Manager"]:::core

    %% Match System
    Match["Match"]:::match
    MatchModules["Match Modules"]:::match
    Teams["Teams/Parties"]:::match
    Players["Players"]:::match

    %% Map System
    MapContext["Map Context"]:::map
    MapModules["Map Modules"]:::map
    Features["Features"]:::map

    %% Module System
    subgraph GameModes
        Blitz["Blitz"]:::gamemode
        CTF["CTF"]:::gamemode
        ControlPoints["Control Points"]:::gamemode
    end

    subgraph CoreFeatures
        Spawns["Spawns"]:::feature
        TeamsFeature["Teams"]:::feature
        Filters["Filters"]:::feature
    end

    %% Platform Layer
    PlatformAPI["Platform API"]:::platform
    ModernPlatform["Modern Platform"]:::platform
    SportPaperPlatform["SportPaper Platform"]:::platform

    %% Utilities
    subgraph Utilities
        Commands["Commands"]:::utility
        Events["Events"]:::utility
        GeneralUtils["General Utilities"]:::utility
    end

    %% Relationships
    PGMPlugin --> MatchManager
    PGMPlugin --> MapLibrary
    PGMPlugin --> PlayerManager
    PGMPlugin --> PlatformAPI

    MatchManager --> Match
    Match <--> MatchModules
    Match <--> Teams
    Match <--> Players

    MapLibrary --> MapContext
    MapContext --> MapModules
    MapContext --> Features

    PlatformAPI --> ModernPlatform
    PlatformAPI --> SportPaperPlatform

    %% Module Connections
    Match --> GameModes
    Match --> CoreFeatures
    Match --> Utilities

    %% Styling
    classDef core fill:#3498db,stroke:#2980b9,color:white
    classDef match fill:#2ecc71,stroke:#27ae60,color:white
    classDef map fill:#e67e22,stroke:#d35400,color:white
    classDef platform fill:#9b59b6,stroke:#8e44ad,color:white
    classDef utility fill:#95a5a6,stroke:#7f8c8d,color:white
    classDef gamemode fill:#f1c40f,stroke:#f39c12,color:black
    classDef feature fill:#e74c3c,stroke:#c0392b,color:white

    %% Click Events
    click PGMPlugin "https://github.com/PGMDev/PGM/blob/dev/core/src/main/java/tc/oc/pgm/PGMPlugin.java"
    click MatchManager "https://github.com/PGMDev/PGM/blob/dev/core/src/main/java/tc/oc/pgm/match/MatchManagerImpl.java"
    click MapLibrary "https://github.com/PGMDev/PGM/blob/dev/core/src/main/java/tc/oc/pgm/map/MapLibraryImpl.java"
    click Players "https://github.com/PGMDev/PGM/blob/dev/core/src/main/java/tc/oc/pgm/api/player/MatchPlayer.java"
    click Blitz "https://github.com/PGMDev/PGM/tree/dev/core/src/main/java/tc/oc/pgm/blitz/"
    click CTF "https://github.com/PGMDev/PGM/tree/dev/core/src/main/java/tc/oc/pgm/flag/"
    click ControlPoints "https://github.com/PGMDev/PGM/tree/dev/core/src/main/java/tc/oc/pgm/controlpoint/"
    click Spawns "https://github.com/PGMDev/PGM/tree/dev/core/src/main/java/tc/oc/pgm/spawns/"
    click TeamsFeature "https://github.com/PGMDev/PGM/tree/dev/core/src/main/java/tc/oc/pgm/teams/"
    click Filters "https://github.com/PGMDev/PGM/tree/dev/core/src/main/java/tc/oc/pgm/filters/"
    click ModernPlatform "https://github.com/PGMDev/PGM/blob/dev/platform/platform-modern/src/main/java/tc/oc/pgm/platform/modern/ModernPlatform.java"
    click SportPaperPlatform "https://github.com/PGMDev/PGM/blob/dev/platform/platform-sportpaper/src/main/java/tc/oc/pgm/platform/sportpaper/SportPaperPlatform.java"
    click Commands "https://github.com/PGMDev/PGM/tree/dev/core/src/main/java/tc/oc/pgm/command/"
    click Events "https://github.com/PGMDev/PGM/tree/dev/core/src/main/java/tc/oc/pgm/events/"
    click GeneralUtils "https://github.com/PGMDev/PGM/tree/dev/util/src/main/java/tc/oc/pgm/util/"
```
