# mentolka1207/my-web-rts architecture

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

- Interactive diagram: https://gitdiagram.com/mentolka1207/my-web-rts
- Repository: https://github.com/mentolka1207/my-web-rts

## Overview

Tabhold is a browser-based 3D RTS: the player configures and commands an army, manages resources and abilities, and fights AI-driven waves toward victory. The main loop coordinates gameplay and rendering; supporting branches cover procedural maps, tactical movement, presentation, persistence, audio, and the optional worker-based stress test. The README documents several capabilities whose internal call sites were not sampled, so those subsystems are included without speculative links. Evidence is limited to the README and shown source excerpts.

Main entry points: [`main.js`](https://github.com/mentolka1207/my-web-rts/blob/main/main.js) (Game Loop), [`js/ui.js`](https://github.com/mentolka1207/my-web-rts/blob/main/js/ui.js) (HUD & Menus), [`sw.js`](https://github.com/mentolka1207/my-web-rts/blob/main/sw.js) (PWA Cache), [`js/input.js`](https://github.com/mentolka1207/my-web-rts/blob/main/js/input.js) (Game Input)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_controls["Player &amp; Interface"]
  node_input["Game Input<br/>[input.js]"]
  node_ui["HUD &amp; Menus<br/>[ui.js]"]
  node_i18n["Translations<br/>[i18n.js]"]
end

subgraph group_gameplay["Combat Simulation"]
  node_main["Game Loop<br/>[main.js]"]
  node_simulation["Unit Simulation<br/>[simulation.js]"]
  node_fsm["Unit State Logic<br/>[fsm.js]"]
  node_ai["Wave AI<br/>[ai.js]"]
  node_economy["Economy<br/>[economy.js]"]
  node_resources["Resource Nodes<br/>[resources.js]"]
  node_units["Units &amp; Abilities<br/>[units.js]"]
  node_formations["Formations<br/>[formations.js]"]
  node_flowfield["Flow Fields<br/>[flowfield.js]"]
  node_spatial["Spatial Hash<br/>[spatialhash.js]"]
  node_worker["Stress Workers<br/>[sim_worker.js]"]
end

subgraph group_world["World &amp; Rendering"]
  node_maps["Procedural Maps<br/>[maps.js]"]
  node_terrain["Terrain<br/>[terrain.js]"]
  node_scene["3D Scene<br/>[scene.js]"]
  node_models["Procedural Models<br/>[models.js]"]
  node_instancing["GPU Instancing<br/>[instancing.js]"]
  node_minimap["Minimap<br/>[minimap.js]"]
end

subgraph group_support["Game Services"]
  node_audio["Procedural Audio<br/>[audio.js]"]
  node_storage[("Local Persistence<br/>[storage.js]")]
  node_serviceworker["PWA Cache<br/>[sw.js]"]
end

node_player(("Player"))

node_player -->|"issues commands"| node_input
node_main -->|"dispatches stress test"| node_worker
node_main -->|"updates enemy AI"| node_ai
node_main -->|"updates abilities"| node_units
node_main -->|"renders frame"| node_scene
node_ui -->|"starts ambient"| node_audio
node_ui -->|"loads profile"| node_storage
node_serviceworker -->|"serves cached app"| node_player

click node_input "https://github.com/mentolka1207/my-web-rts/blob/main/js/input.js"
click node_ui "https://github.com/mentolka1207/my-web-rts/blob/main/js/ui.js"
click node_i18n "https://github.com/mentolka1207/my-web-rts/blob/main/js/i18n.js"
click node_main "https://github.com/mentolka1207/my-web-rts/blob/main/main.js"
click node_simulation "https://github.com/mentolka1207/my-web-rts/blob/main/js/simulation.js"
click node_fsm "https://github.com/mentolka1207/my-web-rts/blob/main/js/fsm.js"
click node_ai "https://github.com/mentolka1207/my-web-rts/blob/main/js/ai.js"
click node_economy "https://github.com/mentolka1207/my-web-rts/blob/main/js/economy.js"
click node_resources "https://github.com/mentolka1207/my-web-rts/blob/main/js/resources.js"
click node_units "https://github.com/mentolka1207/my-web-rts/blob/main/js/units.js"
click node_formations "https://github.com/mentolka1207/my-web-rts/blob/main/js/formations.js"
click node_flowfield "https://github.com/mentolka1207/my-web-rts/blob/main/js/flowfield.js"
click node_spatial "https://github.com/mentolka1207/my-web-rts/blob/main/js/spatialhash.js"
click node_worker "https://github.com/mentolka1207/my-web-rts/blob/main/js/sim_worker.js"
click node_maps "https://github.com/mentolka1207/my-web-rts/blob/main/js/maps.js"
click node_terrain "https://github.com/mentolka1207/my-web-rts/blob/main/js/terrain.js"
click node_scene "https://github.com/mentolka1207/my-web-rts/blob/main/js/scene.js"
click node_models "https://github.com/mentolka1207/my-web-rts/blob/main/js/models.js"
click node_instancing "https://github.com/mentolka1207/my-web-rts/blob/main/js/instancing.js"
click node_minimap "https://github.com/mentolka1207/my-web-rts/blob/main/js/minimap.js"
click node_audio "https://github.com/mentolka1207/my-web-rts/blob/main/js/audio.js"
click node_storage "https://github.com/mentolka1207/my-web-rts/blob/main/js/storage.js"
click node_serviceworker "https://github.com/mentolka1207/my-web-rts/blob/main/sw.js"

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_input,node_ui,node_i18n toneBlue
class node_main,node_simulation,node_fsm,node_ai,node_economy,node_resources,node_units,node_formations,node_flowfield,node_spatial,node_worker toneAmber
class node_maps,node_terrain,node_scene,node_models,node_instancing,node_minimap toneMint
class node_audio,node_storage,node_serviceworker toneRose
class node_player toneIndigo
```

## Components

### Player & Interface

- [Game Input](https://github.com/mentolka1207/my-web-rts/blob/main/js/input.js): `js/input.js`
- [HUD & Menus](https://github.com/mentolka1207/my-web-rts/blob/main/js/ui.js): `js/ui.js`
- [Translations](https://github.com/mentolka1207/my-web-rts/blob/main/js/i18n.js): `js/i18n.js`

### Combat Simulation

- [Game Loop](https://github.com/mentolka1207/my-web-rts/blob/main/main.js): `main.js`
- [Unit Simulation](https://github.com/mentolka1207/my-web-rts/blob/main/js/simulation.js): `js/simulation.js`
- [Unit State Logic](https://github.com/mentolka1207/my-web-rts/blob/main/js/fsm.js): `js/fsm.js`
- [Wave AI](https://github.com/mentolka1207/my-web-rts/blob/main/js/ai.js): `js/ai.js`
- [Economy](https://github.com/mentolka1207/my-web-rts/blob/main/js/economy.js): `js/economy.js`
- [Resource Nodes](https://github.com/mentolka1207/my-web-rts/blob/main/js/resources.js): `js/resources.js`
- [Units & Abilities](https://github.com/mentolka1207/my-web-rts/blob/main/js/units.js): `js/units.js`
- [Formations](https://github.com/mentolka1207/my-web-rts/blob/main/js/formations.js): `js/formations.js`
- [Flow Fields](https://github.com/mentolka1207/my-web-rts/blob/main/js/flowfield.js): `js/flowfield.js`
- [Spatial Hash](https://github.com/mentolka1207/my-web-rts/blob/main/js/spatialhash.js): `js/spatialhash.js`
- [Stress Workers](https://github.com/mentolka1207/my-web-rts/blob/main/js/sim_worker.js): `js/sim_worker.js`

### World & Rendering

- [Procedural Maps](https://github.com/mentolka1207/my-web-rts/blob/main/js/maps.js): `js/maps.js`
- [Terrain](https://github.com/mentolka1207/my-web-rts/blob/main/js/terrain.js): `js/terrain.js`
- [3D Scene](https://github.com/mentolka1207/my-web-rts/blob/main/js/scene.js): `js/scene.js`
- [Procedural Models](https://github.com/mentolka1207/my-web-rts/blob/main/js/models.js): `js/models.js`
- [GPU Instancing](https://github.com/mentolka1207/my-web-rts/blob/main/js/instancing.js): `js/instancing.js`
- [Minimap](https://github.com/mentolka1207/my-web-rts/blob/main/js/minimap.js): `js/minimap.js`

### Game Services

- [Procedural Audio](https://github.com/mentolka1207/my-web-rts/blob/main/js/audio.js): `js/audio.js`
- [Local Persistence](https://github.com/mentolka1207/my-web-rts/blob/main/js/storage.js): `js/storage.js`
- [PWA Cache](https://github.com/mentolka1207/my-web-rts/blob/main/sw.js): `sw.js`

### Other components

- **Player**

## Connections

- Player → Game Input: issues commands (evidence: `README.md`)
- Game Loop → Stress Workers: dispatches stress test (evidence: `main.js`)
- Game Loop → Wave AI: updates enemy AI (evidence: `main.js`)
- Game Loop → Units & Abilities: updates abilities (evidence: `main.js`)
- Game Loop → 3D Scene: renders frame (evidence: `main.js`)
- HUD & Menus → Procedural Audio: starts ambient (evidence: `js/ui.js`)
- HUD & Menus → Local Persistence: loads profile (evidence: `js/ui.js`)
- PWA Cache → Player: serves cached app (evidence: `sw.js`)
