# maxnest0x0/gardn architecture

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

- Interactive diagram: https://gitdiagram.com/maxnest0x0/gardn
- Repository: https://github.com/maxnest0x0/gardn

## Overview

The gardn is a self-hostable multiplayer PvP game inspired by florr.io. A player configures a mode and loadout, joins a game, sends movement and action input, and receives multiplayer game state rendered in the browser. The server runs game instances and ECS simulation processes for movement, AI, combat, drops and scoring; shared definitions and simulation structures support both sides. The README also documents native and WebAssembly server options, Canvas2D rendering, a custom UI engine, and uniform-grid collision queries. Some client/server wiring is inferred only at subsystem level because those sources were not sampled.

Main entry points: [`Shared/Simulation.cc`](https://github.com/maxnest0x0/gardn/blob/master/Shared/Simulation.cc) (ECS Simulation), [`Client/Game.cc`](https://github.com/maxnest0x0/gardn/blob/master/Client/Game.cc) (Client Game), [`Server/Game.cc`](https://github.com/maxnest0x0/gardn/blob/master/Server/Game.cc) (Game Instances), [`Client/Ui/TitleScreen`](https://github.com/maxnest0x0/gardn/tree/master/Client/Ui/TitleScreen) (Title Screens)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Browser Client"]
  node_client_game["Client Game<br/>[Game.cc]"]
  node_client_ui["UI Engine"]
  node_title_ui["Title Screens"]
  node_ingame_ui["In-game UI"]
  node_client_input["Input Handling<br/>[Input.cc]"]
  node_client_network["Client Networking<br/>[Network.cc]"]
  node_client_render["Game Rendering<br/>[Rendering.cc]"]
  node_canvas_renderer["Canvas Renderer<br/>[Renderer.cc]"]
  node_local_storage[("Local Storage<br/>[Storage.cc]")]
end

subgraph group_server["Game Server"]
  node_game_instances["Game Instances<br/>[Game.cc]"]
  node_server_client["Client Sessions<br/>[Client.cc]"]
  node_server_loop["Server Tick<br/>[Server.cc]"]
end

subgraph group_shared["Shared Runtime"]
  node_simulation["ECS Simulation<br/>[Simulation.cc]"]
  node_entity_model["Entity Model<br/>[Entity.cc]"]
  node_static_data["Game Definitions<br/>[StaticData.cc]"]
  node_map_data["Map and Arena<br/>[Map.cc]"]
end

subgraph group_gameplay["Gameplay Features"]
  node_processes["Simulation Processes"]
  node_collision["Collision Queries"]
  node_combat["Damage and Death"]
  node_spawning["Entity Spawning<br/>[Spawn.cc]"]
  node_teams["Team Management<br/>[TeamManager.cc]"]
end

node_player(("Player"))
node_browser["Browser APIs"]
node_socket_peer["WebSocket Peer"]

node_player -->|"chooses mode"| node_title_ui
node_player -->|"sends input"| node_client_input
node_title_ui -->|"switches mode"| node_client_game
node_client_ui -->|"draws UI"| node_canvas_renderer
node_ingame_ui -->|"uses layout"| node_client_ui
node_title_ui -->|"uses layout"| node_client_ui
node_client_game -->|"handles input"| node_client_input
node_client_game -->|"exchanges packets"| node_client_network
node_client_game -->|"renders state"| node_client_render
node_client_render -->|"draws frame"| node_canvas_renderer
node_canvas_renderer -->|"uses Canvas2D"| node_browser
node_client_game -->|"loads and saves"| node_local_storage
node_local_storage -->|"uses browser storage"| node_browser
node_client_network -->|"exchanges packets"| node_socket_peer
node_socket_peer -->|"delivers messages"| node_server_client
node_server_loop -->|"ticks instances"| node_game_instances
node_game_instances -->|"manages sessions"| node_server_client
node_game_instances -->|"runs simulation"| node_simulation
node_simulation -->|"updates entities"| node_entity_model
node_simulation -->|"runs processes"| node_processes
node_simulation -->|"queries spatial grid"| node_collision
node_processes -->|"applies combat"| node_combat
node_processes -->|"creates entities"| node_spawning
node_game_instances -->|"manages teams"| node_teams
node_simulation -->|"uses definitions"| node_static_data
node_simulation -->|"uses map data"| node_map_data

click node_client_game "https://github.com/maxnest0x0/gardn/blob/master/Client/Game.cc"
click node_client_ui "https://github.com/maxnest0x0/gardn/tree/master/Client/Ui"
click node_title_ui "https://github.com/maxnest0x0/gardn/tree/master/Client/Ui/TitleScreen"
click node_ingame_ui "https://github.com/maxnest0x0/gardn/tree/master/Client/Ui/InGame"
click node_client_input "https://github.com/maxnest0x0/gardn/blob/master/Client/Input.cc"
click node_client_network "https://github.com/maxnest0x0/gardn/blob/master/Client/Network.cc"
click node_client_render "https://github.com/maxnest0x0/gardn/blob/master/Client/Rendering.cc"
click node_canvas_renderer "https://github.com/maxnest0x0/gardn/blob/master/Client/Render/Renderer.cc"
click node_local_storage "https://github.com/maxnest0x0/gardn/blob/master/Client/Storage.cc"
click node_game_instances "https://github.com/maxnest0x0/gardn/blob/master/Server/Game.cc"
click node_server_client "https://github.com/maxnest0x0/gardn/blob/master/Server/Client.cc"
click node_server_loop "https://github.com/maxnest0x0/gardn/blob/master/Server/Server.cc"
click node_simulation "https://github.com/maxnest0x0/gardn/blob/master/Shared/Simulation.cc"
click node_entity_model "https://github.com/maxnest0x0/gardn/blob/master/Shared/Entity.cc"
click node_static_data "https://github.com/maxnest0x0/gardn/blob/master/Shared/StaticData.cc"
click node_processes "https://github.com/maxnest0x0/gardn/tree/master/Server/Process"
click node_collision "https://github.com/maxnest0x0/gardn/blob/master/Server/SpatialHashUniform.cc"
click node_combat "https://github.com/maxnest0x0/gardn/tree/master/Server/EntityFunctions"
click node_spawning "https://github.com/maxnest0x0/gardn/blob/master/Server/Spawn.cc"
click node_teams "https://github.com/maxnest0x0/gardn/blob/master/Server/TeamManager.cc"
click node_map_data "https://github.com/maxnest0x0/gardn/blob/master/Shared/Map.cc"

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_client_game,node_client_ui,node_title_ui,node_ingame_ui,node_client_input,node_client_network,node_client_render,node_canvas_renderer,node_local_storage,node_browser toneBlue
class node_game_instances,node_server_client,node_server_loop toneAmber
class node_simulation,node_entity_model,node_static_data,node_map_data toneMint
class node_processes,node_collision,node_combat,node_spawning,node_teams toneRose
class node_player,node_socket_peer toneIndigo
```

## Components

### Browser Client

- [Client Game](https://github.com/maxnest0x0/gardn/blob/master/Client/Game.cc): `Client/Game.cc`
- [UI Engine](https://github.com/maxnest0x0/gardn/tree/master/Client/Ui): `Client/Ui`
- [Title Screens](https://github.com/maxnest0x0/gardn/tree/master/Client/Ui/TitleScreen): `Client/Ui/TitleScreen`
- [In-game UI](https://github.com/maxnest0x0/gardn/tree/master/Client/Ui/InGame): `Client/Ui/InGame`
- [Input Handling](https://github.com/maxnest0x0/gardn/blob/master/Client/Input.cc): `Client/Input.cc`
- [Client Networking](https://github.com/maxnest0x0/gardn/blob/master/Client/Network.cc): `Client/Network.cc`
- [Game Rendering](https://github.com/maxnest0x0/gardn/blob/master/Client/Rendering.cc): `Client/Rendering.cc`
- [Canvas Renderer](https://github.com/maxnest0x0/gardn/blob/master/Client/Render/Renderer.cc): `Client/Render/Renderer.cc`
- [Local Storage](https://github.com/maxnest0x0/gardn/blob/master/Client/Storage.cc): `Client/Storage.cc`

### Game Server

- [Game Instances](https://github.com/maxnest0x0/gardn/blob/master/Server/Game.cc): `Server/Game.cc`
- [Client Sessions](https://github.com/maxnest0x0/gardn/blob/master/Server/Client.cc): `Server/Client.cc`
- [Server Tick](https://github.com/maxnest0x0/gardn/blob/master/Server/Server.cc): `Server/Server.cc`

### Shared Runtime

- [ECS Simulation](https://github.com/maxnest0x0/gardn/blob/master/Shared/Simulation.cc): `Shared/Simulation.cc`
- [Entity Model](https://github.com/maxnest0x0/gardn/blob/master/Shared/Entity.cc): `Shared/Entity.cc`
- [Game Definitions](https://github.com/maxnest0x0/gardn/blob/master/Shared/StaticData.cc): `Shared/StaticData.cc`
- [Map and Arena](https://github.com/maxnest0x0/gardn/blob/master/Shared/Map.cc): `Shared/Map.cc`

### Gameplay Features

- [Simulation Processes](https://github.com/maxnest0x0/gardn/tree/master/Server/Process): `Server/Process`
- [Collision Queries](https://github.com/maxnest0x0/gardn/blob/master/Server/SpatialHashUniform.cc): `Server/SpatialHashUniform.cc`
- [Damage and Death](https://github.com/maxnest0x0/gardn/tree/master/Server/EntityFunctions): `Server/EntityFunctions`
- [Entity Spawning](https://github.com/maxnest0x0/gardn/blob/master/Server/Spawn.cc): `Server/Spawn.cc`
- [Team Management](https://github.com/maxnest0x0/gardn/blob/master/Server/TeamManager.cc): `Server/TeamManager.cc`

### Other components

- **Player**
- **Browser APIs**
- **WebSocket Peer**

## Connections

- Player → Title Screens: chooses mode
- Player → Input Handling: sends input
- Title Screens → Client Game: switches mode
- UI Engine → Canvas Renderer: draws UI
- In-game UI → UI Engine: uses layout
- Title Screens → UI Engine: uses layout
- Client Game → Input Handling: handles input
- Client Game → Client Networking: exchanges packets
- Client Game → Game Rendering: renders state
- Game Rendering → Canvas Renderer: draws frame
- Canvas Renderer → Browser APIs: uses Canvas2D
- Client Game → Local Storage: loads and saves
- Local Storage → Browser APIs: uses browser storage
- Client Networking → WebSocket Peer: exchanges packets
- WebSocket Peer → Client Sessions: delivers messages
- Server Tick → Game Instances: ticks instances
- Game Instances → Client Sessions: manages sessions
- Game Instances → ECS Simulation: runs simulation
- ECS Simulation → Entity Model: updates entities
- ECS Simulation → Simulation Processes: runs processes
- ECS Simulation → Collision Queries: queries spatial grid
- Simulation Processes → Damage and Death: applies combat
- Simulation Processes → Entity Spawning: creates entities
- Game Instances → Team Management: manages teams
- ECS Simulation → Game Definitions: uses definitions
- ECS Simulation → Map and Arena: uses map data
