# kbl13350/kartsim architecture

> Architecture diagram of the GitHub repository kbl13350/kartsim, 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/kbl13350/kartsim
- Repository: https://github.com/kbl13350/kartsim

## Overview

KartSim is a browser kart-racing game with a TypeScript client and Go backend; the README also identifies original game resources and a separate admin console. The principal player flow is choosing a mode and kart, loading resources, racing with driving physics and (for multiplayer) networked participants, then viewing results and rewards. The graph preserves the documented account, economy, social, and mode-specific features. Most cross-module wiring is documented at product level; edges based on unsampled subsystems cite the README rather than implying source-level calls.

Main entry points: [`client/src/main.ts`](https://github.com/kbl13350/kartsim/blob/main/client/src/main.ts) (Game client), [`client/src/timeattack/ready-controller.ts`](https://github.com/kbl13350/kartsim/blob/main/client/src/timeattack/ready-controller.ts) (Mode and garage setup), [`client/src/driving/frame-pipeline.ts`](https://github.com/kbl13350/kartsim/blob/main/client/src/driving/frame-pipeline.ts) (Driving physics), [`server-go/internal/data/server/server.go`](https://github.com/kbl13350/kartsim/blob/main/server-go/internal/data/server/server.go) (Data service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Browser game"]
  node_clientapp["Game client<br/>[main.ts]"]
  node_ready["Mode and garage setup"]
  node_resourcesvc["Resource loading"]
  node_physics["Driving physics<br/>[frame-pipeline.ts]"]
  node_itemrace["Item race rules"]
  node_racehud["Race presentation"]
  node_timeattack["Time attack and ghosts<br/>[ghost-runtime.ts]"]
  node_results["Race results and rewards<br/>[race-results.ts]"]
  node_account["Accounts and profile<br/>[account-runtime.ts]"]
  node_garage["Garage and inventory"]
  node_shop["Shop and economy UI<br/>[shop-view.ts]"]
  node_social["Social features<br/>[club-screen.ts]"]
  node_lobby["Multiplayer lobby"]
  node_networkrace["Networked race<br/>[race-session.ts]"]
  node_othermodes["Missions and game modes<br/>[license-mission.ts]"]
  node_clientapi["Client service APIs<br/>[api.ts]"]
end

subgraph group_backend["Go backend"]
  node_dataapi["Data service<br/>[server.go]"]
  node_economy["Accounts and economy<br/>[economy.go]"]
  node_datastore[("Persistent data<br/>[storage.go]")]
  node_gamenode["Game node<br/>[app.go]"]
  node_lobbyservice["Rooms and races<br/>[lobby.go]"]
end

subgraph group_admin["Admin console"]
  node_adminui["Admin console<br/>[App.vue]"]
  node_adminapi["Admin API client<br/>[client.ts]"]
end

subgraph group_resources["Game resources"]
  node_originalresources["Original game resources"]
end

node_player(("Player"))

node_player -->|"plays"| node_clientapp
node_clientapp -->|"selects mode"| node_ready
node_ready -.->|"loads assets"| node_resourcesvc
node_resourcesvc -->|"reads resources"| node_originalresources
node_ready -.->|"starts race"| node_physics
node_physics -.->|"advances item effects"| node_itemrace
node_physics -.->|"updates presentation"| node_racehud
node_itemrace -->|"feeds item HUD"| node_racehud
node_ready -->|"opens multiplayer"| node_lobby
node_lobby -.->|"loads race"| node_networkrace
node_networkrace -->|"exchanges race data"| node_gamenode
node_gamenode -->|"runs rooms"| node_lobbyservice
node_clientapp -.->|"requests services"| node_clientapi
node_clientapi -->|"calls backend"| node_dataapi
node_dataapi -->|"serves economy"| node_economy
node_dataapi -->|"persists data"| node_datastore
node_clientapp -->|"runs time attack"| node_timeattack
node_timeattack -.->|"records results"| node_results
node_physics -.->|"finishes race"| node_results
node_clientapp -->|"supports login"| node_account
node_clientapp -->|"opens garage"| node_garage
node_clientapp -->|"opens shop"| node_shop
node_clientapp -->|"supports social play"| node_social
node_clientapp -->|"offers missions"| node_othermodes
node_player -->|"administers"| node_adminui
node_adminui -->|"requests admin data"| node_adminapi
node_adminapi -.->|"calls admin API"| node_dataapi

click node_clientapp "https://github.com/kbl13350/kartsim/blob/main/client/src/main.ts"
click node_ready "https://github.com/kbl13350/kartsim/blob/main/client/src/timeattack/ready-controller.ts"
click node_resourcesvc "https://github.com/kbl13350/kartsim/blob/main/client/src/resources/resource-manager.ts"
click node_physics "https://github.com/kbl13350/kartsim/blob/main/client/src/driving/frame-pipeline.ts"
click node_itemrace "https://github.com/kbl13350/kartsim/blob/main/client/src/item/item-race-controller.ts"
click node_racehud "https://github.com/kbl13350/kartsim/blob/main/client/src/ui/race-hud-controller.ts"
click node_timeattack "https://github.com/kbl13350/kartsim/blob/main/client/src/timeattack/ghost-runtime.ts"
click node_results "https://github.com/kbl13350/kartsim/blob/main/client/src/game/race-results.ts"
click node_account "https://github.com/kbl13350/kartsim/blob/main/client/src/account/account-runtime.ts"
click node_garage "https://github.com/kbl13350/kartsim/blob/main/client/src/ui/garage-view-construction.ts"
click node_shop "https://github.com/kbl13350/kartsim/blob/main/client/src/shop/shop-view.ts"
click node_social "https://github.com/kbl13350/kartsim/blob/main/client/src/club/club-screen.ts"
click node_lobby "https://github.com/kbl13350/kartsim/blob/main/client/src/multiplayer/lobby-controller.ts"
click node_networkrace "https://github.com/kbl13350/kartsim/blob/main/client/src/multiplayer/race-session.ts"
click node_othermodes "https://github.com/kbl13350/kartsim/blob/main/client/src/license/license-mission.ts"
click node_clientapi "https://github.com/kbl13350/kartsim/blob/main/client/src/game/api.ts"
click node_dataapi "https://github.com/kbl13350/kartsim/blob/main/server-go/internal/data/server/server.go"
click node_economy "https://github.com/kbl13350/kartsim/blob/main/server-go/internal/data/economy/economy.go"
click node_datastore "https://github.com/kbl13350/kartsim/blob/main/server-go/internal/data/store/storage.go"
click node_gamenode "https://github.com/kbl13350/kartsim/blob/main/server-go/internal/game/app/app.go"
click node_lobbyservice "https://github.com/kbl13350/kartsim/blob/main/server-go/internal/game/lobby/lobby.go"
click node_adminui "https://github.com/kbl13350/kartsim/blob/main/server-go/admin-ui/src/App.vue"
click node_adminapi "https://github.com/kbl13350/kartsim/blob/main/server-go/admin-ui/src/api/client.ts"
click node_originalresources "https://github.com/kbl13350/kartsim/tree/main/mirror"

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_clientapp,node_ready,node_resourcesvc,node_physics,node_itemrace,node_racehud,node_timeattack,node_results,node_account,node_garage,node_shop,node_social,node_lobby,node_networkrace,node_othermodes,node_clientapi toneBlue
class node_dataapi,node_economy,node_datastore,node_gamenode,node_lobbyservice toneAmber
class node_adminui,node_adminapi toneMint
class node_originalresources toneRose
class node_player toneIndigo
```

## Components

### Browser game

- [Game client](https://github.com/kbl13350/kartsim/blob/main/client/src/main.ts): `client/src/main.ts`
- [Mode and garage setup](https://github.com/kbl13350/kartsim/blob/main/client/src/timeattack/ready-controller.ts): `client/src/timeattack/ready-controller.ts`
- [Resource loading](https://github.com/kbl13350/kartsim/blob/main/client/src/resources/resource-manager.ts): `client/src/resources/resource-manager.ts`
- [Driving physics](https://github.com/kbl13350/kartsim/blob/main/client/src/driving/frame-pipeline.ts): `client/src/driving/frame-pipeline.ts`
- [Item race rules](https://github.com/kbl13350/kartsim/blob/main/client/src/item/item-race-controller.ts): `client/src/item/item-race-controller.ts`
- [Race presentation](https://github.com/kbl13350/kartsim/blob/main/client/src/ui/race-hud-controller.ts): `client/src/ui/race-hud-controller.ts`
- [Time attack and ghosts](https://github.com/kbl13350/kartsim/blob/main/client/src/timeattack/ghost-runtime.ts): `client/src/timeattack/ghost-runtime.ts`
- [Race results and rewards](https://github.com/kbl13350/kartsim/blob/main/client/src/game/race-results.ts): `client/src/game/race-results.ts`
- [Accounts and profile](https://github.com/kbl13350/kartsim/blob/main/client/src/account/account-runtime.ts): `client/src/account/account-runtime.ts`
- [Garage and inventory](https://github.com/kbl13350/kartsim/blob/main/client/src/ui/garage-view-construction.ts): `client/src/ui/garage-view-construction.ts`
- [Shop and economy UI](https://github.com/kbl13350/kartsim/blob/main/client/src/shop/shop-view.ts): `client/src/shop/shop-view.ts`
- [Social features](https://github.com/kbl13350/kartsim/blob/main/client/src/club/club-screen.ts): `client/src/club/club-screen.ts`
- [Multiplayer lobby](https://github.com/kbl13350/kartsim/blob/main/client/src/multiplayer/lobby-controller.ts): `client/src/multiplayer/lobby-controller.ts`
- [Networked race](https://github.com/kbl13350/kartsim/blob/main/client/src/multiplayer/race-session.ts): `client/src/multiplayer/race-session.ts`
- [Missions and game modes](https://github.com/kbl13350/kartsim/blob/main/client/src/license/license-mission.ts): `client/src/license/license-mission.ts`
- [Client service APIs](https://github.com/kbl13350/kartsim/blob/main/client/src/game/api.ts): `client/src/game/api.ts`

### Go backend

- [Data service](https://github.com/kbl13350/kartsim/blob/main/server-go/internal/data/server/server.go): `server-go/internal/data/server/server.go`
- [Accounts and economy](https://github.com/kbl13350/kartsim/blob/main/server-go/internal/data/economy/economy.go): `server-go/internal/data/economy/economy.go`
- [Persistent data](https://github.com/kbl13350/kartsim/blob/main/server-go/internal/data/store/storage.go): `server-go/internal/data/store/storage.go`
- [Game node](https://github.com/kbl13350/kartsim/blob/main/server-go/internal/game/app/app.go): `server-go/internal/game/app/app.go`
- [Rooms and races](https://github.com/kbl13350/kartsim/blob/main/server-go/internal/game/lobby/lobby.go): `server-go/internal/game/lobby/lobby.go`

### Admin console

- [Admin console](https://github.com/kbl13350/kartsim/blob/main/server-go/admin-ui/src/App.vue): `server-go/admin-ui/src/App.vue`
- [Admin API client](https://github.com/kbl13350/kartsim/blob/main/server-go/admin-ui/src/api/client.ts): `server-go/admin-ui/src/api/client.ts`

### Game resources

- [Original game resources](https://github.com/kbl13350/kartsim/tree/main/mirror): `mirror`

### Other components

- **Player**

## Connections

- Player → Game client: plays (evidence: `README.md`)
- Game client → Mode and garage setup: selects mode (evidence: `README.md`)
- Mode and garage setup → Resource loading: loads assets
- Resource loading → Original game resources: reads resources (evidence: `README.md`)
- Mode and garage setup → Driving physics: starts race
- Driving physics → Item race rules: advances item effects
- Driving physics → Race presentation: updates presentation
- Item race rules → Race presentation: feeds item HUD
- Mode and garage setup → Multiplayer lobby: opens multiplayer (evidence: `client/src/timeattack/ready-controller.ts`)
- Multiplayer lobby → Networked race: loads race
- Networked race → Game node: exchanges race data (evidence: `README.md`)
- Game node → Rooms and races: runs rooms (evidence: `README.md`)
- Game client → Client service APIs: requests services
- Client service APIs → Data service: calls backend (evidence: `README.md`)
- Data service → Accounts and economy: serves economy (evidence: `README.md`)
- Data service → Persistent data: persists data (evidence: `README.md`)
- Game client → Time attack and ghosts: runs time attack (evidence: `README.md`)
- Time attack and ghosts → Race results and rewards: records results
- Driving physics → Race results and rewards: finishes race
- Game client → Accounts and profile: supports login (evidence: `README.md`)
- Game client → Garage and inventory: opens garage (evidence: `README.md`)
- Game client → Shop and economy UI: opens shop (evidence: `README.md`)
- Game client → Social features: supports social play (evidence: `README.md`)
- Game client → Missions and game modes: offers missions (evidence: `README.md`)
- Player → Admin console: administers (evidence: `README.md`)
- Admin console → Admin API client: requests admin data (evidence: `server-go/admin-ui/src/App.vue`)
- Admin API client → Data service: calls admin API
