# leo0416/ultimatexnova architecture

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

- Interactive diagram: https://gitdiagram.com/leo0416/ultimatexnova
- Repository: https://github.com/leo0416/ultimatexnova

## Overview

1. **What this repo is**
   - ultimateXnova is a PHP/MySQL browser game server for a space strategy game.
   - The application is split into a web-facing game/admin/install surface, a background cron layer, and a set of bundled client-side assets and third-party libraries.

2. **Main runtime entry points**
   - `index.php` is the public landing/login entry.
   - `game.php` is the main authenticated game shell.
   - `admin.php` is the administration console.
   - `install/index.php` drives installation and upgrades.
   - `cronjob.php` is the scheduled background entry point for game simulation, updates, and maintenance.

3. **Server-side application structure**
   - `includes/` contains the core PHP application logic.
   - `includes/pages/` is the page/controller layer, separated by area: login, game, and admin.
   - `includes/classes/` holds domain services and handlers for fleets, missions, stats, support tickets, templates, themes, and cron tasks.
   - `includes/common.php`, `constants.php`, `dbtables.php`, and `vars.php` look like bootstrap/configuration and shared definitions.

4. **Primary data model and persistence**
   - The backend persists state in MySQL: players, planets, fleets, messages, alliances, tickets, logs, etc.
   - `includes/dbtables.php` centralizes table names/structure references.
   - `cache/` stores rendered template cache and PHP session data, showing the app relies on file-backed caching alongside the database.

5. **Core game loop and background processing**
   - The game is not purely request/response; a significant amount of state changes happen asynchronously through `cronjob.php`.
   - Background tasks likely update resources, fleets, combat resolution, statistics, and timed events.
   - `includes/classes/cronjob/` defines task interfaces, indicating modular scheduled jobs.

6. **Combat and fleet simulation subsystem**
   - Battle resolution is a major subsystem.
   - `includes/libs/opbe/` provides the combat engine and report rendering.
   - Mission and fleet helpers in `includes/classes/missions/` and `includes/classes/class.FlyingFleetHandler.php` orchestrate travel, attacks, recycling, espionage, and report generation.
   - `CombatReport.php` is a top-level report-oriented entry point, likely for viewing or exporting battle results.

7. **Templating and UI rendering**
   - The UI is rendered primarily with Smarty templates under `styles/templates/`.
   - Theme variants such as `gow`, `nova`, `nextgen`, `office`, and `EpicBlueXIII` provide alternate skins and layouts.
   - `includes/classes/class.template.php` and `class.theme.php` connect game data to the selected theme.
   - This means presentation is strongly separated from game logic, but still server-rendered.

8. **Client-side behavior**
   - `scripts/` contains JavaScript for gameplay interactions, forms, validation, tables, fleet actions, galaxy views, messaging, and login/register flows.
   - `styles/resource/css/` and theme assets contain the visual layer, while `scripts/base/` bundles shared libraries like jQuery, validation, TinyMCE, and tooltip helpers.
   - The frontend is mostly enhancement code over server-rendered pages rather than a standalone SPA.

9. **Internationalization and content**
   - The app is heavily localized.
   - `language/` contains server-side language packs and email/template text for multiple languages.
   - `chat/js/lang/` and `chat/lib/lang/` provide chat localization.
   - This localization layer feeds both gameplay UI and system-generated messages.

10. **Chat subsystem**
   - `chat/` is a self-contained AJAX chat/shoutbox integration with its own PHP library, templates, assets, and optional socket server.
   - `chat/socket/server.rb` and `server.conf` indicate a separate real-time component used for chat transport.
   - The game embeds chat as an adjunct service rather than folding it into the core gameplay runtime.

11. **External integrations**
   - The repo bundles libraries for SMTP mail delivery, reCAPTCHA, OpenID, Facebook auth, and TeamSpeak integration.
   - These are used where the game needs account verification, anti-bot protection, email workflows, or community integration.
   - `includes/libs/phpmailer`, `reCAPTCHA`, `OpenID`, `facebook`, and `teamspeak` are the main integration boundaries.

12. **Automation and server ops tooling**
   - `external/autobot/` contains scripts for automated bot/server behavior such as attacks, building, colonization, and message cleanup.
   - `external/forcekill-session-patch/` and `external/events.php` suggest administrative or maintenance utilities.
   - `scripts/backend/` includes Python tooling, which appears to support backend/server-side automation rather than gameplay.

13. **Deployment shape**
   - The repo is designed to run either on a traditional PHP web server or in Docker.
   - `Dockerfile` and `docker-compose.yml` package the web app plus its MySQL dependency.
   - `nginx.md` suggests there is deployment guidance for reverse proxy/web server setup.

14. **How the pieces interact**
   - Browser requests hit one of the PHP entry points, which route into `includes/pages/*`.
   - Those pages call into `includes/classes/*` for game rules and persistence, query MySQL, and render via Smarty templates/theme assets.
   - Time-based state changes are applied by `cronjob.php`.
   - Chat, email, and other integrations operate as adjacent subsystems, not as part of the core game engine.

Main entry points: [`includes/pages`](https://github.com/leo0416/ultimatexnova/tree/master/includes/pages) (Page controllers), [`includes/classes`](https://github.com/leo0416/ultimatexnova/tree/master/includes/classes) (Game services), [`includes/common.php`](https://github.com/leo0416/ultimatexnova/blob/master/includes/common.php) (Bootstrap), [`includes/classes/class.template.php`](https://github.com/leo0416/ultimatexnova/blob/master/includes/classes/class.template.php) (Smarty layer)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtimes"]
  node_index_php["Landing<br/>php entry<br/>[index.php]"]
  node_game_php["Game shell<br/>php entry<br/>[game.php]"]
  node_admin_php["Admin console<br/>php entry<br/>[admin.php]"]
  node_install_php["Installer<br/>php entry<br/>[index.php]"]
  node_cronjob_php["Cron runner<br/>php entry<br/>[cronjob.php]"]
end

subgraph group_core["Core app"]
  node_bootstrap["Bootstrap<br/>shared php<br/>[common.php]"]
  node_dbtables["DB schema map<br/>persistence map<br/>[dbtables.php]"]
  node_pages["Page controllers<br/>controller layer"]
  node_services["Game services<br/>domain services"]
  node_fleet["Fleet handler<br/>simulation service"]
  node_missions["Missions<br/>mission logic"]
  node_cron_tasks["Cron tasks<br/>job interface"]
  node_opbe["Combat engine<br/>battle engine"]
  node_cache[("Cache & sessions<br/>runtime storage")]
end

subgraph group_ui["Presentation"]
  node_templating["Smarty layer<br/>view engine<br/>[class.template.php]"]
  node_themes["Themes"]
  node_scripts["Client scripts<br/>frontend scripts"]
  node_language["Language packs<br/>localization"]
end

subgraph group_integrations["Integrations"]
  node_chat["Chat subsystem<br/>adjacent service"]
  node_libs["Third-party libs<br/>vendor bundles"]
end

subgraph group_ops["Ops"]
  node_external_tools["Automation tools<br/>ops scripts"]
  node_docker["Deployment<br/>infra"]
end

node_index_php -->|"bootstraps"| node_bootstrap
node_game_php -->|"bootstraps"| node_bootstrap
node_admin_php -->|"bootstraps"| node_bootstrap
node_install_php -->|"bootstraps"| node_bootstrap
node_cronjob_php -->|"boots"| node_bootstrap
node_index_php -->|"routes to"| node_pages
node_game_php -->|"routes to"| node_pages
node_admin_php -->|"routes to"| node_pages
node_install_php -->|"routes to"| node_pages
node_pages -->|"uses"| node_services
node_services -->|"includes"| node_fleet
node_services -->|"includes"| node_missions
node_services -->|"includes"| node_cron_tasks
node_cronjob_php -->|"executes"| node_cron_tasks
node_missions -->|"simulates"| node_opbe
node_services -->|"queries"| node_dbtables
node_bootstrap -->|"defines"| node_dbtables
node_pages -->|"renders"| node_templating
node_templating -->|"selects"| node_themes
node_templating -->|"reads/writes"| node_cache
node_pages -->|"localizes"| node_language
node_pages -->|"serves"| node_scripts
node_pages -->|"embeds"| node_chat
node_pages -->|"integrates"| node_libs
node_external_tools -->|"automates"| node_services
node_docker -->|"deploys"| node_game_php
node_docker -.->|"deploys"| node_chat

click node_index_php "https://github.com/leo0416/ultimatexnova/blob/master/index.php"
click node_game_php "https://github.com/leo0416/ultimatexnova/blob/master/game.php"
click node_admin_php "https://github.com/leo0416/ultimatexnova/blob/master/admin.php"
click node_install_php "https://github.com/leo0416/ultimatexnova/blob/master/install/index.php"
click node_cronjob_php "https://github.com/leo0416/ultimatexnova/blob/master/cronjob.php"
click node_bootstrap "https://github.com/leo0416/ultimatexnova/blob/master/includes/common.php"
click node_dbtables "https://github.com/leo0416/ultimatexnova/blob/master/includes/dbtables.php"
click node_pages "https://github.com/leo0416/ultimatexnova/tree/master/includes/pages"
click node_services "https://github.com/leo0416/ultimatexnova/tree/master/includes/classes"
click node_fleet "https://github.com/leo0416/ultimatexnova/blob/master/includes/classes/class.FlyingFleetHandler.php"
click node_missions "https://github.com/leo0416/ultimatexnova/tree/master/includes/classes/missions"
click node_cron_tasks "https://github.com/leo0416/ultimatexnova/tree/master/includes/classes/cronjob"
click node_opbe "https://github.com/leo0416/ultimatexnova/tree/master/includes/libs/opbe"
click node_templating "https://github.com/leo0416/ultimatexnova/blob/master/includes/classes/class.template.php"
click node_themes "https://github.com/leo0416/ultimatexnova/tree/master/styles/templates/theme"
click node_scripts "https://github.com/leo0416/ultimatexnova/tree/master/scripts"
click node_language "https://github.com/leo0416/ultimatexnova/tree/master/language"
click node_chat "https://github.com/leo0416/ultimatexnova/tree/master/chat"
click node_libs "https://github.com/leo0416/ultimatexnova/tree/master/includes/libs"
click node_external_tools "https://github.com/leo0416/ultimatexnova/tree/master/external"
click node_docker "https://github.com/leo0416/ultimatexnova/tree/master/Dockerfile"
click node_cache "https://github.com/leo0416/ultimatexnova/tree/master/cache"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_index_php,node_game_php,node_admin_php,node_install_php,node_cronjob_php toneBlue
class node_bootstrap,node_dbtables,node_pages,node_services,node_fleet,node_missions,node_cron_tasks,node_opbe,node_cache toneAmber
class node_templating,node_themes,node_scripts,node_language toneMint
class node_chat,node_libs toneRose
class node_external_tools,node_docker toneIndigo
```

## Components

### Runtimes

Main PHP entry points and background execution paths

- [Landing](https://github.com/leo0416/ultimatexnova/blob/master/index.php): php entry · Public login and landing entry point · `index.php`
- [Game shell](https://github.com/leo0416/ultimatexnova/blob/master/game.php): php entry · Authenticated in-game entry point · `game.php`
- [Admin console](https://github.com/leo0416/ultimatexnova/blob/master/admin.php): php entry · Administration entry point · `admin.php`
- [Installer](https://github.com/leo0416/ultimatexnova/blob/master/install/index.php): php entry · Install and upgrade entry point · `install/index.php`
- [Cron runner](https://github.com/leo0416/ultimatexnova/blob/master/cronjob.php): php entry · Scheduled background simulation and maintenance · `cronjob.php`

### Core app

Shared server-side game logic and persistence

- [Bootstrap](https://github.com/leo0416/ultimatexnova/blob/master/includes/common.php): shared php · Common setup, constants, variables, and table map · `includes/common.php`
- [DB schema map](https://github.com/leo0416/ultimatexnova/blob/master/includes/dbtables.php): persistence map · Centralized MySQL table references and structure names · `includes/dbtables.php`
- [Page controllers](https://github.com/leo0416/ultimatexnova/tree/master/includes/pages): controller layer · Login, game, and admin page dispatchers · `includes/pages`
- [Game services](https://github.com/leo0416/ultimatexnova/tree/master/includes/classes): domain services · Fleet, missions, builds, stats, support, themes, and templates · `includes/classes`
- [Fleet handler](https://github.com/leo0416/ultimatexnova/blob/master/includes/classes/class.FlyingFleetHandler.php): simulation service · Coordinates fleet movement and active fleet state · `includes/classes/class.FlyingFleetHandler.php`
- [Missions](https://github.com/leo0416/ultimatexnova/tree/master/includes/classes/missions): mission logic · Attack, steal, espionage, and report generation helpers · `includes/classes/missions`
- [Cron tasks](https://github.com/leo0416/ultimatexnova/tree/master/includes/classes/cronjob): job interface · Modular scheduled job contract and task implementations · `includes/classes/cronjob`
- [Combat engine](https://github.com/leo0416/ultimatexnova/tree/master/includes/libs/opbe): battle engine · Battle simulation and combat report rendering · `includes/libs/opbe`
- [Cache & sessions](https://github.com/leo0416/ultimatexnova/tree/master/cache): runtime storage · File-backed template cache and session storage · `cache`

### Presentation

Templates, themes, and client-side assets

- [Smarty layer](https://github.com/leo0416/ultimatexnova/blob/master/includes/classes/class.template.php): view engine · Template rendering and theme binding · `includes/classes/class.template.php`
- [Themes](https://github.com/leo0416/ultimatexnova/tree/master/styles/templates/theme): ui themes · Server-rendered theme templates and assets · `styles/templates/theme`
- [Client scripts](https://github.com/leo0416/ultimatexnova/tree/master/scripts): frontend scripts · Gameplay, login, admin, and shared JavaScript · `scripts`
- [Language packs](https://github.com/leo0416/ultimatexnova/tree/master/language): localization · Server-side text, email templates, and UI strings · `language`

### Integrations

Third-party services and adjacent subsystems

- [Chat subsystem](https://github.com/leo0416/ultimatexnova/tree/master/chat): adjacent service · Bundled AJAX chat with optional socket transport · `chat`
- [Third-party libs](https://github.com/leo0416/ultimatexnova/tree/master/includes/libs): vendor bundles · SMTP, OpenID, Facebook, reCAPTCHA, BBCode, Parsedown, TeamSpeak, ZIP, PHP cron helpers · `includes/libs`

### Ops

Deployment, automation, and maintenance tooling

- [Automation tools](https://github.com/leo0416/ultimatexnova/tree/master/external): ops scripts · Bot, maintenance, and backend automation utilities · `external`
- [Deployment](https://github.com/leo0416/ultimatexnova/tree/master/Dockerfile): infra · Container and web server deployment definitions · `Dockerfile`

## Connections

- Landing → Bootstrap: bootstraps · Loads shared app setup
- Game shell → Bootstrap: bootstraps · Loads shared app setup
- Admin console → Bootstrap: bootstraps · Loads shared app setup
- Installer → Bootstrap: bootstraps · Loads install-time shared setup
- Cron runner → Bootstrap: boots · Initializes background runtime
- Landing → Page controllers: routes to · Dispatches login and public pages
- Game shell → Page controllers: routes to · Dispatches in-game pages
- Admin console → Page controllers: routes to · Dispatches admin pages
- Installer → Page controllers: routes to · Dispatches installer pages
- Page controllers → Game services: uses · Page controllers call into game services
- Game services → Fleet handler: includes · Fleet execution is a central service
- Game services → Missions: includes · Mission orchestration and outcomes
- Game services → Cron tasks: includes · Scheduled jobs extend the cron interface
- Cron runner → Cron tasks: executes · Runs modular background jobs
- Missions → Combat engine: simulates · Combat and report generation depend on battle engine
- Game services → DB schema map: queries · Persists game state through shared table map
- Bootstrap → DB schema map: defines · Shared bootstrap includes table definitions
- Page controllers → Smarty layer: renders · Controllers render via the template layer
- Smarty layer → Themes: selects · Theme-aware server rendering
- Smarty layer → Cache & sessions: reads/writes · Compiled template and session cache
- Page controllers → Language packs: localizes · Page text and emails use language packs
- Page controllers → Client scripts: serves · Pages are enhanced by client-side behavior
- Page controllers → Chat subsystem: embeds · Chat is an adjacent subsystem in the UI
- Page controllers → Third-party libs: integrates · Uses bundled third-party libraries
- Automation tools → Game services: automates · Automation scripts interact with game systems
- Deployment → Game shell: deploys · Container setup serves the PHP app
- Deployment → Chat subsystem: deploys · Deployment may include chat service pieces
