# lakzayi/typeracer3d architecture

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

- Interactive diagram: https://gitdiagram.com/lakzayi/typeracer3d
- Repository: https://github.com/lakzayi/typeracer3d

## Overview

TypeRacer 3D is a browser-based typing race game: players choose a race, type its quote while vehicles and opponents advance, then see results and can share a replay challenge. Its main.js phase machine coordinates data selection, typing, race simulation, rendering, and results. README documents additional practice modes, language pools, local multiplayer, profile lookup, install/offline support, and historical-race data. Several of those implementations were not sampled, so their links are limited to documented relationships.

Main entry points: [`public/js/main.js`](https://github.com/lakzayi/typeracer3d/blob/main/public/js/main.js) (Game coordinator), [`public/js/themes/index.js`](https://github.com/lakzayi/typeracer3d/blob/main/public/js/themes/index.js) (Theme registry), [`public/js/api.js`](https://github.com/lakzayi/typeracer3d/blob/main/public/js/api.js) (Race data API), [`public/js/themes/shared.js`](https://github.com/lakzayi/typeracer3d/blob/main/public/js/themes/shared.js) (Theme helpers)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_gameflow["Game flow"]
  node_main["Game coordinator<br/>[main.js]"]
  node_hud["HUD and results<br/>[hud.js]"]
end

subgraph group_raceplay["Raceplay"]
  node_typing["Typing input<br/>[typing.js]"]
  node_race["Race simulation<br/>[race.js]"]
  node_modes["Race modes<br/>[modes.js]"]
  node_languages["Language pools<br/>[languages.js]"]
end

subgraph group_world["3D world"]
  node_worldcore["World renderer<br/>[world.js]"]
  node_gfx["Graphics quality<br/>[gfx.js]"]
  node_themes["Theme registry<br/>[index.js]"]
  node_car["Street Race<br/>[car.js]"]
  node_boat["River Rapids<br/>[boat.js]"]
  node_horse["Wild West Ride<br/>[horse.js]"]
  node_rocket["Orbit Dash<br/>[rocket.js]"]
  node_themehelpers["Theme helpers<br/>[shared.js]"]
  node_sound["Race audio<br/>[sound.js]"]
end

subgraph group_data["Race data"]
  node_api["Race data API<br/>[api.js]"]
  node_demo["Demo race data<br/>[demo-data.js]"]
  node_server["Data proxy and cache<br/>[server.js]"]
end

subgraph group_extras["Player features"]
  node_net["Online lobby<br/>[net.js]"]
  node_daily["Daily race<br/>[daily.js]"]
  node_drills["Typing drills<br/>[drills.js]"]
  node_stats[("Local stats<br/>[stats.js]")]
  node_achievements["Achievements<br/>[achievements.js]"]
  node_share["Share challenge<br/>[share.js]"]
  node_serviceworker["Offline support<br/>[sw.js]"]
end

node_player(("Player"))
node_typeracer(("TypeRacer public data"))

node_player -->|"starts and types"| node_main
node_main -->|"requests race"| node_api
node_main -->|"selects daily"| node_daily
node_main -->|"creates drill"| node_drills
node_main -->|"joins lobby"| node_net
node_main -->|"coordinates input"| node_typing
node_main -->|"runs race"| node_race
node_main -->|"updates world"| node_worldcore
node_main -->|"selects theme"| node_themes
node_main -->|"updates display"| node_hud
node_main -->|"controls audio"| node_sound
node_main -->|"updates stats"| node_stats
node_main -->|"checks awards"| node_achievements
node_main -->|"shares result"| node_share
node_api -->|"falls back to"| node_demo
node_api -.->|"requests race data"| node_server
node_server -->|"reads public races"| node_typeracer
node_main -.->|"uses language"| node_languages
node_race -->|"uses mode rules"| node_modes
node_main -->|"adjusts quality"| node_gfx
node_worldcore -->|"uses graphics settings"| node_gfx
node_themes -->|"creates theme"| node_car
node_themes -->|"creates theme"| node_boat
node_themes -->|"creates theme"| node_horse
node_themes -->|"creates theme"| node_rocket
node_car -->|"uses helpers"| node_themehelpers
node_boat -->|"uses helpers"| node_themehelpers
node_horse -->|"uses helpers"| node_themehelpers
node_rocket -->|"uses helpers"| node_themehelpers
node_daily -->|"requests race data"| node_api
node_daily -->|"selects language text"| node_languages
node_main -.->|"supports offline play"| node_serviceworker

click node_main "https://github.com/lakzayi/typeracer3d/blob/main/public/js/main.js"
click node_typing "https://github.com/lakzayi/typeracer3d/blob/main/public/js/typing.js"
click node_race "https://github.com/lakzayi/typeracer3d/blob/main/public/js/race.js"
click node_modes "https://github.com/lakzayi/typeracer3d/blob/main/public/js/modes.js"
click node_languages "https://github.com/lakzayi/typeracer3d/blob/main/public/js/languages.js"
click node_worldcore "https://github.com/lakzayi/typeracer3d/blob/main/public/js/world.js"
click node_gfx "https://github.com/lakzayi/typeracer3d/blob/main/public/js/gfx.js"
click node_themes "https://github.com/lakzayi/typeracer3d/blob/main/public/js/themes/index.js"
click node_car "https://github.com/lakzayi/typeracer3d/blob/main/public/js/themes/car.js"
click node_boat "https://github.com/lakzayi/typeracer3d/blob/main/public/js/themes/boat.js"
click node_horse "https://github.com/lakzayi/typeracer3d/blob/main/public/js/themes/horse.js"
click node_rocket "https://github.com/lakzayi/typeracer3d/blob/main/public/js/themes/rocket.js"
click node_themehelpers "https://github.com/lakzayi/typeracer3d/blob/main/public/js/themes/shared.js"
click node_hud "https://github.com/lakzayi/typeracer3d/blob/main/public/js/hud.js"
click node_sound "https://github.com/lakzayi/typeracer3d/blob/main/public/js/sound.js"
click node_api "https://github.com/lakzayi/typeracer3d/blob/main/public/js/api.js"
click node_demo "https://github.com/lakzayi/typeracer3d/blob/main/public/js/demo-data.js"
click node_server "https://github.com/lakzayi/typeracer3d/blob/main/server.js"
click node_net "https://github.com/lakzayi/typeracer3d/blob/main/public/js/net.js"
click node_daily "https://github.com/lakzayi/typeracer3d/blob/main/public/js/daily.js"
click node_drills "https://github.com/lakzayi/typeracer3d/blob/main/public/js/drills.js"
click node_stats "https://github.com/lakzayi/typeracer3d/blob/main/public/js/stats.js"
click node_achievements "https://github.com/lakzayi/typeracer3d/blob/main/public/js/achievements.js"
click node_share "https://github.com/lakzayi/typeracer3d/blob/main/public/js/share.js"
click node_serviceworker "https://github.com/lakzayi/typeracer3d/blob/main/public/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_main,node_hud toneBlue
class node_typing,node_race,node_modes,node_languages toneAmber
class node_worldcore,node_gfx,node_themes,node_car,node_boat,node_horse,node_rocket,node_themehelpers,node_sound toneMint
class node_api,node_demo,node_server toneRose
class node_net,node_daily,node_drills,node_stats,node_achievements,node_share,node_serviceworker,node_player,node_typeracer toneIndigo
```

## Components

### Game flow

- [Game coordinator](https://github.com/lakzayi/typeracer3d/blob/main/public/js/main.js): `public/js/main.js`
- [HUD and results](https://github.com/lakzayi/typeracer3d/blob/main/public/js/hud.js): `public/js/hud.js`

### Raceplay

- [Typing input](https://github.com/lakzayi/typeracer3d/blob/main/public/js/typing.js): `public/js/typing.js`
- [Race simulation](https://github.com/lakzayi/typeracer3d/blob/main/public/js/race.js): `public/js/race.js`
- [Race modes](https://github.com/lakzayi/typeracer3d/blob/main/public/js/modes.js): `public/js/modes.js`
- [Language pools](https://github.com/lakzayi/typeracer3d/blob/main/public/js/languages.js): `public/js/languages.js`

### 3D world

- [World renderer](https://github.com/lakzayi/typeracer3d/blob/main/public/js/world.js): `public/js/world.js`
- [Graphics quality](https://github.com/lakzayi/typeracer3d/blob/main/public/js/gfx.js): `public/js/gfx.js`
- [Theme registry](https://github.com/lakzayi/typeracer3d/blob/main/public/js/themes/index.js): `public/js/themes/index.js`
- [Street Race](https://github.com/lakzayi/typeracer3d/blob/main/public/js/themes/car.js): `public/js/themes/car.js`
- [River Rapids](https://github.com/lakzayi/typeracer3d/blob/main/public/js/themes/boat.js): `public/js/themes/boat.js`
- [Wild West Ride](https://github.com/lakzayi/typeracer3d/blob/main/public/js/themes/horse.js): `public/js/themes/horse.js`
- [Orbit Dash](https://github.com/lakzayi/typeracer3d/blob/main/public/js/themes/rocket.js): `public/js/themes/rocket.js`
- [Theme helpers](https://github.com/lakzayi/typeracer3d/blob/main/public/js/themes/shared.js): `public/js/themes/shared.js`
- [Race audio](https://github.com/lakzayi/typeracer3d/blob/main/public/js/sound.js): `public/js/sound.js`

### Race data

- [Race data API](https://github.com/lakzayi/typeracer3d/blob/main/public/js/api.js): `public/js/api.js`
- [Demo race data](https://github.com/lakzayi/typeracer3d/blob/main/public/js/demo-data.js): `public/js/demo-data.js`
- [Data proxy and cache](https://github.com/lakzayi/typeracer3d/blob/main/server.js): `server.js`

### Player features

- [Online lobby](https://github.com/lakzayi/typeracer3d/blob/main/public/js/net.js): `public/js/net.js`
- [Daily race](https://github.com/lakzayi/typeracer3d/blob/main/public/js/daily.js): `public/js/daily.js`
- [Typing drills](https://github.com/lakzayi/typeracer3d/blob/main/public/js/drills.js): `public/js/drills.js`
- [Local stats](https://github.com/lakzayi/typeracer3d/blob/main/public/js/stats.js): `public/js/stats.js`
- [Achievements](https://github.com/lakzayi/typeracer3d/blob/main/public/js/achievements.js): `public/js/achievements.js`
- [Share challenge](https://github.com/lakzayi/typeracer3d/blob/main/public/js/share.js): `public/js/share.js`
- [Offline support](https://github.com/lakzayi/typeracer3d/blob/main/public/sw.js): `public/sw.js`

### Other components

- **Player**
- **TypeRacer public data**

## Connections

- Player → Game coordinator: starts and types (evidence: `README.md`)
- Game coordinator → Race data API: requests race (evidence: `public/js/main.js`)
- Game coordinator → Daily race: selects daily (evidence: `public/js/main.js`)
- Game coordinator → Typing drills: creates drill (evidence: `public/js/main.js`)
- Game coordinator → Online lobby: joins lobby (evidence: `public/js/main.js`)
- Game coordinator → Typing input: coordinates input (evidence: `public/js/main.js`)
- Game coordinator → Race simulation: runs race (evidence: `public/js/main.js`)
- Game coordinator → World renderer: updates world (evidence: `public/js/main.js`)
- Game coordinator → Theme registry: selects theme (evidence: `public/js/main.js`)
- Game coordinator → HUD and results: updates display (evidence: `public/js/main.js`)
- Game coordinator → Race audio: controls audio (evidence: `public/js/main.js`)
- Game coordinator → Local stats: updates stats (evidence: `public/js/main.js`)
- Game coordinator → Achievements: checks awards (evidence: `public/js/main.js`)
- Game coordinator → Share challenge: shares result (evidence: `public/js/main.js`)
- Race data API → Demo race data: falls back to (evidence: `public/js/api.js`)
- Race data API → Data proxy and cache: requests race data (evidence: `README.md`)
- Data proxy and cache → TypeRacer public data: reads public races (evidence: `README.md`)
- Game coordinator → Language pools: uses language (evidence: `README.md`)
- Race simulation → Race modes: uses mode rules (evidence: `public/js/race.js`)
- Game coordinator → Graphics quality: adjusts quality (evidence: `public/js/main.js`)
- World renderer → Graphics quality: uses graphics settings (evidence: `public/js/world.js`)
- Theme registry → Street Race: creates theme (evidence: `public/js/themes/index.js`)
- Theme registry → River Rapids: creates theme (evidence: `public/js/themes/index.js`)
- Theme registry → Wild West Ride: creates theme (evidence: `public/js/themes/index.js`)
- Theme registry → Orbit Dash: creates theme (evidence: `public/js/themes/index.js`)
- Street Race → Theme helpers: uses helpers (evidence: `public/js/themes/car.js`)
- River Rapids → Theme helpers: uses helpers (evidence: `public/js/themes/boat.js`)
- Wild West Ride → Theme helpers: uses helpers (evidence: `public/js/themes/horse.js`)
- Orbit Dash → Theme helpers: uses helpers (evidence: `public/js/themes/rocket.js`)
- Daily race → Race data API: requests race data (evidence: `public/js/daily.js`)
- Daily race → Language pools: selects language text (evidence: `public/js/daily.js`)
- Game coordinator → Offline support: supports offline play (evidence: `README.md`)
