# dangnhuphong/gameproject architecture

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

- Interactive diagram: https://gitdiagram.com/dangnhuphong/gameproject
- Repository: https://github.com/dangnhuphong/gameproject

## Overview

OverNấuĂn is a cooperative multiplayer cooking game with online rooms and local play. Players enter through the React app, choose or join a room, and play in a Phaser kitchen: collect ingredients, prepare them at stations, assemble and serve orders for score. Online play uses backend room and match handling with server-authoritative game rules; maps supply the shared kitchen layout. The README also describes recipe access and story-map progression. Some links below are documented rather than source-verified because several relevant modules were not excerpted.

Main entry points: [`frontend/src/services/api.js`](https://github.com/dangnhuphong/gameproject/blob/main/frontend/src/services/api.js) (HTTP API client), [`frontend/src/App.jsx`](https://github.com/dangnhuphong/gameproject/blob/main/frontend/src/App.jsx) (App routing), [`frontend/src/game/KitchenScene.js`](https://github.com/dangnhuphong/gameproject/blob/main/frontend/src/game/KitchenScene.js) (Kitchen scene), [`backend/src/controllers/matchController.js`](https://github.com/dangnhuphong/gameproject/blob/main/backend/src/controllers/matchController.js) (Match API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Client experience"]
  node_app["App routing<br/>[App.jsx]"]
  node_lobby["Room lobby<br/>[Lobby.jsx]"]
  node_world["World map<br/>[WorldMap.jsx]"]
  node_gamepage["Game page<br/>[Game.jsx]"]
  node_api["HTTP API client<br/>[api.js]"]
end

subgraph group_play["Gameplay runtime"]
  node_scene["Kitchen scene<br/>[KitchenScene.js]"]
  node_audio["Game audio<br/>[GameAudio.js]"]
  node_controls["Game controls<br/>[gameControls.js]"]
  node_local["Local transport<br/>[LocalTransport.js]"]
  node_localrules["Local game rules<br/>[GameController.js]"]
  node_localroom["Local room state<br/>[GameRoom.js]"]
end

subgraph group_backend["Room backend"]
  node_socket["Socket server<br/>[server.js]"]
  node_runtime["Game runtime<br/>[gameRuntime.js]"]
  node_rules["Authoritative game rules<br/>[GameController.js]"]
  node_room["Room state<br/>[GameRoom.js]"]
  node_stations["Stations and items"]
  node_match["Match API<br/>[matchController.js]"]
  node_recipes["Recipe API"]
end

subgraph group_content["Content and persistence"]
  node_maps["Map layouts"]
  node_story["Story progression<br/>[storyConfig.js]"]
  node_characters["Character selection<br/>[characterStore.js]"]
end

node_player(("Player"))
node_supabase[("Supabase")]

node_player -->|"enters game"| node_app
node_app -->|"routes to"| node_lobby
node_app -->|"routes to"| node_world
node_app -->|"routes to"| node_gamepage
node_lobby -->|"requests rooms"| node_api
node_world -->|"loads match data"| node_api
node_gamepage -->|"loads match and recipes"| node_api
node_gamepage -->|"starts scene"| node_scene
node_scene -->|"plays effects"| node_audio
node_scene -->|"uses offline transport"| node_local
node_local -->|"dispatches actions"| node_localrules
node_localrules -->|"updates room"| node_localroom
node_scene -->|"sends game events"| node_socket
node_socket -->|"uses runtime"| node_runtime
node_runtime -->|"creates controller"| node_rules
node_rules -->|"updates room"| node_room
node_room -->|"builds game objects"| node_stations
node_socket -->|"serves map layout"| node_maps
node_api -.->|"calls match endpoints"| node_match
node_api -.->|"calls recipe endpoints"| node_recipes
node_match -->|"reads and writes"| node_supabase
node_recipes -->|"reads recipes"| node_supabase
node_match -->|"checks map access"| node_story
node_match -->|"reads selections"| node_characters

click node_app "https://github.com/dangnhuphong/gameproject/blob/main/frontend/src/App.jsx"
click node_lobby "https://github.com/dangnhuphong/gameproject/blob/main/frontend/src/pages/Lobby.jsx"
click node_world "https://github.com/dangnhuphong/gameproject/blob/main/frontend/src/pages/WorldMap.jsx"
click node_gamepage "https://github.com/dangnhuphong/gameproject/blob/main/frontend/src/pages/Game.jsx"
click node_api "https://github.com/dangnhuphong/gameproject/blob/main/frontend/src/services/api.js"
click node_scene "https://github.com/dangnhuphong/gameproject/blob/main/frontend/src/game/KitchenScene.js"
click node_audio "https://github.com/dangnhuphong/gameproject/blob/main/frontend/src/game/GameAudio.js"
click node_controls "https://github.com/dangnhuphong/gameproject/blob/main/frontend/src/game/gameControls.js"
click node_local "https://github.com/dangnhuphong/gameproject/blob/main/frontend/src/game/LocalTransport.js"
click node_localrules "https://github.com/dangnhuphong/gameproject/blob/main/frontend/src/game/core/GameController.js"
click node_localroom "https://github.com/dangnhuphong/gameproject/blob/main/frontend/src/game/core/GameRoom.js"
click node_socket "https://github.com/dangnhuphong/gameproject/blob/main/backend/src/server.js"
click node_runtime "https://github.com/dangnhuphong/gameproject/blob/main/backend/src/classes/gameRuntime.js"
click node_rules "https://github.com/dangnhuphong/gameproject/blob/main/backend/src/classes/GameController.js"
click node_room "https://github.com/dangnhuphong/gameproject/blob/main/backend/src/classes/GameRoom.js"
click node_stations "https://github.com/dangnhuphong/gameproject/tree/main/backend/src/classes"
click node_maps "https://github.com/dangnhuphong/gameproject/tree/main/backend/src/maps"
click node_match "https://github.com/dangnhuphong/gameproject/blob/main/backend/src/controllers/matchController.js"
click node_recipes "https://github.com/dangnhuphong/gameproject/blob/main/backend/src/controllers/recipeController.js"
click node_story "https://github.com/dangnhuphong/gameproject/blob/main/backend/src/classes/storyConfig.js"
click node_characters "https://github.com/dangnhuphong/gameproject/blob/main/backend/src/classes/characterStore.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_app,node_lobby,node_world,node_gamepage,node_api toneBlue
class node_scene,node_audio,node_controls,node_local,node_localrules,node_localroom,node_supabase toneAmber
class node_socket,node_runtime,node_rules,node_room,node_stations,node_match,node_recipes toneMint
class node_maps,node_story,node_characters toneRose
class node_player toneIndigo
```

## Components

### Client experience

- [App routing](https://github.com/dangnhuphong/gameproject/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Room lobby](https://github.com/dangnhuphong/gameproject/blob/main/frontend/src/pages/Lobby.jsx): `frontend/src/pages/Lobby.jsx`
- [World map](https://github.com/dangnhuphong/gameproject/blob/main/frontend/src/pages/WorldMap.jsx): `frontend/src/pages/WorldMap.jsx`
- [Game page](https://github.com/dangnhuphong/gameproject/blob/main/frontend/src/pages/Game.jsx): `frontend/src/pages/Game.jsx`
- [HTTP API client](https://github.com/dangnhuphong/gameproject/blob/main/frontend/src/services/api.js): `frontend/src/services/api.js`

### Gameplay runtime

- [Kitchen scene](https://github.com/dangnhuphong/gameproject/blob/main/frontend/src/game/KitchenScene.js): `frontend/src/game/KitchenScene.js`
- [Game audio](https://github.com/dangnhuphong/gameproject/blob/main/frontend/src/game/GameAudio.js): `frontend/src/game/GameAudio.js`
- [Game controls](https://github.com/dangnhuphong/gameproject/blob/main/frontend/src/game/gameControls.js): `frontend/src/game/gameControls.js`
- [Local transport](https://github.com/dangnhuphong/gameproject/blob/main/frontend/src/game/LocalTransport.js): `frontend/src/game/LocalTransport.js`
- [Local game rules](https://github.com/dangnhuphong/gameproject/blob/main/frontend/src/game/core/GameController.js): `frontend/src/game/core/GameController.js`
- [Local room state](https://github.com/dangnhuphong/gameproject/blob/main/frontend/src/game/core/GameRoom.js): `frontend/src/game/core/GameRoom.js`

### Room backend

- [Socket server](https://github.com/dangnhuphong/gameproject/blob/main/backend/src/server.js): `backend/src/server.js`
- [Game runtime](https://github.com/dangnhuphong/gameproject/blob/main/backend/src/classes/gameRuntime.js): `backend/src/classes/gameRuntime.js`
- [Authoritative game rules](https://github.com/dangnhuphong/gameproject/blob/main/backend/src/classes/GameController.js): `backend/src/classes/GameController.js`
- [Room state](https://github.com/dangnhuphong/gameproject/blob/main/backend/src/classes/GameRoom.js): `backend/src/classes/GameRoom.js`
- [Stations and items](https://github.com/dangnhuphong/gameproject/tree/main/backend/src/classes): `backend/src/classes`
- [Match API](https://github.com/dangnhuphong/gameproject/blob/main/backend/src/controllers/matchController.js): `backend/src/controllers/matchController.js`
- [Recipe API](https://github.com/dangnhuphong/gameproject/blob/main/backend/src/controllers/recipeController.js): `backend/src/controllers/recipeController.js`

### Content and persistence

- [Map layouts](https://github.com/dangnhuphong/gameproject/tree/main/backend/src/maps): `backend/src/maps`
- [Story progression](https://github.com/dangnhuphong/gameproject/blob/main/backend/src/classes/storyConfig.js): `backend/src/classes/storyConfig.js`
- [Character selection](https://github.com/dangnhuphong/gameproject/blob/main/backend/src/classes/characterStore.js): `backend/src/classes/characterStore.js`

### Other components

- **Player**
- **Supabase**

## Connections

- Player → App routing: enters game
- App routing → Room lobby: routes to (evidence: `frontend/src/App.jsx`)
- App routing → World map: routes to (evidence: `frontend/src/App.jsx`)
- App routing → Game page: routes to (evidence: `frontend/src/App.jsx`)
- Room lobby → HTTP API client: requests rooms (evidence: `frontend/src/pages/Lobby.jsx`)
- World map → HTTP API client: loads match data (evidence: `frontend/src/pages/WorldMap.jsx`)
- Game page → HTTP API client: loads match and recipes (evidence: `frontend/src/pages/Game.jsx`)
- Game page → Kitchen scene: starts scene (evidence: `frontend/src/pages/Game.jsx`)
- Kitchen scene → Game audio: plays effects (evidence: `frontend/src/game/KitchenScene.js`)
- Kitchen scene → Local transport: uses offline transport (evidence: `frontend/src/game/KitchenScene.js`)
- Local transport → Local game rules: dispatches actions (evidence: `frontend/src/game/LocalTransport.js`)
- Local game rules → Local room state: updates room (evidence: `frontend/src/game/core/GameController.js`)
- Kitchen scene → Socket server: sends game events
- Socket server → Game runtime: uses runtime (evidence: `backend/src/server.js`)
- Game runtime → Authoritative game rules: creates controller (evidence: `backend/src/classes/gameRuntime.js`)
- Authoritative game rules → Room state: updates room (evidence: `backend/src/classes/GameController.js`)
- Room state → Stations and items: builds game objects (evidence: `backend/src/classes/GameRoom.js`)
- Socket server → Map layouts: serves map layout
- HTTP API client → Match API: calls match endpoints
- HTTP API client → Recipe API: calls recipe endpoints
- Match API → Supabase: reads and writes (evidence: `backend/src/controllers/matchController.js`)
- Recipe API → Supabase: reads recipes (evidence: `backend/src/controllers/recipeController.js`)
- Match API → Story progression: checks map access (evidence: `backend/src/controllers/matchController.js`)
- Match API → Character selection: reads selections (evidence: `backend/src/controllers/matchController.js`)
