# mojoismojo/heat-online architecture

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

- Interactive diagram: https://gitdiagram.com/mojoismojo/heat-online
- Repository: https://github.com/mojoismojo/heat-online

## Overview

HEAT is a Chinese-language multiplayer racing game. Players create or join a room, configure its track and optional modules, draft upgrades when enabled, then plan and resolve race turns until the server ranks finishers. The page polls room state and submits actions through the room API; the shared game engine validates and applies them before state is persisted. The graph also shows track rendering and turn/module interfaces. Relationships among unsampled subsystems are included only where the README documents them; source excerpts do not expose every runtime detail.

Main entry points: [`app/page.tsx`](https://github.com/mojoismojo/heat-online/blob/main/app/page.tsx) (Game page), [`lib/game.ts`](https://github.com/mojoismojo/heat-online/blob/main/lib/game.ts) (Game engine), [`app/circuit.tsx`](https://github.com/mojoismojo/heat-online/blob/main/app/circuit.tsx) (Circuit renderer), [`lib/modules.ts`](https://github.com/mojoismojo/heat-online/blob/main/lib/modules.ts) (Module rules)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["Player experience"]
  node_web["Game page<br/>[page.tsx]"]
  node_room_api["Room API<br/>[route.ts]"]
  node_round_flow["Turn guide<br/>[round-flow.tsx]"]
  node_round_events["Round events<br/>[round-events.tsx]"]
  node_modules_ui["Module interface<br/>[modules-ui.tsx]"]
end

subgraph group_race["Race rules"]
  node_engine["Game engine<br/>[game.ts]"]
end

subgraph group_content["Tracks and modules"]
  node_tracks["Track definitions<br/>[tracks.ts]"]
  node_geometry["Track geometry<br/>[track-geometry.ts]"]
  node_circuit["Circuit renderer<br/>[circuit.tsx]"]
  node_module_data["Module rules<br/>[modules.ts]"]
  node_upgrade_help["Upgrade guidance<br/>[upgrade-help.ts]"]
end

subgraph group_persistence["Room persistence"]
  node_room_store["Room storage adapter<br/>[room-store.ts]"]
  node_room_db[("Room database<br/>[schema.ts]")]
end

node_player(("Driver"))

node_player -->|"plays through"| node_web
node_web -->|"polls and submits"| node_room_api
node_room_api -->|"validates actions"| node_engine
node_room_api -->|"reads and writes"| node_room_store
node_room_store -.->|"persists room state"| node_room_db
node_engine -->|"uses track rules"| node_tracks
node_engine -->|"compares car positions"| node_geometry
node_engine -->|"applies module rules"| node_module_data
node_web -->|"renders circuit"| node_circuit
node_circuit -->|"reads track data"| node_tracks
node_circuit -->|"uses geometry"| node_geometry
node_circuit -->|"renders road effects"| node_module_data
node_web -->|"shows turn guide"| node_round_flow
node_web -->|"shows round events"| node_round_events
node_web -->|"shows race modules"| node_modules_ui
node_modules_ui -->|"displays module rules"| node_module_data
node_modules_ui -->|"shows upgrade guidance"| node_upgrade_help
node_upgrade_help -->|"reads upgrade definitions"| node_module_data

click node_web "https://github.com/mojoismojo/heat-online/blob/main/app/page.tsx"
click node_room_api "https://github.com/mojoismojo/heat-online/blob/main/app/api/rooms/route.ts"
click node_round_flow "https://github.com/mojoismojo/heat-online/blob/main/app/round-flow.tsx"
click node_round_events "https://github.com/mojoismojo/heat-online/blob/main/app/round-events.tsx"
click node_modules_ui "https://github.com/mojoismojo/heat-online/blob/main/app/modules-ui.tsx"
click node_engine "https://github.com/mojoismojo/heat-online/blob/main/lib/game.ts"
click node_tracks "https://github.com/mojoismojo/heat-online/blob/main/lib/tracks.ts"
click node_geometry "https://github.com/mojoismojo/heat-online/blob/main/lib/track-geometry.ts"
click node_circuit "https://github.com/mojoismojo/heat-online/blob/main/app/circuit.tsx"
click node_module_data "https://github.com/mojoismojo/heat-online/blob/main/lib/modules.ts"
click node_upgrade_help "https://github.com/mojoismojo/heat-online/blob/main/lib/upgrade-help.ts"
click node_room_store "https://github.com/mojoismojo/heat-online/blob/main/db/room-store.ts"
click node_room_db "https://github.com/mojoismojo/heat-online/blob/main/db/schema.ts"

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_room_api,node_round_flow,node_round_events,node_modules_ui toneBlue
class node_engine toneAmber
class node_tracks,node_geometry,node_circuit,node_module_data,node_upgrade_help toneMint
class node_room_store,node_room_db toneRose
class node_player toneIndigo
```

## Components

### Player experience

- [Game page](https://github.com/mojoismojo/heat-online/blob/main/app/page.tsx): `app/page.tsx`
- [Room API](https://github.com/mojoismojo/heat-online/blob/main/app/api/rooms/route.ts): `app/api/rooms/route.ts`
- [Turn guide](https://github.com/mojoismojo/heat-online/blob/main/app/round-flow.tsx): `app/round-flow.tsx`
- [Round events](https://github.com/mojoismojo/heat-online/blob/main/app/round-events.tsx): `app/round-events.tsx`
- [Module interface](https://github.com/mojoismojo/heat-online/blob/main/app/modules-ui.tsx): `app/modules-ui.tsx`

### Race rules

- [Game engine](https://github.com/mojoismojo/heat-online/blob/main/lib/game.ts): `lib/game.ts`

### Tracks and modules

- [Track definitions](https://github.com/mojoismojo/heat-online/blob/main/lib/tracks.ts): `lib/tracks.ts`
- [Track geometry](https://github.com/mojoismojo/heat-online/blob/main/lib/track-geometry.ts): `lib/track-geometry.ts`
- [Circuit renderer](https://github.com/mojoismojo/heat-online/blob/main/app/circuit.tsx): `app/circuit.tsx`
- [Module rules](https://github.com/mojoismojo/heat-online/blob/main/lib/modules.ts): `lib/modules.ts`
- [Upgrade guidance](https://github.com/mojoismojo/heat-online/blob/main/lib/upgrade-help.ts): `lib/upgrade-help.ts`

### Room persistence

- [Room storage adapter](https://github.com/mojoismojo/heat-online/blob/main/db/room-store.ts): `db/room-store.ts`
- [Room database](https://github.com/mojoismojo/heat-online/blob/main/db/schema.ts): `db/schema.ts`

### Other components

- **Driver**

## Connections

- Driver → Game page: plays through
- Game page → Room API: polls and submits
- Room API → Game engine: validates actions (evidence: `app/api/rooms/route.ts`)
- Room API → Room storage adapter: reads and writes (evidence: `app/api/rooms/route.ts`)
- Room storage adapter → Room database: persists room state
- Game engine → Track definitions: uses track rules (evidence: `lib/game.ts`)
- Game engine → Track geometry: compares car positions (evidence: `lib/game.ts`)
- Game engine → Module rules: applies module rules (evidence: `lib/game.ts`)
- Game page → Circuit renderer: renders circuit (evidence: `app/page.tsx`)
- Circuit renderer → Track definitions: reads track data (evidence: `app/circuit.tsx`)
- Circuit renderer → Track geometry: uses geometry (evidence: `app/circuit.tsx`)
- Circuit renderer → Module rules: renders road effects (evidence: `app/circuit.tsx`)
- Game page → Turn guide: shows turn guide (evidence: `app/page.tsx`)
- Game page → Round events: shows round events (evidence: `app/page.tsx`)
- Game page → Module interface: shows race modules (evidence: `app/page.tsx`)
- Module interface → Module rules: displays module rules (evidence: `app/modules-ui.tsx`)
- Module interface → Upgrade guidance: shows upgrade guidance (evidence: `app/modules-ui.tsx`)
- Upgrade guidance → Module rules: reads upgrade definitions (evidence: `lib/upgrade-help.ts`)
