# projectasakura/bayshore architecture

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

- Interactive diagram: https://gitdiagram.com/projectasakura/bayshore
- Repository: https://github.com/projectasakura/bayshore

## Overview

Bayshore reimplements the Wangan Midnight Maximum Tune 6 server. A game client’s protobuf requests enter the service listener, are dispatched to domain modules, which implement user/card, terminal, race and ghost/OCM behavior and persist game state. ALL.Net startup and Mucha board/update emulation are separate protocol-facing services. The README identifies the product but does not enumerate capabilities; the source index and excerpts support the principal branches shown. Several modules are unsampled, so their internal call relationships are omitted.

Main entry points: [`src/modules/game.ts`](https://github.com/projectasakura/bayshore/blob/master/src/modules/game.ts) (Game dispatch), [`src/index.ts`](https://github.com/projectasakura/bayshore/blob/master/src/index.ts) (HTTP service), [`src/modules/game/ghost.ts`](https://github.com/projectasakura/bayshore/blob/master/src/modules/game/ghost.ts) (Ghost gameplay), [`src/modules/terminal.ts`](https://github.com/projectasakura/bayshore/blob/master/src/modules/terminal.ts) (Terminal services)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Protocol entry"]
  node_server["HTTP service<br/>[index.ts]"]
  node_allnet["ALL.Net startup<br/>[allnet.ts]"]
  node_mucha["Mucha board/update<br/>[mucha.ts]"]
end

subgraph group_player["Player services"]
  node_users["User accounts<br/>[users.ts]"]
  node_cars["Car management<br/>[functions.ts]"]
  node_car_tune["Car tuning<br/>[car_tune.ts]"]
  node_terminal["Terminal services<br/>[terminal.ts]"]
  node_scratch["Scratch rewards<br/>[scratch.ts]"]
  node_startup["Game startup<br/>[functions.ts]"]
  node_meter["Meter rewards<br/>[meter_reward.ts]"]
end

subgraph group_racing["Racing features"]
  node_game["Game dispatch<br/>[game.ts]"]
  node_game_functions["Game operations<br/>[functions.ts]"]
  node_story["Story mode<br/>[story.ts]"]
  node_time_attack["Time attack<br/>[time_attack.ts]"]
  node_versus["Versus mode<br/>[versus.ts]"]
  node_ranking["Rankings<br/>[ranking.ts]"]
  node_crown["Crown list<br/>[crown_list.ts]"]
end

subgraph group_ghost["Ghost features"]
  node_ghost_game["Ghost gameplay<br/>[ghost.ts]"]
  node_ghost_service["Ghost services<br/>[ghost.ts]"]
  node_ghost_ops["Ghost operations<br/>[functions.ts]"]
  node_history["Ghost history<br/>[ghost_history.ts]"]
  node_ocm["OCM competition<br/>[ghost_ocm.ts]"]
  node_ghost_area["Area selection<br/>[ghost_area.ts]"]
  node_path_area["Path area lookup"]
  node_ocm_area["OCM area lookup<br/>[ghost_ocm_area.ts]"]
  node_trail["Ghost trail<br/>[ghost_trail.ts]"]
end

subgraph group_shared["Shared runtime"]
  node_config["Runtime config<br/>[config.ts]"]
  node_proto["Protocol definitions<br/>[wm.proto.js]"]
  node_service_proto["Service protocol<br/>[service.proto.js]"]
  node_common["Response utilities<br/>[common.ts]"]
  node_db[("Game database")]
end

node_client(("Game client"))

node_client -->|"sends requests"| node_server
node_server -->|"registers protocol"| node_allnet
node_server -->|"registers protocol"| node_mucha
node_server -->|"loads settings"| node_config
node_server -->|"initializes client"| node_db
node_allnet -->|"reads settings"| node_config
node_allnet -->|"sanitizes inputs"| node_common
node_mucha -->|"reads settings"| node_config
node_game -->|"calls operations"| node_game_functions
node_game -->|"dispatches mode"| node_story
node_game -->|"dispatches mode"| node_time_attack
node_game -->|"dispatches mode"| node_ghost_game
node_game -->|"dispatches mode"| node_versus
node_ghost_game -->|"saves results"| node_history
node_history -->|"resolves area"| node_path_area
node_ghost_service -->|"calls operations"| node_ghost_ops
node_ghost_service -->|"uses trail utility"| node_trail
node_trail -->|"resolves competition area"| node_ocm_area
node_trail -->|"resolves ghost area"| node_ghost_area
node_terminal -->|"uses scratch sheets"| node_scratch
node_terminal -->|"reads and writes"| node_db
node_ghost_game -->|"updates race state"| node_db
node_history -->|"records battles"| node_db
node_ocm -->|"tallies competition"| node_db
node_scratch -->|"stores reward sheets"| node_db
node_terminal -->|"decodes requests"| node_proto
node_ghost_game -->|"uses messages"| node_proto
node_ghost_service -->|"uses service messages"| node_service_proto
node_ranking -->|"uses service messages"| node_service_proto
node_crown -->|"uses service messages"| node_service_proto

click node_server "https://github.com/projectasakura/bayshore/blob/master/src/index.ts"
click node_allnet "https://github.com/projectasakura/bayshore/blob/master/src/allnet.ts"
click node_mucha "https://github.com/projectasakura/bayshore/blob/master/src/mucha.ts"
click node_config "https://github.com/projectasakura/bayshore/blob/master/src/config.ts"
click node_users "https://github.com/projectasakura/bayshore/blob/master/src/modules/users.ts"
click node_cars "https://github.com/projectasakura/bayshore/blob/master/src/modules/cars/functions.ts"
click node_car_tune "https://github.com/projectasakura/bayshore/blob/master/src/modules/cars/car_tune.ts"
click node_terminal "https://github.com/projectasakura/bayshore/blob/master/src/modules/terminal.ts"
click node_scratch "https://github.com/projectasakura/bayshore/blob/master/src/modules/terminal/scratch.ts"
click node_game "https://github.com/projectasakura/bayshore/blob/master/src/modules/game.ts"
click node_game_functions "https://github.com/projectasakura/bayshore/blob/master/src/modules/game/functions.ts"
click node_story "https://github.com/projectasakura/bayshore/blob/master/src/modules/game/story.ts"
click node_time_attack "https://github.com/projectasakura/bayshore/blob/master/src/modules/game/time_attack.ts"
click node_versus "https://github.com/projectasakura/bayshore/blob/master/src/modules/game/versus.ts"
click node_ghost_game "https://github.com/projectasakura/bayshore/blob/master/src/modules/game/ghost.ts"
click node_ghost_service "https://github.com/projectasakura/bayshore/blob/master/src/modules/ghost.ts"
click node_ghost_ops "https://github.com/projectasakura/bayshore/blob/master/src/modules/ghost/functions.ts"
click node_history "https://github.com/projectasakura/bayshore/blob/master/src/modules/ghost/ghost_history.ts"
click node_ocm "https://github.com/projectasakura/bayshore/blob/master/src/modules/ghost/ghost_ocm.ts"
click node_ghost_area "https://github.com/projectasakura/bayshore/blob/master/src/modules/ghost/ghost_util/ghost_area.ts"
click node_path_area "https://github.com/projectasakura/bayshore/blob/master/src/modules/ghost/ghost_util/ghost_get_area_from_path.ts"
click node_ocm_area "https://github.com/projectasakura/bayshore/blob/master/src/modules/ghost/ghost_util/ghost_ocm_area.ts"
click node_trail "https://github.com/projectasakura/bayshore/blob/master/src/modules/ghost/ghost_util/ghost_trail.ts"
click node_ranking "https://github.com/projectasakura/bayshore/blob/master/src/modules/resource/ranking.ts"
click node_crown "https://github.com/projectasakura/bayshore/blob/master/src/modules/resource/crown_list.ts"
click node_startup "https://github.com/projectasakura/bayshore/blob/master/src/modules/startup/functions.ts"
click node_meter "https://github.com/projectasakura/bayshore/blob/master/src/modules/util/meter_reward.ts"
click node_proto "https://github.com/projectasakura/bayshore/blob/master/src/wmmt/wm.proto.js"
click node_service_proto "https://github.com/projectasakura/bayshore/blob/master/src/wmmt/service.proto.js"
click node_common "https://github.com/projectasakura/bayshore/blob/master/src/modules/util/common.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_server,node_allnet,node_mucha,node_client toneBlue
class node_users,node_cars,node_car_tune,node_terminal,node_scratch,node_startup,node_meter toneAmber
class node_game,node_game_functions,node_story,node_time_attack,node_versus,node_ranking,node_crown toneMint
class node_ghost_game,node_ghost_service,node_ghost_ops,node_history,node_ocm,node_ghost_area,node_path_area,node_ocm_area,node_trail toneRose
class node_config,node_proto,node_service_proto,node_common,node_db toneIndigo
```

## Components

### Protocol entry

- [HTTP service](https://github.com/projectasakura/bayshore/blob/master/src/index.ts): `src/index.ts`
- [ALL.Net startup](https://github.com/projectasakura/bayshore/blob/master/src/allnet.ts): `src/allnet.ts`
- [Mucha board/update](https://github.com/projectasakura/bayshore/blob/master/src/mucha.ts): `src/mucha.ts`

### Player services

- [User accounts](https://github.com/projectasakura/bayshore/blob/master/src/modules/users.ts): `src/modules/users.ts`
- [Car management](https://github.com/projectasakura/bayshore/blob/master/src/modules/cars/functions.ts): `src/modules/cars/functions.ts`
- [Car tuning](https://github.com/projectasakura/bayshore/blob/master/src/modules/cars/car_tune.ts): `src/modules/cars/car_tune.ts`
- [Terminal services](https://github.com/projectasakura/bayshore/blob/master/src/modules/terminal.ts): `src/modules/terminal.ts`
- [Scratch rewards](https://github.com/projectasakura/bayshore/blob/master/src/modules/terminal/scratch.ts): `src/modules/terminal/scratch.ts`
- [Game startup](https://github.com/projectasakura/bayshore/blob/master/src/modules/startup/functions.ts): `src/modules/startup/functions.ts`
- [Meter rewards](https://github.com/projectasakura/bayshore/blob/master/src/modules/util/meter_reward.ts): `src/modules/util/meter_reward.ts`

### Racing features

- [Game dispatch](https://github.com/projectasakura/bayshore/blob/master/src/modules/game.ts): `src/modules/game.ts`
- [Game operations](https://github.com/projectasakura/bayshore/blob/master/src/modules/game/functions.ts): `src/modules/game/functions.ts`
- [Story mode](https://github.com/projectasakura/bayshore/blob/master/src/modules/game/story.ts): `src/modules/game/story.ts`
- [Time attack](https://github.com/projectasakura/bayshore/blob/master/src/modules/game/time_attack.ts): `src/modules/game/time_attack.ts`
- [Versus mode](https://github.com/projectasakura/bayshore/blob/master/src/modules/game/versus.ts): `src/modules/game/versus.ts`
- [Rankings](https://github.com/projectasakura/bayshore/blob/master/src/modules/resource/ranking.ts): `src/modules/resource/ranking.ts`
- [Crown list](https://github.com/projectasakura/bayshore/blob/master/src/modules/resource/crown_list.ts): `src/modules/resource/crown_list.ts`

### Ghost features

- [Ghost gameplay](https://github.com/projectasakura/bayshore/blob/master/src/modules/game/ghost.ts): `src/modules/game/ghost.ts`
- [Ghost services](https://github.com/projectasakura/bayshore/blob/master/src/modules/ghost.ts): `src/modules/ghost.ts`
- [Ghost operations](https://github.com/projectasakura/bayshore/blob/master/src/modules/ghost/functions.ts): `src/modules/ghost/functions.ts`
- [Ghost history](https://github.com/projectasakura/bayshore/blob/master/src/modules/ghost/ghost_history.ts): `src/modules/ghost/ghost_history.ts`
- [OCM competition](https://github.com/projectasakura/bayshore/blob/master/src/modules/ghost/ghost_ocm.ts): `src/modules/ghost/ghost_ocm.ts`
- [Area selection](https://github.com/projectasakura/bayshore/blob/master/src/modules/ghost/ghost_util/ghost_area.ts): `src/modules/ghost/ghost_util/ghost_area.ts`
- [Path area lookup](https://github.com/projectasakura/bayshore/blob/master/src/modules/ghost/ghost_util/ghost_get_area_from_path.ts): `src/modules/ghost/ghost_util/ghost_get_area_from_path.ts`
- [OCM area lookup](https://github.com/projectasakura/bayshore/blob/master/src/modules/ghost/ghost_util/ghost_ocm_area.ts): `src/modules/ghost/ghost_util/ghost_ocm_area.ts`
- [Ghost trail](https://github.com/projectasakura/bayshore/blob/master/src/modules/ghost/ghost_util/ghost_trail.ts): `src/modules/ghost/ghost_util/ghost_trail.ts`

### Shared runtime

- [Runtime config](https://github.com/projectasakura/bayshore/blob/master/src/config.ts): `src/config.ts`
- [Protocol definitions](https://github.com/projectasakura/bayshore/blob/master/src/wmmt/wm.proto.js): `src/wmmt/wm.proto.js`
- [Service protocol](https://github.com/projectasakura/bayshore/blob/master/src/wmmt/service.proto.js): `src/wmmt/service.proto.js`
- [Response utilities](https://github.com/projectasakura/bayshore/blob/master/src/modules/util/common.ts): `src/modules/util/common.ts`
- **Game database**

### Other components

- **Game client**

## Connections

- Game client → HTTP service: sends requests (evidence: `src/index.ts`)
- HTTP service → ALL.Net startup: registers protocol (evidence: `src/index.ts`)
- HTTP service → Mucha board/update: registers protocol (evidence: `src/index.ts`)
- HTTP service → Runtime config: loads settings (evidence: `src/index.ts`)
- HTTP service → Game database: initializes client (evidence: `src/index.ts`)
- ALL.Net startup → Runtime config: reads settings (evidence: `src/allnet.ts`)
- ALL.Net startup → Response utilities: sanitizes inputs (evidence: `src/allnet.ts`)
- Mucha board/update → Runtime config: reads settings (evidence: `src/mucha.ts`)
- Game dispatch → Game operations: calls operations (evidence: `src/modules/game.ts`)
- Game dispatch → Story mode: dispatches mode (evidence: `src/modules/game.ts`)
- Game dispatch → Time attack: dispatches mode (evidence: `src/modules/game.ts`)
- Game dispatch → Ghost gameplay: dispatches mode (evidence: `src/modules/game.ts`)
- Game dispatch → Versus mode: dispatches mode (evidence: `src/modules/game.ts`)
- Ghost gameplay → Ghost history: saves results (evidence: `src/modules/game/ghost.ts`)
- Ghost history → Path area lookup: resolves area (evidence: `src/modules/ghost/ghost_history.ts`)
- Ghost services → Ghost operations: calls operations (evidence: `src/modules/ghost.ts`)
- Ghost services → Ghost trail: uses trail utility (evidence: `src/modules/ghost.ts`)
- Ghost trail → OCM area lookup: resolves competition area (evidence: `src/modules/ghost/ghost_util/ghost_trail.ts`)
- Ghost trail → Area selection: resolves ghost area (evidence: `src/modules/ghost/ghost_util/ghost_trail.ts`)
- Terminal services → Scratch rewards: uses scratch sheets (evidence: `src/modules/terminal.ts`)
- Terminal services → Game database: reads and writes (evidence: `src/modules/terminal.ts`)
- Ghost gameplay → Game database: updates race state (evidence: `src/modules/game/ghost.ts`)
- Ghost history → Game database: records battles (evidence: `src/modules/ghost/ghost_history.ts`)
- OCM competition → Game database: tallies competition (evidence: `src/modules/ghost/ghost_ocm.ts`)
- Scratch rewards → Game database: stores reward sheets (evidence: `src/modules/terminal/scratch.ts`)
- Terminal services → Protocol definitions: decodes requests (evidence: `src/modules/terminal.ts`)
- Ghost gameplay → Protocol definitions: uses messages (evidence: `src/modules/game/ghost.ts`)
- Ghost services → Service protocol: uses service messages (evidence: `src/modules/ghost.ts`)
- Rankings → Service protocol: uses service messages (evidence: `src/modules/resource/ranking.ts`)
- Crown list → Service protocol: uses service messages (evidence: `src/modules/resource/crown_list.ts`)
