# saara-u-r/tower-game architecture

> Architecture diagram of the GitHub repository saara-u-r/tower-game, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/saara-u-r/tower-game
- Repository: https://github.com/saara-u-r/tower-game

## Overview

SecureVille is a browser-based cyber-city defense game with a Flask backend for serving the game and shared leaderboard data. The player enters a name and department, then plays a lane-based, multi-wave defense run with threats, defenses, decision events, upgrades and a boss encounter. The frontend loads game configuration from the backend; the backend validates and stores leaderboard submissions in SQLite. The game excerpt is partial, so frontend-to-score API wiring and some gameplay details are not shown.

Main entry points: [`app.py`](https://github.com/saara-u-r/tower-game/blob/main/app.py) (Config endpoint), [`static/js/login.js`](https://github.com/saara-u-r/tower-game/blob/main/static/js/login.js) (Identity gate), [`static/js/game.js`](https://github.com/saara-u-r/tower-game/blob/main/static/js/game.js) (Game runtime), [`templates/index.html`](https://github.com/saara-u-r/tower-game/blob/main/templates/index.html) (Game page)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Player experience"]
  node_login["Identity gate<br/>[login.js]"]
  node_page["Game page<br/>[index.html]"]
end

subgraph group_gameplay["Game systems"]
  node_game["Game runtime<br/>[game.js]"]
  node_waves["Wave combat<br/>[game.js]"]
  node_decisions["Decision events<br/>[game.js]"]
  node_upgrades["Upgrade system<br/>[game.js]"]
  node_rendering["City rendering<br/>[game.js]"]
end

subgraph group_backend["Backend services"]
  node_api["Flask API<br/>[app.py]"]
  node_config["Config endpoint<br/>[app.py]"]
  node_leaderboard[("Leaderboard store")]
end

subgraph group_content["Game configuration"]
  node_buildings["Building data<br/>[buildings.json]"]
  node_threats["Threat data<br/>[threats.json]"]
  node_defenses["Defense data<br/>[defenses.json]"]
end

node_player(("Player"))

node_player -->|"enters identity"| node_login
node_login -->|"starts game"| node_game
node_game -->|"fetches config"| node_config
node_api -->|"renders page"| node_page
node_api -->|"serves config"| node_config
node_config -->|"loads data"| node_buildings
node_config -->|"loads data"| node_threats
node_config -->|"loads data"| node_defenses
node_api -->|"reads and writes"| node_leaderboard

click node_login "https://github.com/saara-u-r/tower-game/blob/main/static/js/login.js"
click node_game "https://github.com/saara-u-r/tower-game/blob/main/static/js/game.js"
click node_waves "https://github.com/saara-u-r/tower-game/blob/main/static/js/game.js"
click node_decisions "https://github.com/saara-u-r/tower-game/blob/main/static/js/game.js"
click node_upgrades "https://github.com/saara-u-r/tower-game/blob/main/static/js/game.js"
click node_rendering "https://github.com/saara-u-r/tower-game/blob/main/static/js/game.js"
click node_page "https://github.com/saara-u-r/tower-game/blob/main/templates/index.html"
click node_api "https://github.com/saara-u-r/tower-game/blob/main/app.py"
click node_config "https://github.com/saara-u-r/tower-game/blob/main/app.py"
click node_buildings "https://github.com/saara-u-r/tower-game/blob/main/config/buildings.json"
click node_threats "https://github.com/saara-u-r/tower-game/blob/main/config/threats.json"
click node_defenses "https://github.com/saara-u-r/tower-game/blob/main/config/defenses.json"

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_login,node_page toneBlue
class node_game,node_waves,node_decisions,node_upgrades,node_rendering toneAmber
class node_api,node_config,node_leaderboard toneMint
class node_buildings,node_threats,node_defenses toneRose
class node_player toneIndigo
```

## Components

### Player experience

- [Identity gate](https://github.com/saara-u-r/tower-game/blob/main/static/js/login.js): `static/js/login.js`
- [Game page](https://github.com/saara-u-r/tower-game/blob/main/templates/index.html): `templates/index.html`

### Game systems

- [Game runtime](https://github.com/saara-u-r/tower-game/blob/main/static/js/game.js): `static/js/game.js`
- [Wave combat](https://github.com/saara-u-r/tower-game/blob/main/static/js/game.js): `static/js/game.js`
- [Decision events](https://github.com/saara-u-r/tower-game/blob/main/static/js/game.js): `static/js/game.js`
- [Upgrade system](https://github.com/saara-u-r/tower-game/blob/main/static/js/game.js): `static/js/game.js`
- [City rendering](https://github.com/saara-u-r/tower-game/blob/main/static/js/game.js): `static/js/game.js`

### Backend services

- [Flask API](https://github.com/saara-u-r/tower-game/blob/main/app.py): `app.py`
- [Config endpoint](https://github.com/saara-u-r/tower-game/blob/main/app.py): `app.py`
- **Leaderboard store**

### Game configuration

- [Building data](https://github.com/saara-u-r/tower-game/blob/main/config/buildings.json): `config/buildings.json`
- [Threat data](https://github.com/saara-u-r/tower-game/blob/main/config/threats.json): `config/threats.json`
- [Defense data](https://github.com/saara-u-r/tower-game/blob/main/config/defenses.json): `config/defenses.json`

### Other components

- **Player**

## Connections

- Player → Identity gate: enters identity (evidence: `static/js/login.js`)
- Identity gate → Game runtime: starts game (evidence: `static/js/login.js`)
- Game runtime → Config endpoint: fetches config (evidence: `static/js/game.js`)
- Flask API → Game page: renders page (evidence: `app.py`)
- Flask API → Config endpoint: serves config (evidence: `app.py`)
- Config endpoint → Building data: loads data (evidence: `app.py`)
- Config endpoint → Threat data: loads data (evidence: `app.py`)
- Config endpoint → Defense data: loads data (evidence: `app.py`)
- Flask API → Leaderboard store: reads and writes (evidence: `app.py`)
