# swiftbytegbr/gmc-daemon architecture

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

- Interactive diagram: https://gitdiagram.com/swiftbytegbr/gmc-daemon
- Repository: https://github.com/swiftbytegbr/gmc-daemon

## Overview

##### Main Components
- • Application Entry Point: Represented by the Application.java class. This will be the starting block for initializing the daemon.
- • Command Processing: The “commands” package (e.g. BackupManagementCommands, DaemonManagementCommand, JoinTeamCommand, ServerManagementCommands) handles various control inputs.
- • Node & Server Management: The Node.java class, along with the “server” package (e.g. AsaServer, GameServer), encapsulates functionality related to managing dedicated nodes and game servers.
- • Caching: The “cache” package (CacheModel and GameServerCacheModel) indicates a layer used for temporarily storing state or configuration information to increase responsiveness.
- • Configuration: The “config” package (with classes like GmcPromptProvider) handles how configuration is provided and managed within the daemon.
- • Service Layer: Services like BackupService and FirewallService implement core business logic required for operations such as auto-backup, firewall management, etc.
- • STOMP Messaging: The “stomp” package and its sub-packages (including StompHandler, StompPacketConsumer, and various consumers for backend, node, and server events) manage inter-component communication using the STOMP protocol. This is key since it facilitates the interaction between the daemon and external systems (e.g., the GMC WebPanel) or other nodes.
- • Utilities: The “utils” package supports common operations (e.g., configuration, connection state, node/server utilities) to ease the operation across components.

##### Relationships and Interactions
- A “Command Dispatcher” component that routes commands from both local input and remote calls (via the WebPanel) to appropriate command handlers.
- How commands interact with the “Service Layer” to perform operations like backups, firewall changes, or server state modifications.
- Caching layer working as a mediator between the commands/services and the server/node state.
- STOMP messaging subsystem:
- External integration points such as the GMC WebPanel (from the README) that communicates with the daemon, likely through the STOMP messaging layer or API endpoints (although the direct web layer is separate, it is integral for management).

##### Architectural Patterns and Principles
- The design leans towards modularization where responsibilities are clearly defined (command handling, service operations, messaging, and caching).
- There’s a separation of concerns: the command layer handles user inputs; the service layer processes business logic; the messaging subsystem handles communication; and the configuration/cache layers manage state and operational parameters.
- The use of STOMP indicates a messaging or event-driven pattern which is essential for asynchronous communication between distributed components (nodes, servers, and the backend).

##### Relevant Technologies, Frameworks, and Tools
- Java with Maven as the build system (indicated by pom.xml, mvnw, mvnw.cmd).
- STOMP protocol as seen in the messaging package.
- Potential integration with external services like the GMC WebPanel. Although the panel is hosted independently, its communication with the daemon is critical.
- Dependency management via GitHub workflows (.github directory) ensures integration and deployment practices are in place.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Initialization Layer
    subgraph "Initialization Layer"
        A["Application (Application.java)"]:::internal
    end

    %% Presentation/Command Layer
    subgraph "Presentation/Command Layer"
        CMD["Command Dispatcher"]:::internal
        Commands["Commands Package"]:::internal
    end

    %% Business Logic Layer
    subgraph "Business Logic Layer"
        Services["Service Layer"]:::internal
        NodeMgmt["Node Management (Node.java)"]:::internal
        ServerMgmt["Server Management"]:::internal
    end

    %% Messaging Layer
    subgraph "Messaging Layer"
        STOMP["STOMP Core"]:::internal
        subgraph "STOMP Consumers"
            Backend["Backend Consumers"]:::internal
            NodeCon["Node Consumers"]:::internal
            ServerCon["Server Consumers"]:::internal
        end
    end

    %% Persistence/Cache & Configuration Layer
    subgraph "Persistence/Cache & Configuration Layer"
        Cache["Caching"]:::internal
        Config["Configuration"]:::internal
    end

    %% External Integration
    External["GMC WebPanel (External)"]:::external

    %% Utilities (Support Layer)
    Utilities["Utilities"]:::internal

    %% Connections
    A -->|"initializes"| CMD
    CMD -->|"routes commands"| Commands
    CMD -->|"sends messages"| STOMP
    Commands -->|"triggers services"| Services
    Services -->|"manages node ops"| NodeMgmt
    Services -->|"manages server ops"| ServerMgmt
    Services -->|"updates cache"| Cache
    Services -->|"reads config"| Config
    Services -->|"utilizes"| Utilities
    CMD -->|"utilizes"| Utilities
    External -->|"sendsRemoteCmds"| STOMP
    STOMP -->|"sendsEvent"| Backend
    STOMP -->|"sendsEvent"| NodeCon
    STOMP -->|"sendsEvent"| ServerCon

    %% Styles
    classDef internal fill:#ADD8E6,stroke:#333,stroke-width:2px;
    classDef external fill:#90EE90,stroke:#333,stroke-width:2px;

    %% Click Events
    click A "https://github.com/swiftbytegbr/gmc-daemon/blob/master/src/main/java/de/swiftbyte/gmc/Application.java"
    click Commands "https://github.com/swiftbytegbr/gmc-daemon/tree/master/src/main/java/de/swiftbyte/gmc/commands"
    click NodeMgmt "https://github.com/swiftbytegbr/gmc-daemon/blob/master/src/main/java/de/swiftbyte/gmc/Node.java"
    click ServerMgmt "https://github.com/swiftbytegbr/gmc-daemon/tree/master/src/main/java/de/swiftbyte/gmc/server"
    click Cache "https://github.com/swiftbytegbr/gmc-daemon/tree/master/src/main/java/de/swiftbyte/gmc/cache"
    click Config "https://github.com/swiftbytegbr/gmc-daemon/tree/master/src/main/java/de/swiftbyte/gmc/config"
    click Services "https://github.com/swiftbytegbr/gmc-daemon/tree/master/src/main/java/de/swiftbyte/gmc/service"
    click STOMP "https://github.com/swiftbytegbr/gmc-daemon/tree/master/src/main/java/de/swiftbyte/gmc/stomp"
    click Backend "https://github.com/swiftbytegbr/gmc-daemon/tree/master/src/main/java/de/swiftbyte/gmc/stomp/consumers/backend"
    click NodeCon "https://github.com/swiftbytegbr/gmc-daemon/tree/master/src/main/java/de/swiftbyte/gmc/stomp/consumers/node"
    click ServerCon "https://github.com/swiftbytegbr/gmc-daemon/tree/master/src/main/java/de/swiftbyte/gmc/stomp/consumers/server"
    click Utilities "https://github.com/swiftbytegbr/gmc-daemon/tree/master/src/main/java/de/swiftbyte/gmc/utils"
```
