How esther-pui/who-drank-my-coke works
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: Game.ts Investigation game · main.ts Scene runtime · main.py Game API · GameOver.ts Game over
Components 15
Game frontend
- React entry
frontend/who-drank-my-coke/src/main.tsx - App host
frontend/who-drank-my-coke/src/App.tsx - Phaser host
frontend/who-drank-my-coke/src/PhaserGame.tsx - Scene runtime
frontend/who-drank-my-coke/src/game/main.ts - Asset preloader
frontend/who-drank-my-coke/src/game/scenes/Preloader.ts - Story intro
frontend/who-drank-my-coke/src/game/scenes/Intro.ts - Main menu
frontend/who-drank-my-coke/src/game/scenes/MainMenu.ts - Investigation game
frontend/who-drank-my-coke/src/game/scenes/Game.ts - Game over
frontend/who-drank-my-coke/src/game/scenes/GameOver.ts - Scene event bus
frontend/who-drank-my-coke/src/game/EventBus.ts
Game backend
- Game API
backend/app/main.py - In-memory games
backend/app/main.py
Mystery logic
- Action workflow
backend/app/graph.py
Other components
- Player
- Azure chat model
Connections 22
- Player → Investigation game: plays
frontend/who-drank-my-coke/src/game/scenes/Game.ts - React entry → App host: renders
frontend/who-drank-my-coke/src/main.tsx - App host → Phaser host: renders
frontend/who-drank-my-coke/src/App.tsx - Phaser host → Scene runtime: starts
frontend/who-drank-my-coke/src/PhaserGame.tsx - Scene runtime → Asset preloader: registers
frontend/who-drank-my-coke/src/game/main.ts - Scene runtime → Story intro: registers
frontend/who-drank-my-coke/src/game/main.ts - Scene runtime → Main menu: registers
frontend/who-drank-my-coke/src/game/main.ts - Scene runtime → Investigation game: registers
frontend/who-drank-my-coke/src/game/main.ts - Scene runtime → Game over: registers
frontend/who-drank-my-coke/src/game/main.ts - Asset preloader → Story intro: starts
frontend/who-drank-my-coke/src/game/scenes/Preloader.ts - Story intro → Investigation game: starts
frontend/who-drank-my-coke/src/game/scenes/Intro.ts - Main menu → Investigation game: starts
frontend/who-drank-my-coke/src/game/scenes/MainMenu.ts - Investigation game → Game over: starts
frontend/who-drank-my-coke/src/game/scenes/Game.ts - Game over → Investigation game: restarts
frontend/who-drank-my-coke/src/game/scenes/GameOver.ts - Main menu → Scene event bus: emits scene event
frontend/who-drank-my-coke/src/game/scenes/MainMenu.ts - Game over → Scene event bus: emits scene event
frontend/who-drank-my-coke/src/game/scenes/GameOver.ts - Phaser host → Scene event bus: subscribes
frontend/who-drank-my-coke/src/PhaserGame.tsx - Investigation game → Game API: calls inspect and accuse
frontend/who-drank-my-coke/src/game/scenes/Game.ts - Game API → In-memory games: reads and writes
backend/app/main.py - Game API → Action workflow: invokes actions
backend/app/main.py - Action workflow → Game API: returns action state
backend/app/main.py - Game API → Azure chat model: requests reply
backend/app/main.py