# stewie1570/sailing architecture

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

- Interactive diagram: https://gitdiagram.com/stewie1570/sailing
- Repository: https://github.com/stewie1570/sailing

## Overview

Lake Windermere is a browser-based 3D sailing and docking simulator with solo play, multiplayer rooms, navigation/AIS features, and sailing theory. The player enters through the menu, starts or joins a session, then steers and trims a locally simulated boat through the rendered lake; multiplayer sessions relay room, wind, and boat updates. The map generator prepares chart-derived runtime assets. Edges reflect shown imports/calls or README descriptions; several unsampled UI, rendering, and server details are therefore represented only at subsystem level.

Main entry points: [`client/src/scene/Scene.tsx`](https://github.com/stewie1570/sailing/blob/main/client/src/scene/Scene.tsx) (Scene composer), [`client/src/App.tsx`](https://github.com/stewie1570/sailing/blob/main/client/src/App.tsx) (App flow), [`client/src/net/session.ts`](https://github.com/stewie1570/sailing/blob/main/client/src/net/session.ts) (Session manager), [`client/src/map/mapData.ts`](https://github.com/stewie1570/sailing/blob/main/client/src/map/mapData.ts) (Map loader)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["Player experience"]
  node_app["App flow<br/>[App.tsx]"]
  node_menu["Menu<br/>[Menu.tsx]"]
  node_hud["HUD<br/>[Hud.tsx]"]
  node_controls["Sailing controls"]
  node_controller["Controller setup"]
  node_navmap["Navigation map<br/>[NavMap.tsx]"]
  node_theory["Sailing theory<br/>[Theory.tsx]"]
end

subgraph group_simulation["Sailing simulation"]
  node_boat["Local boat<br/>[Boat.tsx]"]
  node_remote["Remote boats<br/>[RemoteBoat.tsx]"]
  node_physics["Boat physics<br/>[physics.ts]"]
  node_dynamics["Motion dynamics<br/>[dynamics.ts]"]
  node_sails["Sail forces<br/>[sail.ts]"]
  node_helm["Helm state<br/>[helm.ts]"]
end

subgraph group_world["Lake world"]
  node_scene["Scene composer<br/>[Scene.tsx]"]
  node_environment["Lake environment<br/>[environment.ts]"]
  node_mapdata["Map loader<br/>[mapData.ts]"]
  node_terrain["Terrain renderer<br/>[Terrain.tsx]"]
  node_water["Water renderer<br/>[Water.tsx]"]
  node_harbors["Harbors and buoys<br/>[Harbors.tsx]"]
end

subgraph group_multiplayer["Multiplayer"]
  node_session["Session manager<br/>[session.ts]"]
  node_protocol["Room protocol<br/>[protocol.ts]"]
  node_ais["AIS messages<br/>[aisMail.ts]"]
  node_hub["Game relay<br/>[GameHub.cs]"]
  node_server["Server host<br/>[Program.cs]"]
end

subgraph group_assets["Map assets"]
  node_mapgen["Chart map generator<br/>[mapgen.mjs]"]
  node_worldinfo["World endpoint<br/>[WorldInfo.cs]"]
end

node_sailor(("Sailor"))

node_sailor -->|"opens"| node_app
node_app -->|"uses session"| node_session
node_app -->|"shows sailing"| node_scene
node_app -->|"shows HUD"| node_hud
node_app -->|"shows menu"| node_menu
node_app -->|"opens lessons"| node_theory
node_sailor -.->|"chooses session"| node_menu
node_hud -.->|"presents controls"| node_controls
node_hud -->|"presents map"| node_navmap
node_hud -->|"reads session"| node_session
node_controls -->|"updates helm"| node_helm
node_controller -->|"configures helm"| node_helm
node_navmap -->|"reads ships"| node_session
node_navmap -->|"opens messages"| node_ais
node_session -->|"uses messages"| node_protocol
node_session -->|"relays room traffic"| node_hub
node_server -->|"hosts hub"| node_hub
node_server -->|"serves world data"| node_worldinfo
node_scene -->|"loads map"| node_mapdata
node_scene -->|"renders boat"| node_boat
node_scene -->|"renders fleet"| node_remote
node_scene -->|"renders terrain"| node_terrain
node_scene -->|"renders water"| node_water
node_scene -->|"renders harbors"| node_harbors
node_boat -->|"steps motion"| node_physics
node_boat -->|"computes sail state"| node_sails
node_boat -->|"reads controls"| node_helm
node_physics -->|"steps dynamics"| node_dynamics
node_scene -->|"uses environment"| node_environment
node_terrain -->|"reads map"| node_mapdata
node_water -->|"reads map"| node_mapdata
node_harbors -->|"reads map"| node_mapdata
node_mapgen -->|"generates runtime assets"| node_mapdata

click node_app "https://github.com/stewie1570/sailing/blob/main/client/src/App.tsx"
click node_menu "https://github.com/stewie1570/sailing/blob/main/client/src/ui/Menu.tsx"
click node_hud "https://github.com/stewie1570/sailing/blob/main/client/src/ui/Hud.tsx"
click node_controls "https://github.com/stewie1570/sailing/blob/main/client/src/ui/SailingControls.tsx"
click node_controller "https://github.com/stewie1570/sailing/blob/main/client/src/ui/ControllerSetup.tsx"
click node_navmap "https://github.com/stewie1570/sailing/blob/main/client/src/ui/NavMap.tsx"
click node_theory "https://github.com/stewie1570/sailing/blob/main/client/src/ui/theory/Theory.tsx"
click node_session "https://github.com/stewie1570/sailing/blob/main/client/src/net/session.ts"
click node_protocol "https://github.com/stewie1570/sailing/blob/main/client/src/net/protocol.ts"
click node_ais "https://github.com/stewie1570/sailing/blob/main/client/src/net/aisMail.ts"
click node_hub "https://github.com/stewie1570/sailing/blob/main/server/Sailing.Server/Hubs/GameHub.cs"
click node_server "https://github.com/stewie1570/sailing/blob/main/server/Sailing.Server/Program.cs"
click node_boat "https://github.com/stewie1570/sailing/blob/main/client/src/scene/boat/Boat.tsx"
click node_remote "https://github.com/stewie1570/sailing/blob/main/client/src/scene/boat/RemoteBoat.tsx"
click node_physics "https://github.com/stewie1570/sailing/blob/main/client/src/scene/boat/physics.ts"
click node_dynamics "https://github.com/stewie1570/sailing/blob/main/client/src/scene/boat/dynamics.ts"
click node_sails "https://github.com/stewie1570/sailing/blob/main/client/src/scene/boat/sail.ts"
click node_helm "https://github.com/stewie1570/sailing/blob/main/client/src/scene/boat/helm.ts"
click node_scene "https://github.com/stewie1570/sailing/blob/main/client/src/scene/Scene.tsx"
click node_environment "https://github.com/stewie1570/sailing/blob/main/client/src/scene/environment.ts"
click node_mapdata "https://github.com/stewie1570/sailing/blob/main/client/src/map/mapData.ts"
click node_terrain "https://github.com/stewie1570/sailing/blob/main/client/src/scene/Terrain.tsx"
click node_water "https://github.com/stewie1570/sailing/blob/main/client/src/scene/Water.tsx"
click node_harbors "https://github.com/stewie1570/sailing/blob/main/client/src/scene/Harbors.tsx"
click node_mapgen "https://github.com/stewie1570/sailing/blob/main/tools/mapgen/mapgen.mjs"
click node_worldinfo "https://github.com/stewie1570/sailing/blob/main/server/Sailing.Server/World/WorldInfo.cs"

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_app,node_menu,node_hud,node_controls,node_controller,node_navmap,node_theory toneBlue
class node_boat,node_remote,node_physics,node_dynamics,node_sails,node_helm toneAmber
class node_scene,node_environment,node_mapdata,node_terrain,node_water,node_harbors toneMint
class node_session,node_protocol,node_ais,node_hub,node_server toneRose
class node_mapgen,node_worldinfo,node_sailor toneIndigo
```

## Components

### Player experience

- [App flow](https://github.com/stewie1570/sailing/blob/main/client/src/App.tsx): `client/src/App.tsx`
- [Menu](https://github.com/stewie1570/sailing/blob/main/client/src/ui/Menu.tsx): `client/src/ui/Menu.tsx`
- [HUD](https://github.com/stewie1570/sailing/blob/main/client/src/ui/Hud.tsx): `client/src/ui/Hud.tsx`
- [Sailing controls](https://github.com/stewie1570/sailing/blob/main/client/src/ui/SailingControls.tsx): `client/src/ui/SailingControls.tsx`
- [Controller setup](https://github.com/stewie1570/sailing/blob/main/client/src/ui/ControllerSetup.tsx): `client/src/ui/ControllerSetup.tsx`
- [Navigation map](https://github.com/stewie1570/sailing/blob/main/client/src/ui/NavMap.tsx): `client/src/ui/NavMap.tsx`
- [Sailing theory](https://github.com/stewie1570/sailing/blob/main/client/src/ui/theory/Theory.tsx): `client/src/ui/theory/Theory.tsx`

### Sailing simulation

- [Local boat](https://github.com/stewie1570/sailing/blob/main/client/src/scene/boat/Boat.tsx): `client/src/scene/boat/Boat.tsx`
- [Remote boats](https://github.com/stewie1570/sailing/blob/main/client/src/scene/boat/RemoteBoat.tsx): `client/src/scene/boat/RemoteBoat.tsx`
- [Boat physics](https://github.com/stewie1570/sailing/blob/main/client/src/scene/boat/physics.ts): `client/src/scene/boat/physics.ts`
- [Motion dynamics](https://github.com/stewie1570/sailing/blob/main/client/src/scene/boat/dynamics.ts): `client/src/scene/boat/dynamics.ts`
- [Sail forces](https://github.com/stewie1570/sailing/blob/main/client/src/scene/boat/sail.ts): `client/src/scene/boat/sail.ts`
- [Helm state](https://github.com/stewie1570/sailing/blob/main/client/src/scene/boat/helm.ts): `client/src/scene/boat/helm.ts`

### Lake world

- [Scene composer](https://github.com/stewie1570/sailing/blob/main/client/src/scene/Scene.tsx): `client/src/scene/Scene.tsx`
- [Lake environment](https://github.com/stewie1570/sailing/blob/main/client/src/scene/environment.ts): `client/src/scene/environment.ts`
- [Map loader](https://github.com/stewie1570/sailing/blob/main/client/src/map/mapData.ts): `client/src/map/mapData.ts`
- [Terrain renderer](https://github.com/stewie1570/sailing/blob/main/client/src/scene/Terrain.tsx): `client/src/scene/Terrain.tsx`
- [Water renderer](https://github.com/stewie1570/sailing/blob/main/client/src/scene/Water.tsx): `client/src/scene/Water.tsx`
- [Harbors and buoys](https://github.com/stewie1570/sailing/blob/main/client/src/scene/Harbors.tsx): `client/src/scene/Harbors.tsx`

### Multiplayer

- [Session manager](https://github.com/stewie1570/sailing/blob/main/client/src/net/session.ts): `client/src/net/session.ts`
- [Room protocol](https://github.com/stewie1570/sailing/blob/main/client/src/net/protocol.ts): `client/src/net/protocol.ts`
- [AIS messages](https://github.com/stewie1570/sailing/blob/main/client/src/net/aisMail.ts): `client/src/net/aisMail.ts`
- [Game relay](https://github.com/stewie1570/sailing/blob/main/server/Sailing.Server/Hubs/GameHub.cs): `server/Sailing.Server/Hubs/GameHub.cs`
- [Server host](https://github.com/stewie1570/sailing/blob/main/server/Sailing.Server/Program.cs): `server/Sailing.Server/Program.cs`

### Map assets

- [Chart map generator](https://github.com/stewie1570/sailing/blob/main/tools/mapgen/mapgen.mjs): `tools/mapgen/mapgen.mjs`
- [World endpoint](https://github.com/stewie1570/sailing/blob/main/server/Sailing.Server/World/WorldInfo.cs): `server/Sailing.Server/World/WorldInfo.cs`

### Other components

- **Sailor**

## Connections

- Sailor → App flow: opens (evidence: `client/src/App.tsx`)
- App flow → Session manager: uses session (evidence: `client/src/App.tsx`)
- App flow → Scene composer: shows sailing (evidence: `client/src/App.tsx`)
- App flow → HUD: shows HUD (evidence: `client/src/App.tsx`)
- App flow → Menu: shows menu (evidence: `client/src/App.tsx`)
- App flow → Sailing theory: opens lessons (evidence: `client/src/App.tsx`)
- Sailor → Menu: chooses session (evidence: `README.md`)
- HUD → Sailing controls: presents controls (evidence: `client/src/ui/Hud.tsx`)
- HUD → Navigation map: presents map (evidence: `client/src/ui/Hud.tsx`)
- HUD → Session manager: reads session (evidence: `client/src/ui/Hud.tsx`)
- Sailing controls → Helm state: updates helm (evidence: `client/src/ui/SailingControls.tsx`)
- Controller setup → Helm state: configures helm (evidence: `client/src/ui/ControllerSetup.tsx`)
- Navigation map → Session manager: reads ships (evidence: `client/src/ui/NavMap.tsx`)
- Navigation map → AIS messages: opens messages (evidence: `client/src/ui/NavMap.tsx`)
- Session manager → Room protocol: uses messages (evidence: `client/src/net/session.ts`)
- Session manager → Game relay: relays room traffic (evidence: `README.md`)
- Server host → Game relay: hosts hub (evidence: `server/Sailing.Server/Program.cs`)
- Server host → World endpoint: serves world data (evidence: `server/Sailing.Server/Program.cs`)
- Scene composer → Map loader: loads map (evidence: `client/src/scene/Scene.tsx`)
- Scene composer → Local boat: renders boat (evidence: `client/src/scene/Scene.tsx`)
- Scene composer → Remote boats: renders fleet (evidence: `client/src/scene/Scene.tsx`)
- Scene composer → Terrain renderer: renders terrain (evidence: `client/src/scene/Scene.tsx`)
- Scene composer → Water renderer: renders water (evidence: `client/src/scene/Scene.tsx`)
- Scene composer → Harbors and buoys: renders harbors (evidence: `client/src/scene/Scene.tsx`)
- Local boat → Boat physics: steps motion (evidence: `client/src/scene/boat/Boat.tsx`)
- Local boat → Sail forces: computes sail state (evidence: `client/src/scene/boat/Boat.tsx`)
- Local boat → Helm state: reads controls (evidence: `client/src/scene/boat/Boat.tsx`)
- Boat physics → Motion dynamics: steps dynamics (evidence: `client/src/scene/boat/physics.ts`)
- Scene composer → Lake environment: uses environment (evidence: `client/src/scene/Scene.tsx`)
- Terrain renderer → Map loader: reads map (evidence: `client/src/scene/Terrain.tsx`)
- Water renderer → Map loader: reads map (evidence: `client/src/scene/Water.tsx`)
- Harbors and buoys → Map loader: reads map (evidence: `client/src/scene/Harbors.tsx`)
- Chart map generator → Map loader: generates runtime assets (evidence: `README.md`)
