# easy-wi/developer architecture

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

- Interactive diagram: https://gitdiagram.com/easy-wi/developer
- Repository: https://github.com/easy-wi/developer

## Overview

##### Project Overview and Purpose
- Easy-WI is a web-based control panel designed to manage server daemons such as gameservers and TS3 voice servers. It also embeds a CMS which automates game and voice server lending services.
- It is aimed at a diverse user base (commercial hosting providers, LAN party organizers, private individuals, etc.) and emphasizes automation and minimal manual administration.
- The system is built in PHP (7.4+) and leverages many third-party libraries (e.g., Decoda for markup parsing, Symfony Yaml, GameQ for game server query protocols, hybridauth for social logins, phpmailer, phpseclib, etc.)

##### Key Components in the File Structure and their Architectural Roles
A. Presentation/Frontend Layer
– Templates: The “template”, “template/New”, “template/default” folders contain HTML views for both administrative and user interfaces.
– AJAX Endpoints: Various AJAX calls (e.g., in js/default/ajax and stuff/ajax) support dynamic operations and partial page updates.

B. Business Logic / Application Layer
– PHP Entry Points: Files such as index.php, admin.php, login.php, api.php, and others serve as primary controllers.
– Modular “Stuff” Directory: The “stuff” folder is subdivided into subdirectories (admin, ajax, api, cms, custom_modules, data, jobs, methods, user) that encapsulate business logic for different modules:
- “stuff/admin”: Contains administrative modules (user management, game server settings, feeds, etc.).
- “stuff/api”: Provides REST API endpoints.
- “stuff/cms”: Houses CMS logic and view initializers.
- “stuff/ajax”: Contains handlers for AJAX-driven interactions.
- “stuff/methods”: Contains core classes and functions (e.g., for FTP, database operations, and validation).
- “stuff/user”: Contains user panel modules including lending functions and customization.

C. Infrastructure / Integration Layer
– Installer & Configuration: The “install” folder manages the database & system configuration. The “config.php” file and various language XML files support configuration and multilanguage support.
– Third-Party Libraries: The “third_party” folder holds external libraries which integrate:
- Decoda for markup/BBCode parsing.
- Symfony’s YAML component for configuration.
- GameQ for game server querying.
- Hybridauth for social authentication.
- MonstaFTP, PHPMailer, phpseclib, etc.
– Scripts for server integrations: PHP files such as cloud.php, lend.php, serverallocation.php and various “jobs” scripts automate interactions with external daemons (gameservers, TS3 voice servers).

##### Relationships and Data Flow
- Clients (users and administrators) interact via browsers with the presentation layer. They receive HTML/CSS/JS pages that dynamically call backend endpoints via AJAX as needed.
- The PHP entry scripts (admin.php, login.php, etc.) invoke the appropriate modules in the “stuff” directory. These modules encapsulate business logic for server management, user management, and content management.
- The system interacts with external services (e.g., game servers, TS3 voice servers) and libraries. These external integrations are managed by dedicated methods (in “stuff/methods”) and jobs (“stuff/jobs”) that periodically monitor and control daemons.
- Although not explicitly shown in the file tree, the use of PDO, PHP configuration files, and related scripts indicate database interactions (most likely MySQL) that support persistent storage of user data, server settings, and configuration.
- The REST API endpoints (via api.php and under stuff/api) not only serve internal modules but are also designed to integrate with third-party systems, such as WHMCS or Magento.

##### Architectural Patterns and Design Principles
- Separation of Concerns: Clear distinction between the presentation (templates and static assets) and business logic (PHP modules in “stuff”), with fallback to default templates.
- Modular Design: Business logic is broken down into distinct modules (admin, API, AJAX, CMS, user panels) for maintainability and scalability.
- Reusability and Integration: Extensive use of third-party libraries and shared utilities (e.g., for social authentication, mail, FTP, and game server queries).
- Use of REST API: Many modules are exposed as APIs allowing integration with external platforms.
- Fallback and Theming: Custom templates can override default views, indicating a template override mechanism.

##### Final Steps
- Every major directory, service, or external integration is represented.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Top Level: Client
    Client["Client/Browser"]:::frontend

    %% Presentation Layer Subgraph
    subgraph "Presentation Layer"
        direction TB
        subgraph "Templates"
            T1["Template (template/)"]:::frontend
            T2["Template New (template/New/)"]:::frontend
            T3["Template Default (template/default/)"]:::frontend
        end
        CSS["CSS (css/)"]:::frontend
        JS["JS (js/)"]:::frontend
        Images["Images (images/)"]:::frontend
        Webfonts["Webfonts (webfonts/)"]:::frontend
        AJAX_Client["AJAX Client (js/default)"]:::frontend
        AJAX_Backend["AJAX Handlers (stuff/ajax/)"]:::frontend
    end

    %% PHP Entry Points Subgraph
    subgraph "PHP Entry Points"
        direction TB
        indexPHP["index.php"]:::business
        adminPHP["admin.php"]:::business
        loginPHP["login.php"]:::business
        apiPHP["api.php"]:::business
        ajaxPHP["ajax.php"]:::business
        cloudPHP["cloud.php"]:::business
        lendPHP["lend.php"]:::business
        serverallocationPHP["serverallocation.php"]:::business
        rebootPHP["reboot.php"]:::business
        statuscheckPHP["statuscheck.php"]:::business
        jobsPHP["jobs.php"]:::business
        switchPHP["switch.php"]:::business
    end

    %% Business Logic Modules Subgraph
    subgraph "Business Logic Modules"
        direction TB
        adminModule["Admin Module (stuff/admin/)"]:::business
        apiModule["API Module (stuff/api/)"]:::business
        cmsModule["CMS Module (stuff/cms/)"]:::business
        customModules["Custom Modules (stuff/custom_modules/)"]:::business
        dataModule["Data Module (stuff/data/)"]:::business
        jobsModule["Jobs Module (stuff/jobs/)"]:::business
        methodsModule["Core Methods (stuff/methods/)"]:::business
        userModule["User Module (stuff/user/)"]:::business
    end

    %% Infrastructure / Integration Subgraph
    subgraph "Infrastructure / Integration"
        direction TB
        installer["Installer & Configuration (install/)"]:::infra
        thirdParty["Third-Party Libraries (third_party/)"]:::infra
    end

    %% Data Store and External Services
    Database["Database (MySQL via PDO)"]:::db
    External["External Services (Game Servers, TS3, FTP, etc.)"]:::external

    %% Relationships
    Client -->|"HTTP_Request"| T1
    Client -->|"HTTP_Request"| CSS
    Client -->|"HTTP_Request"| JS
    Client -->|"HTTP_Request"| Images
    Client -->|"HTTP_Request"| Webfonts
    Client -->|"AJAX_Request"| AJAX_Client

    AJAX_Client -->|"AJAX Call"| AJAX_Backend

    %% PHP Entry Points receive client requests (rendering views, processing forms, etc.)
    T1 -->|"Render"| indexPHP
    T2 -->|"Render"| indexPHP
    T3 -->|"Render"| indexPHP

    %% PHP Entry Points invoke Business Logic Modules
    indexPHP -->|"RouteRequest"| adminModule
    adminPHP -->|"RouteRequest"| adminModule
    loginPHP -->|"RouteRequest"| userModule
    apiPHP -->|"RouteRequest"| apiModule
    ajaxPHP -->|"RouteRequest"| AJAX_Backend
    cloudPHP -->|"RouteRequest"| jobsModule
    lendPHP -->|"RouteRequest"| userModule
    serverallocationPHP -->|"RouteRequest"| adminModule
    rebootPHP -->|"RouteRequest"| adminModule
    statuscheckPHP -->|"RouteRequest"| jobsModule
    jobsPHP -->|"RouteRequest"| jobsModule
    switchPHP -->|"RouteRequest"| adminModule

    %% Business Logic Modules interactions
    adminModule -->|"DB_Query"| Database
    apiModule -->|"DB_Query"| Database
    cmsModule -->|"DB_Query"| Database
    userModule -->|"DB_Query"| Database

    adminModule -->|"ServerCommand"| External
    apiModule -->|"ServerCommand"| External
    cmsModule -->|"ServerCommand"| External
    userModule -->|"ServerCommand"| External

    %% Business Logic Modules integration with Third-Party Libraries and Configurations
    adminModule ---|"LibraryCalls"| thirdParty
    apiModule ---|"LibraryCalls"| thirdParty
    cmsModule ---|"LibraryCalls"| thirdParty
    userModule ---|"LibraryCalls"| thirdParty
    methodsModule ---|"Utility"| installer

    %% PHP Entry Points access configuration as needed
    indexPHP ---|"Config"| installer
    adminPHP ---|"Config"| installer
    loginPHP ---|"Config"| installer
    apiPHP ---|"Config"| installer

    %% Click Events for Presentation Layer
    click T1 "https://github.com/easy-wi/developer/tree/master/template/"
    click T2 "https://github.com/easy-wi/developer/tree/master/template/New/"
    click T3 "https://github.com/easy-wi/developer/tree/master/template/default/"

    click CSS "https://github.com/easy-wi/developer/tree/master/css/"
    click JS "https://github.com/easy-wi/developer/tree/master/js/"
    click Images "https://github.com/easy-wi/developer/tree/master/images/"
    click Webfonts "https://github.com/easy-wi/developer/tree/master/webfonts/"

    click AJAX_Client "https://github.com/easy-wi/developer/tree/master/js/default"
    click AJAX_Backend "https://github.com/easy-wi/developer/tree/master/stuff/ajax/"

    %% Click Events for PHP Entry Points
    click indexPHP "https://github.com/easy-wi/developer/blob/master/index.php"
    click adminPHP "https://github.com/easy-wi/developer/blob/master/admin.php"
    click loginPHP "https://github.com/easy-wi/developer/blob/master/login.php"
    click apiPHP "https://github.com/easy-wi/developer/blob/master/api.php"
    click ajaxPHP "https://github.com/easy-wi/developer/blob/master/ajax.php"
    click cloudPHP "https://github.com/easy-wi/developer/blob/master/cloud.php"
    click lendPHP "https://github.com/easy-wi/developer/blob/master/lend.php"
    click serverallocationPHP "https://github.com/easy-wi/developer/blob/master/serverallocation.php"
    click rebootPHP "https://github.com/easy-wi/developer/blob/master/reboot.php"
    click statuscheckPHP "https://github.com/easy-wi/developer/blob/master/statuscheck.php"
    click jobsPHP "https://github.com/easy-wi/developer/blob/master/jobs.php"
    click switchPHP "https://github.com/easy-wi/developer/blob/master/switch.php"

    %% Click Events for Business Logic Modules
    click adminModule "https://github.com/easy-wi/developer/tree/master/stuff/admin/"
    click apiModule "https://github.com/easy-wi/developer/tree/master/stuff/api/"
    click cmsModule "https://github.com/easy-wi/developer/tree/master/stuff/cms/"
    click customModules "https://github.com/easy-wi/developer/tree/master/stuff/custom_modules/"
    click dataModule "https://github.com/easy-wi/developer/tree/master/stuff/data/"
    click jobsModule "https://github.com/easy-wi/developer/tree/master/stuff/jobs/"
    click methodsModule "https://github.com/easy-wi/developer/tree/master/stuff/methods/"
    click userModule "https://github.com/easy-wi/developer/tree/master/stuff/user/"

    %% Click Events for Infrastructure / Integration
    click installer "https://github.com/easy-wi/developer/tree/master/install/"
    click thirdParty "https://github.com/easy-wi/developer/tree/master/third_party/"

    %% Styles
    classDef frontend fill:#99ccff,stroke:#000,stroke-width:2px;
    classDef business fill:#b3e6b3,stroke:#000,stroke-width:2px;
    classDef infra fill:#cccccc,stroke:#000,stroke-width:2px;
    classDef external fill:#ffcc99,stroke:#000,stroke-width:2px;
    classDef db fill:#e6b3ff,stroke:#000,stroke-width:2px;
```
