# tvghung/monopoly architecture

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

- Interactive diagram: https://gitdiagram.com/tvghung/monopoly
- Repository: https://github.com/tvghung/monopoly

## Overview

Own the Block is a host-authoritative multiplayer Monopoly game for desktop and browser players. A desktop host starts the server and creates a LAN or online room; guests join through an invitation or LAN discovery, then play through the shared client while the host server owns room state and reconnect sessions. The graph also shows the client’s 3D presentation and audio layers, plus desktop updates and optional room-code lookup. Evidence is limited to the README and sampled or indexed source references; unverified implementation links are omitted or dashed.

Main entry points: [`apps/client/src/App.tsx`](https://github.com/tvghung/monopoly/blob/main/apps/client/src/App.tsx) (React Client), [`apps/desktop/src/hostRuntime.ts`](https://github.com/tvghung/monopoly/blob/main/apps/desktop/src/hostRuntime.ts) (Desktop Host), [`apps/server/src/authoritativeServer.ts`](https://github.com/tvghung/monopoly/blob/main/apps/server/src/authoritativeServer.ts) (Server Runtime), [`apps/server/src/rooms.ts`](https://github.com/tvghung/monopoly/blob/main/apps/server/src/rooms.ts) (Room Authority)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_desktop["Desktop Host"]
  node_host["Desktop Host<br/>[hostRuntime.ts]"]
  node_ipc["Desktop IPC<br/>[windowHandlers.ts]"]
  node_updates["App Updates<br/>[updateService.ts]"]
end

subgraph group_server["Authoritative Server"]
  node_server["Server Runtime"]
  node_rooms["Room Authority<br/>[rooms.ts]"]
  node_runtime["Command &amp; Session Services<br/>[runtime.ts]"]
  node_player_sessions["Player Admission"]
  node_store[("In-Memory Store<br/>[inMemory.ts]")]
  node_socket["Socket Sessions<br/>[session.ts]"]
end

subgraph group_client["Game Client"]
  node_client["React Client<br/>[App.tsx]"]
  node_sessions["Reconnect Sessions"]
  node_lobby["Lobby &amp; Joining<br/>[Lobby.tsx]"]
  node_dashboard["Game Dashboard<br/>[Dashboard.tsx]"]
end

subgraph group_presentation["Game Presentation"]
  node_audio["Audio Engine<br/>[AudioEngine.ts]"]
  node_presentation["Event Presentation"]
  node_scene["3D Game Scene<br/>[GameScene.tsx]"]
  node_board["3D Board<br/>[Board3D.tsx]"]
end

subgraph group_shared["Shared Rules"]
  node_rules["Game Rules &amp; State<br/>[rules.ts]"]
  node_powerups["Power-up Rules<br/>[powerUps.ts]"]
end

node_guest(("Desktop or Browser Player"))
node_tunnel{{"Quick Tunnel"}}
node_registry["Room Registry<br/>[index.js]"]
node_update_service{{"Update Service"}}

node_guest -->|"starts hosting"| node_host
node_host -.->|"starts process"| node_server
node_host -.->|"starts online"| node_tunnel
node_guest -->|"opens invitation"| node_client
node_client -->|"joins room"| node_socket
node_client -->|"stores token"| node_sessions
node_client -->|"renders"| node_lobby
node_client -->|"renders"| node_dashboard
node_client -->|"updates"| node_presentation
node_presentation -.->|"drives"| node_scene
node_scene -.->|"renders"| node_board
node_presentation -.->|"plays feedback"| node_audio
node_server -->|"creates"| node_runtime
node_server -->|"creates"| node_store
node_server -->|"registers handlers"| node_socket
node_server -->|"configures"| node_rooms
node_runtime -->|"creates"| node_player_sessions
node_runtime -->|"uses"| node_store
node_player_sessions -->|"checks room"| node_rooms
node_socket -->|"dispatches"| node_runtime
node_rooms -->|"uses rules"| node_rules
node_rooms -->|"uses definitions"| node_powerups
node_client -->|"uses protocol"| node_rules
node_host -->|"serves requests"| node_ipc
node_ipc -->|"resolves room"| node_host
node_host -->|"looks up room"| node_registry
node_host -.->|"checks updates"| node_updates
node_updates -.->|"fetches release"| node_update_service

click node_host "https://github.com/tvghung/monopoly/blob/main/apps/desktop/src/hostRuntime.ts"
click node_ipc "https://github.com/tvghung/monopoly/blob/main/apps/desktop/src/ipc/windowHandlers.ts"
click node_updates "https://github.com/tvghung/monopoly/blob/main/apps/desktop/src/update/updateService.ts"
click node_client "https://github.com/tvghung/monopoly/blob/main/apps/client/src/App.tsx"
click node_sessions "https://github.com/tvghung/monopoly/blob/main/apps/client/src/playerSessionStorage.ts"
click node_lobby "https://github.com/tvghung/monopoly/blob/main/apps/client/src/components/Lobby.tsx"
click node_dashboard "https://github.com/tvghung/monopoly/blob/main/apps/client/src/components/Dashboard.tsx"
click node_audio "https://github.com/tvghung/monopoly/blob/main/apps/client/src/audio/AudioEngine.ts"
click node_presentation "https://github.com/tvghung/monopoly/blob/main/apps/client/src/game/presentation/PresentationController.ts"
click node_scene "https://github.com/tvghung/monopoly/blob/main/apps/client/src/game/scene/GameScene.tsx"
click node_board "https://github.com/tvghung/monopoly/blob/main/apps/client/src/game/scene/board/Board3D.tsx"
click node_server "https://github.com/tvghung/monopoly/blob/main/apps/server/src/authoritativeServer.ts"
click node_rooms "https://github.com/tvghung/monopoly/blob/main/apps/server/src/rooms.ts"
click node_runtime "https://github.com/tvghung/monopoly/blob/main/apps/server/src/services/runtime.ts"
click node_player_sessions "https://github.com/tvghung/monopoly/blob/main/apps/server/src/services/playerSessionService.ts"
click node_store "https://github.com/tvghung/monopoly/blob/main/apps/server/src/persistence/inMemory.ts"
click node_socket "https://github.com/tvghung/monopoly/blob/main/apps/server/src/socket/session.ts"
click node_rules "https://github.com/tvghung/monopoly/blob/main/packages/shared/src/rules.ts"
click node_powerups "https://github.com/tvghung/monopoly/blob/main/packages/shared/src/powerUps.ts"
click node_registry "https://github.com/tvghung/monopoly/blob/main/services/room-registry/src/index.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_host,node_ipc,node_updates,node_guest toneBlue
class node_server,node_rooms,node_runtime,node_player_sessions,node_store,node_socket toneAmber
class node_client,node_sessions,node_lobby,node_dashboard toneMint
class node_audio,node_presentation,node_scene,node_board toneRose
class node_rules,node_powerups,node_tunnel,node_update_service toneIndigo
class node_registry toneTeal
```

## Components

### Desktop Host

- [Desktop Host](https://github.com/tvghung/monopoly/blob/main/apps/desktop/src/hostRuntime.ts): `apps/desktop/src/hostRuntime.ts`
- [Desktop IPC](https://github.com/tvghung/monopoly/blob/main/apps/desktop/src/ipc/windowHandlers.ts): `apps/desktop/src/ipc/windowHandlers.ts`
- [App Updates](https://github.com/tvghung/monopoly/blob/main/apps/desktop/src/update/updateService.ts): `apps/desktop/src/update/updateService.ts`

### Authoritative Server

- [Server Runtime](https://github.com/tvghung/monopoly/blob/main/apps/server/src/authoritativeServer.ts): `apps/server/src/authoritativeServer.ts`
- [Room Authority](https://github.com/tvghung/monopoly/blob/main/apps/server/src/rooms.ts): `apps/server/src/rooms.ts`
- [Command & Session Services](https://github.com/tvghung/monopoly/blob/main/apps/server/src/services/runtime.ts): `apps/server/src/services/runtime.ts`
- [Player Admission](https://github.com/tvghung/monopoly/blob/main/apps/server/src/services/playerSessionService.ts): `apps/server/src/services/playerSessionService.ts`
- [In-Memory Store](https://github.com/tvghung/monopoly/blob/main/apps/server/src/persistence/inMemory.ts): `apps/server/src/persistence/inMemory.ts`
- [Socket Sessions](https://github.com/tvghung/monopoly/blob/main/apps/server/src/socket/session.ts): `apps/server/src/socket/session.ts`

### Game Client

- [React Client](https://github.com/tvghung/monopoly/blob/main/apps/client/src/App.tsx): `apps/client/src/App.tsx`
- [Reconnect Sessions](https://github.com/tvghung/monopoly/blob/main/apps/client/src/playerSessionStorage.ts): `apps/client/src/playerSessionStorage.ts`
- [Lobby & Joining](https://github.com/tvghung/monopoly/blob/main/apps/client/src/components/Lobby.tsx): `apps/client/src/components/Lobby.tsx`
- [Game Dashboard](https://github.com/tvghung/monopoly/blob/main/apps/client/src/components/Dashboard.tsx): `apps/client/src/components/Dashboard.tsx`

### Game Presentation

- [Audio Engine](https://github.com/tvghung/monopoly/blob/main/apps/client/src/audio/AudioEngine.ts): `apps/client/src/audio/AudioEngine.ts`
- [Event Presentation](https://github.com/tvghung/monopoly/blob/main/apps/client/src/game/presentation/PresentationController.ts): `apps/client/src/game/presentation/PresentationController.ts`
- [3D Game Scene](https://github.com/tvghung/monopoly/blob/main/apps/client/src/game/scene/GameScene.tsx): `apps/client/src/game/scene/GameScene.tsx`
- [3D Board](https://github.com/tvghung/monopoly/blob/main/apps/client/src/game/scene/board/Board3D.tsx): `apps/client/src/game/scene/board/Board3D.tsx`

### Shared Rules

- [Game Rules & State](https://github.com/tvghung/monopoly/blob/main/packages/shared/src/rules.ts): `packages/shared/src/rules.ts`
- [Power-up Rules](https://github.com/tvghung/monopoly/blob/main/packages/shared/src/powerUps.ts): `packages/shared/src/powerUps.ts`

### Other components

- **Desktop or Browser Player**
- **Quick Tunnel**
- [Room Registry](https://github.com/tvghung/monopoly/blob/main/services/room-registry/src/index.js): `services/room-registry/src/index.js`
- **Update Service**

## Connections

- Desktop or Browser Player → Desktop Host: starts hosting
- Desktop Host → Server Runtime: starts process
- Desktop Host → Quick Tunnel: starts online
- Desktop or Browser Player → React Client: opens invitation
- React Client → Socket Sessions: joins room
- React Client → Reconnect Sessions: stores token (evidence: `apps/client/src/App.tsx`)
- React Client → Lobby & Joining: renders (evidence: `apps/client/src/App.tsx`)
- React Client → Game Dashboard: renders (evidence: `apps/client/src/App.tsx`)
- React Client → Event Presentation: updates (evidence: `apps/client/src/App.tsx`)
- Event Presentation → 3D Game Scene: drives
- 3D Game Scene → 3D Board: renders
- Event Presentation → Audio Engine: plays feedback
- Server Runtime → Command & Session Services: creates (evidence: `apps/server/src/authoritativeServer.ts`)
- Server Runtime → In-Memory Store: creates (evidence: `apps/server/src/authoritativeServer.ts`)
- Server Runtime → Socket Sessions: registers handlers (evidence: `apps/server/src/authoritativeServer.ts`)
- Server Runtime → Room Authority: configures (evidence: `apps/server/src/authoritativeServer.ts`)
- Command & Session Services → Player Admission: creates (evidence: `apps/server/src/services/runtime.ts`)
- Command & Session Services → In-Memory Store: uses (evidence: `apps/server/src/services/runtime.ts`)
- Player Admission → Room Authority: checks room (evidence: `apps/server/src/services/playerSessionService.ts`)
- Socket Sessions → Command & Session Services: dispatches (evidence: `apps/server/src/socket/session.ts`)
- Room Authority → Game Rules & State: uses rules (evidence: `apps/server/src/rooms.ts`)
- Room Authority → Power-up Rules: uses definitions (evidence: `apps/server/src/rooms.ts`)
- React Client → Game Rules & State: uses protocol (evidence: `apps/client/src/App.tsx`)
- Desktop Host → Desktop IPC: serves requests (evidence: `apps/desktop/src/ipc/windowHandlers.ts`)
- Desktop IPC → Desktop Host: resolves room (evidence: `apps/desktop/src/ipc/windowHandlers.ts`)
- Desktop Host → Room Registry: looks up room (evidence: `apps/desktop/src/hostRuntime.ts`)
- Desktop Host → App Updates: checks updates
- App Updates → Update Service: fetches release
