How sofie-kirk22/death-mahjong works
Death Mahjong is a multiplayer drinking game: players create or join rooms, take turns drawing drawable tiles, and see sip totals and end-of-game results. The backend API owns room actions, delegates game rules to GameEngine, and publishes room updates through SignalR; the frontend provides lobby, play, profile, and leaderboard views. Persistent entities and statistics are represented in the backend data layer, although the README describes room state as in-memory. API route details and several pages are supported by the README/tree rather than sampled implementation, so uncertain call wiring is omitted.
Main entry points: api.ts REST client · Program.cs HTTP API · AppDbContext.cs EF data access · page.tsx Room entry
Components 22
Player experience
- Room entry
frontend/death-mahjong-client/app/page.tsx - Room lobby
frontend/death-mahjong-client/app/room/[roomId]/page.tsx - Live game view
frontend/death-mahjong-client/app/game/[roomId]/page.tsx - Game results
frontend/death-mahjong-client/app/game-end/[roomId]/page.tsx - Player profile
frontend/death-mahjong-client/app/profile/page.tsx - Leaderboards
frontend/death-mahjong-client/app/stats/page.tsx - Room session
frontend/death-mahjong-client/lib/gameSession.ts
Game runtime
- HTTP API
backend/DeathMahjong/Program.cs - Game rules
backend/DeathMahjong/Services/GameEngine.cs - Room store
backend/DeathMahjong/Services/GameRoomStore.cs - Room state
backend/DeathMahjong/Models/GameRoom.cs
Accounts and records
- User session
frontend/death-mahjong-client/lib/userSession.ts - EF data access
backend/DeathMahjong/Data/AppDbContext.cs - Room and game records
backend/DeathMahjong/Data/Entities/GameRoomEntity.cs - User records
backend/DeathMahjong/Data/Entities/UserEntity.cs - Completed-game records
backend/DeathMahjong/Data/Entities/CompletedGameEntity.cs - Relational database
- Statistics records
backend/DeathMahjong/Data/Entities/CompletedGamePlayerEntity.cs
Realtime transport
- REST client
frontend/death-mahjong-client/lib/api.ts - SignalR hub
backend/DeathMahjong/Hubs/GameHub.cs - Live connection
frontend/death-mahjong-client/lib/gameHub.ts
Other components
- Players
Connections 27
- Players → Room entry: create or join
- Room entry → REST client: requests
- Room entry → Room session: saves identity
- Room entry → User session: saves user
- Room lobby → REST client: room actions
- Live game view → REST client: draw or abort
- Live game view → Room session: reads player
- Player profile → REST client: loads profile
- Player profile → User session: reads and saves
- Leaderboards → REST client: loads statistics
- REST client → HTTP API: HTTP requests
- HTTP API → Game rules: delegates rules
- HTTP API → Room store: reads and writes
- HTTP API → Room state: updates state
- HTTP API → SignalR hub: broadcasts events
- Live game view → Live connection: subscribes
- Live connection → SignalR hub: SignalR connection
- SignalR hub → Live game view: live updates
- HTTP API → EF data access: persists and queries
- EF data access → Room and game records: maps records
- EF data access → User records: maps users
- EF data access → Completed-game records: maps completed games
- EF data access → Statistics records: maps player statistics
- EF data access → Relational database: reads and writes
- Game results → REST client: loads room results
- Players → Player profile: view profile
- Players → Leaderboards: view leaderboards