# shadowss/travianz architecture

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

- Interactive diagram: https://gitdiagram.com/shadowss/travianz
- Repository: https://github.com/shadowss/travianz

## Overview

TravianZ is a PHP browser strategy game. Players enter through the public/game pages, use authenticated gameplay pages to manage villages and take part in combat and alliances, and see outcomes through game views; scheduled automation advances world state. The repository also documents hero trading/adventures, rankings, maps, statistics, and extensive administration. The graph preserves these product branches, but several are represented at directory level because their implementation was not excerpted. Solid edges cite visible imports or explicit README claims; dashed edges mark undocumented wiring.

Main entry points: [`GameEngine/Database.php`](https://github.com/shadowss/travianz/blob/master/GameEngine/Database.php) (Database access), [`GameEngine/Automation.php`](https://github.com/shadowss/travianz/blob/master/GameEngine/Automation.php) (World automation), [`index.php`](https://github.com/shadowss/travianz/blob/master/index.php) (Game entry), [`GameEngine/Session.php`](https://github.com/shadowss/travianz/blob/master/GameEngine/Session.php) (Player session)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Entry and access"]
  node_web["Game entry<br/>[index.php]"]
  node_session["Player session<br/>[Session.php]"]
  node_security["Request security<br/>[Security.class.php]"]
  node_templates["Game views<br/>[index.php]"]
end

subgraph group_gameplay["Game mechanics"]
  node_village["Village management<br/>[Village.php]"]
  node_buildings["Building system<br/>[Building.php]"]
  node_troops["Units and training<br/>[Units.php]"]
  node_combat["Battle resolution<br/>[Battle.php]"]
  node_artifacts["Artifacts<br/>[Artifacts.php]"]
  node_hero["Hero features<br/>[HeroItems.php]"]
  node_hero_adventures["Hero adventures<br/>[HeroAdventure.php]"]
  node_hero_auction["Hero auction<br/>[HeroAuction.php]"]
  node_game_data["Game data tables<br/>[buidata.php]"]
end

subgraph group_social["Community and progression"]
  node_alliance["Alliance system<br/>[Alliance.php]"]
  node_alliance_bonus["Alliance bonuses<br/>[AllianceBonus.php]"]
  node_messages["Messages and chat<br/>[Message.php]"]
  node_ranking["Rankings and statistics<br/>[Ranking.php]"]
end

subgraph group_operations["World operations"]
  node_automation["World automation<br/>[Automation.php]"]
  node_automation_battle["Automated battles"]
  node_admin["Admin panel<br/>[index.php]"]
end

subgraph group_persistence["Persistence"]
  node_database["Database access<br/>[Database.php]"]
  node_village_queries["Village queries"]
  node_alliance_queries["Alliance queries"]
  node_troop_queries["Troop queries"]
  node_mariadb[("MariaDB")]
end

node_player(("Player"))

node_player -->|"opens"| node_web
node_web -->|"loads"| node_security
node_web -->|"loads"| node_database
node_web -.->|"starts gameplay"| node_session
node_player -.->|"authenticates"| node_session
node_session -->|"loads"| node_database
node_session -.->|"serves views"| node_templates
node_templates -.->|"presents"| node_village
node_village -.->|"manages"| node_buildings
node_village -.->|"reads and writes"| node_database
node_buildings -.->|"uses definitions"| node_game_data
node_troops -.->|"uses definitions"| node_game_data
node_combat -->|"applies bonuses"| node_hero
node_combat -->|"applies bonuses"| node_alliance_bonus
node_automation -->|"loads"| node_combat
node_automation -->|"processes upgrades"| node_alliance_bonus
node_automation -->|"delegates"| node_automation_battle
node_automation -->|"loads"| node_database
node_alliance -->|"creates permissions"| node_database
node_alliance -->|"sends notices"| node_messages
node_hero -.->|"supports"| node_hero_adventures
node_hero -.->|"supports"| node_hero_auction
node_admin -->|"updates game data"| node_database
node_database -->|"delegates"| node_village_queries
node_database -->|"delegates"| node_alliance_queries
node_database -->|"delegates"| node_troop_queries
node_database -.->|"queries"| node_mariadb
node_ranking -.->|"renders rankings"| node_templates
node_artifacts -.->|"advances world state"| node_automation

click node_web "https://github.com/shadowss/travianz/blob/master/index.php"
click node_session "https://github.com/shadowss/travianz/blob/master/GameEngine/Session.php"
click node_security "https://github.com/shadowss/travianz/blob/master/Security/Security.class.php"
click node_village "https://github.com/shadowss/travianz/blob/master/GameEngine/Village.php"
click node_buildings "https://github.com/shadowss/travianz/blob/master/GameEngine/Building.php"
click node_troops "https://github.com/shadowss/travianz/blob/master/GameEngine/Units.php"
click node_combat "https://github.com/shadowss/travianz/blob/master/GameEngine/Battle.php"
click node_artifacts "https://github.com/shadowss/travianz/blob/master/GameEngine/Artifacts.php"
click node_hero "https://github.com/shadowss/travianz/blob/master/GameEngine/HeroItems.php"
click node_hero_adventures "https://github.com/shadowss/travianz/blob/master/GameEngine/HeroAdventure.php"
click node_hero_auction "https://github.com/shadowss/travianz/blob/master/GameEngine/HeroAuction.php"
click node_alliance "https://github.com/shadowss/travianz/blob/master/GameEngine/Alliance.php"
click node_alliance_bonus "https://github.com/shadowss/travianz/blob/master/GameEngine/AllianceBonus.php"
click node_messages "https://github.com/shadowss/travianz/blob/master/GameEngine/Message.php"
click node_ranking "https://github.com/shadowss/travianz/blob/master/GameEngine/Ranking.php"
click node_automation "https://github.com/shadowss/travianz/blob/master/GameEngine/Automation.php"
click node_automation_battle "https://github.com/shadowss/travianz/blob/master/GameEngine/Automation/AutomationBattleResolution.php"
click node_admin "https://github.com/shadowss/travianz/blob/master/GameEngine/Admin/Mods/index.php"
click node_templates "https://github.com/shadowss/travianz/blob/master/Templates/index.php"
click node_game_data "https://github.com/shadowss/travianz/blob/master/GameEngine/Data/buidata.php"
click node_database "https://github.com/shadowss/travianz/blob/master/GameEngine/Database.php"
click node_village_queries "https://github.com/shadowss/travianz/blob/master/GameEngine/Database/DatabaseVillageQueries.php"
click node_alliance_queries "https://github.com/shadowss/travianz/blob/master/GameEngine/Database/DatabaseAllianceQueries.php"
click node_troop_queries "https://github.com/shadowss/travianz/blob/master/GameEngine/Database/DatabaseTroopQueries.php"

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_web,node_session,node_security,node_templates toneBlue
class node_village,node_buildings,node_troops,node_combat,node_artifacts,node_hero,node_hero_adventures,node_hero_auction,node_game_data toneAmber
class node_alliance,node_alliance_bonus,node_messages,node_ranking toneMint
class node_automation,node_automation_battle,node_admin toneRose
class node_database,node_village_queries,node_alliance_queries,node_troop_queries,node_mariadb,node_player toneIndigo
```

## Components

### Entry and access

- [Game entry](https://github.com/shadowss/travianz/blob/master/index.php): `index.php`
- [Player session](https://github.com/shadowss/travianz/blob/master/GameEngine/Session.php): `GameEngine/Session.php`
- [Request security](https://github.com/shadowss/travianz/blob/master/Security/Security.class.php): `Security/Security.class.php`
- [Game views](https://github.com/shadowss/travianz/blob/master/Templates/index.php): `Templates/index.php`

### Game mechanics

- [Village management](https://github.com/shadowss/travianz/blob/master/GameEngine/Village.php): `GameEngine/Village.php`
- [Building system](https://github.com/shadowss/travianz/blob/master/GameEngine/Building.php): `GameEngine/Building.php`
- [Units and training](https://github.com/shadowss/travianz/blob/master/GameEngine/Units.php): `GameEngine/Units.php`
- [Battle resolution](https://github.com/shadowss/travianz/blob/master/GameEngine/Battle.php): `GameEngine/Battle.php`
- [Artifacts](https://github.com/shadowss/travianz/blob/master/GameEngine/Artifacts.php): `GameEngine/Artifacts.php`
- [Hero features](https://github.com/shadowss/travianz/blob/master/GameEngine/HeroItems.php): `GameEngine/HeroItems.php`
- [Hero adventures](https://github.com/shadowss/travianz/blob/master/GameEngine/HeroAdventure.php): `GameEngine/HeroAdventure.php`
- [Hero auction](https://github.com/shadowss/travianz/blob/master/GameEngine/HeroAuction.php): `GameEngine/HeroAuction.php`
- [Game data tables](https://github.com/shadowss/travianz/blob/master/GameEngine/Data/buidata.php): `GameEngine/Data/buidata.php`

### Community and progression

- [Alliance system](https://github.com/shadowss/travianz/blob/master/GameEngine/Alliance.php): `GameEngine/Alliance.php`
- [Alliance bonuses](https://github.com/shadowss/travianz/blob/master/GameEngine/AllianceBonus.php): `GameEngine/AllianceBonus.php`
- [Messages and chat](https://github.com/shadowss/travianz/blob/master/GameEngine/Message.php): `GameEngine/Message.php`
- [Rankings and statistics](https://github.com/shadowss/travianz/blob/master/GameEngine/Ranking.php): `GameEngine/Ranking.php`

### World operations

- [World automation](https://github.com/shadowss/travianz/blob/master/GameEngine/Automation.php): `GameEngine/Automation.php`
- [Automated battles](https://github.com/shadowss/travianz/blob/master/GameEngine/Automation/AutomationBattleResolution.php): `GameEngine/Automation/AutomationBattleResolution.php`
- [Admin panel](https://github.com/shadowss/travianz/blob/master/GameEngine/Admin/Mods/index.php): `GameEngine/Admin/Mods/index.php`

### Persistence

- [Database access](https://github.com/shadowss/travianz/blob/master/GameEngine/Database.php): `GameEngine/Database.php`
- [Village queries](https://github.com/shadowss/travianz/blob/master/GameEngine/Database/DatabaseVillageQueries.php): `GameEngine/Database/DatabaseVillageQueries.php`
- [Alliance queries](https://github.com/shadowss/travianz/blob/master/GameEngine/Database/DatabaseAllianceQueries.php): `GameEngine/Database/DatabaseAllianceQueries.php`
- [Troop queries](https://github.com/shadowss/travianz/blob/master/GameEngine/Database/DatabaseTroopQueries.php): `GameEngine/Database/DatabaseTroopQueries.php`
- **MariaDB**

### Other components

- **Player**

## Connections

- Player → Game entry: opens
- Game entry → Request security: loads (evidence: `index.php`)
- Game entry → Database access: loads (evidence: `index.php`)
- Game entry → Player session: starts gameplay
- Player → Player session: authenticates
- Player session → Database access: loads (evidence: `GameEngine/Session.php`)
- Player session → Game views: serves views
- Game views → Village management: presents
- Village management → Building system: manages
- Village management → Database access: reads and writes
- Building system → Game data tables: uses definitions
- Units and training → Game data tables: uses definitions
- Battle resolution → Hero features: applies bonuses (evidence: `GameEngine/Battle.php`)
- Battle resolution → Alliance bonuses: applies bonuses (evidence: `GameEngine/Battle.php`)
- World automation → Battle resolution: loads (evidence: `GameEngine/Automation.php`)
- World automation → Alliance bonuses: processes upgrades (evidence: `GameEngine/Automation.php`)
- World automation → Automated battles: delegates (evidence: `GameEngine/Automation/AutomationBattleResolution.php`)
- World automation → Database access: loads (evidence: `GameEngine/Automation.php`)
- Alliance system → Database access: creates permissions (evidence: `GameEngine/Alliance.php`)
- Alliance system → Messages and chat: sends notices (evidence: `GameEngine/Alliance.php`)
- Hero features → Hero adventures: supports
- Hero features → Hero auction: supports
- Admin panel → Database access: updates game data
- Database access → Village queries: delegates (evidence: `GameEngine/Database.php`)
- Database access → Alliance queries: delegates (evidence: `GameEngine/Database.php`)
- Database access → Troop queries: delegates (evidence: `GameEngine/Database.php`)
- Database access → MariaDB: queries
- Rankings and statistics → Game views: renders rankings
- Artifacts → World automation: advances world state (evidence: `GameEngine/Automation.php`)
