# esther-pui/who-drank-my-coke architecture

> Architecture diagram of the GitHub repository esther-pui/who-drank-my-coke, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-15). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/esther-pui/who-drank-my-coke
- Repository: https://github.com/esther-pui/who-drank-my-coke

## Overview

Who Drank My Coke? is a browser-based mystery game: players inspect a kitchen, question characters, and accuse a suspect. The React host starts a Phaser game; its scenes handle the intro, investigation, and ending. The game calls a FastAPI backend, which keeps game state in memory and delegates investigation and accusation actions to a LangGraph workflow; character replies are generated through an Azure OpenAI-compatible chat service. Source excerpts show several scene transitions and API actions, but not every frontend request or backend implementation detail.

Main entry points: [`frontend/who-drank-my-coke/src/game/scenes/Game.ts`](https://github.com/esther-pui/who-drank-my-coke/blob/main/frontend/who-drank-my-coke/src/game/scenes/Game.ts) (Investigation game), [`frontend/who-drank-my-coke/src/game/main.ts`](https://github.com/esther-pui/who-drank-my-coke/blob/main/frontend/who-drank-my-coke/src/game/main.ts) (Scene runtime), [`backend/app/main.py`](https://github.com/esther-pui/who-drank-my-coke/blob/main/backend/app/main.py) (Game API), [`frontend/who-drank-my-coke/src/game/scenes/GameOver.ts`](https://github.com/esther-pui/who-drank-my-coke/blob/main/frontend/who-drank-my-coke/src/game/scenes/GameOver.ts) (Game over)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Game frontend"]
  node_react["React entry<br/>[main.tsx]"]
  node_app["App host<br/>[App.tsx]"]
  node_phaser_host["Phaser host<br/>[PhaserGame.tsx]"]
  node_game_runtime["Scene runtime<br/>[main.ts]"]
  node_preloader["Asset preloader<br/>[Preloader.ts]"]
  node_intro["Story intro<br/>[Intro.ts]"]
  node_menu["Main menu<br/>[MainMenu.ts]"]
  node_game_scene["Investigation game<br/>[Game.ts]"]
  node_game_over["Game over<br/>[GameOver.ts]"]
  node_event_bus["Scene event bus<br/>[EventBus.ts]"]
end

subgraph group_backend["Game backend"]
  node_api["Game API<br/>[main.py]"]
  node_game_store[("In-memory games<br/>[main.py]")]
end

subgraph group_logic["Mystery logic"]
  node_action_graph["Action workflow<br/>[graph.py]"]
end

node_player(("Player"))
node_chat_service{{"Azure chat model"}}

node_player -->|"plays"| node_game_scene
node_react -->|"renders"| node_app
node_app -->|"renders"| node_phaser_host
node_phaser_host -->|"starts"| node_game_runtime
node_game_runtime -->|"registers"| node_preloader
node_game_runtime -->|"registers"| node_intro
node_game_runtime -->|"registers"| node_menu
node_game_runtime -->|"registers"| node_game_scene
node_game_runtime -->|"registers"| node_game_over
node_preloader -->|"starts"| node_intro
node_intro -->|"starts"| node_game_scene
node_menu -->|"starts"| node_game_scene
node_game_scene -->|"starts"| node_game_over
node_game_over -->|"restarts"| node_game_scene
node_menu -->|"emits scene event"| node_event_bus
node_game_over -->|"emits scene event"| node_event_bus
node_phaser_host -->|"subscribes"| node_event_bus
node_game_scene -->|"calls inspect and accuse"| node_api
node_api -->|"reads and writes"| node_game_store
node_api -->|"invokes actions"| node_action_graph
node_action_graph -->|"returns action state"| node_api
node_api -->|"requests reply"| node_chat_service

click node_react "https://github.com/esther-pui/who-drank-my-coke/blob/main/frontend/who-drank-my-coke/src/main.tsx"
click node_app "https://github.com/esther-pui/who-drank-my-coke/blob/main/frontend/who-drank-my-coke/src/App.tsx"
click node_phaser_host "https://github.com/esther-pui/who-drank-my-coke/blob/main/frontend/who-drank-my-coke/src/PhaserGame.tsx"
click node_game_runtime "https://github.com/esther-pui/who-drank-my-coke/blob/main/frontend/who-drank-my-coke/src/game/main.ts"
click node_preloader "https://github.com/esther-pui/who-drank-my-coke/blob/main/frontend/who-drank-my-coke/src/game/scenes/Preloader.ts"
click node_intro "https://github.com/esther-pui/who-drank-my-coke/blob/main/frontend/who-drank-my-coke/src/game/scenes/Intro.ts"
click node_menu "https://github.com/esther-pui/who-drank-my-coke/blob/main/frontend/who-drank-my-coke/src/game/scenes/MainMenu.ts"
click node_game_scene "https://github.com/esther-pui/who-drank-my-coke/blob/main/frontend/who-drank-my-coke/src/game/scenes/Game.ts"
click node_game_over "https://github.com/esther-pui/who-drank-my-coke/blob/main/frontend/who-drank-my-coke/src/game/scenes/GameOver.ts"
click node_event_bus "https://github.com/esther-pui/who-drank-my-coke/blob/main/frontend/who-drank-my-coke/src/game/EventBus.ts"
click node_api "https://github.com/esther-pui/who-drank-my-coke/blob/main/backend/app/main.py"
click node_game_store "https://github.com/esther-pui/who-drank-my-coke/blob/main/backend/app/main.py"
click node_action_graph "https://github.com/esther-pui/who-drank-my-coke/blob/main/backend/app/graph.py"

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_react,node_app,node_phaser_host,node_game_runtime,node_preloader,node_intro,node_menu,node_game_scene,node_game_over,node_event_bus toneBlue
class node_api,node_game_store toneAmber
class node_action_graph toneMint
class node_player,node_chat_service toneIndigo
```

## Components

### Game frontend

- [React entry](https://github.com/esther-pui/who-drank-my-coke/blob/main/frontend/who-drank-my-coke/src/main.tsx): `frontend/who-drank-my-coke/src/main.tsx`
- [App host](https://github.com/esther-pui/who-drank-my-coke/blob/main/frontend/who-drank-my-coke/src/App.tsx): `frontend/who-drank-my-coke/src/App.tsx`
- [Phaser host](https://github.com/esther-pui/who-drank-my-coke/blob/main/frontend/who-drank-my-coke/src/PhaserGame.tsx): `frontend/who-drank-my-coke/src/PhaserGame.tsx`
- [Scene runtime](https://github.com/esther-pui/who-drank-my-coke/blob/main/frontend/who-drank-my-coke/src/game/main.ts): `frontend/who-drank-my-coke/src/game/main.ts`
- [Asset preloader](https://github.com/esther-pui/who-drank-my-coke/blob/main/frontend/who-drank-my-coke/src/game/scenes/Preloader.ts): `frontend/who-drank-my-coke/src/game/scenes/Preloader.ts`
- [Story intro](https://github.com/esther-pui/who-drank-my-coke/blob/main/frontend/who-drank-my-coke/src/game/scenes/Intro.ts): `frontend/who-drank-my-coke/src/game/scenes/Intro.ts`
- [Main menu](https://github.com/esther-pui/who-drank-my-coke/blob/main/frontend/who-drank-my-coke/src/game/scenes/MainMenu.ts): `frontend/who-drank-my-coke/src/game/scenes/MainMenu.ts`
- [Investigation game](https://github.com/esther-pui/who-drank-my-coke/blob/main/frontend/who-drank-my-coke/src/game/scenes/Game.ts): `frontend/who-drank-my-coke/src/game/scenes/Game.ts`
- [Game over](https://github.com/esther-pui/who-drank-my-coke/blob/main/frontend/who-drank-my-coke/src/game/scenes/GameOver.ts): `frontend/who-drank-my-coke/src/game/scenes/GameOver.ts`
- [Scene event bus](https://github.com/esther-pui/who-drank-my-coke/blob/main/frontend/who-drank-my-coke/src/game/EventBus.ts): `frontend/who-drank-my-coke/src/game/EventBus.ts`

### Game backend

- [Game API](https://github.com/esther-pui/who-drank-my-coke/blob/main/backend/app/main.py): `backend/app/main.py`
- [In-memory games](https://github.com/esther-pui/who-drank-my-coke/blob/main/backend/app/main.py): `backend/app/main.py`

### Mystery logic

- [Action workflow](https://github.com/esther-pui/who-drank-my-coke/blob/main/backend/app/graph.py): `backend/app/graph.py`

### Other components

- **Player**
- **Azure chat model**

## Connections

- Player → Investigation game: plays (evidence: `frontend/who-drank-my-coke/src/game/scenes/Game.ts`)
- React entry → App host: renders (evidence: `frontend/who-drank-my-coke/src/main.tsx`)
- App host → Phaser host: renders (evidence: `frontend/who-drank-my-coke/src/App.tsx`)
- Phaser host → Scene runtime: starts (evidence: `frontend/who-drank-my-coke/src/PhaserGame.tsx`)
- Scene runtime → Asset preloader: registers (evidence: `frontend/who-drank-my-coke/src/game/main.ts`)
- Scene runtime → Story intro: registers (evidence: `frontend/who-drank-my-coke/src/game/main.ts`)
- Scene runtime → Main menu: registers (evidence: `frontend/who-drank-my-coke/src/game/main.ts`)
- Scene runtime → Investigation game: registers (evidence: `frontend/who-drank-my-coke/src/game/main.ts`)
- Scene runtime → Game over: registers (evidence: `frontend/who-drank-my-coke/src/game/main.ts`)
- Asset preloader → Story intro: starts (evidence: `frontend/who-drank-my-coke/src/game/scenes/Preloader.ts`)
- Story intro → Investigation game: starts (evidence: `frontend/who-drank-my-coke/src/game/scenes/Intro.ts`)
- Main menu → Investigation game: starts (evidence: `frontend/who-drank-my-coke/src/game/scenes/MainMenu.ts`)
- Investigation game → Game over: starts (evidence: `frontend/who-drank-my-coke/src/game/scenes/Game.ts`)
- Game over → Investigation game: restarts (evidence: `frontend/who-drank-my-coke/src/game/scenes/GameOver.ts`)
- Main menu → Scene event bus: emits scene event (evidence: `frontend/who-drank-my-coke/src/game/scenes/MainMenu.ts`)
- Game over → Scene event bus: emits scene event (evidence: `frontend/who-drank-my-coke/src/game/scenes/GameOver.ts`)
- Phaser host → Scene event bus: subscribes (evidence: `frontend/who-drank-my-coke/src/PhaserGame.tsx`)
- Investigation game → Game API: calls inspect and accuse (evidence: `frontend/who-drank-my-coke/src/game/scenes/Game.ts`)
- Game API → In-memory games: reads and writes (evidence: `backend/app/main.py`)
- Game API → Action workflow: invokes actions (evidence: `backend/app/main.py`)
- Action workflow → Game API: returns action state (evidence: `backend/app/main.py`)
- Game API → Azure chat model: requests reply (evidence: `backend/app/main.py`)
