How kinsara007/mafia-frontend-main works
Mafia is a real-time multiplayer party game. Players authenticate, create or join a room, wait in its lobby, then play alternating night-action and day-discussion/voting phases until a winner is shown. GameApp coordinates screen state, API operations, persisted session/room data, and game updates. The README is only the default Next.js template; feature names and wiring here come from the supplied tree and sampled source. Several screens and the page entry are unsampled, so their internal behavior and exact event wiring are not inferred.
Main entry points: game-app.tsx Game coordinator · LobbyScreen.tsx Room lobby · DayPhaseScreen.tsx Day discussion and vote · ActionPanel.tsx Night action selector
Components 25
Game experience
- App page
src/app/page.tsx - Sign in / register
src/screens/AuthScreen.tsx - Home and room entry
src/screens/HomeScreen.tsx - Room lobby
src/screens/LobbyScreen.tsx - Role reveal
src/screens/RoleRevealScreen.tsx - Night actions
src/screens/NightPhaseScreen.tsx - Night outcome
src/screens/NightResultScreen.tsx - Day discussion and vote
src/screens/DayPhaseScreen.tsx - Day outcome
src/screens/DayResultScreen.tsx - Winner and role reveal
src/screens/GameOverScreen.tsx
Client coordination
- Game coordinator
src/lib/game-app.tsx - Game and domain types
src/lib/types.ts
Persistence and services
- HTTP API client
src/lib/api.ts - Session and room storage
src/lib/storage.ts
Shared interface
- Night action selector
src/components/ActionPanel.tsx - Discussion chat
src/components/ChatPanel.tsx - Vote tally
src/components/VoteTally.tsx - Player card
src/components/PlayerCard.tsx - Navigation bar
src/components/NavBar.tsx - Phase header
src/components/PhaseHeader.tsx - Connection status
src/components/ConnectionBadge.tsx - Icons
src/icons.tsx
Other components
- Player
- Game backend
- Browser local storage
Connections 31
- Player → App page: opens game
- App page → Game coordinator: renders
- Game coordinator → Sign in / register: shows auth
- Game coordinator → Home and room entry: shows home
- Game coordinator → Room lobby: shows lobby
- Game coordinator → Role reveal: shows role
- Game coordinator → Night actions: shows night
- Game coordinator → Night outcome: shows outcome
- Game coordinator → Day discussion and vote: shows day
- Game coordinator → Day outcome: shows outcome
- Game coordinator → Winner and role reveal: shows winner
- Sign in / register → Game coordinator: submits credentials
- Room lobby → Game coordinator: invokes lobby actions
- Night actions → Night action selector: renders selector
- Night action selector → Game coordinator: submits target
- Day discussion and vote → Discussion chat: renders discussion
- Day discussion and vote → Vote tally: renders votes
- Discussion chat → Game coordinator: sends message
- Game coordinator → HTTP API client: requests game operations
- HTTP API client → Game backend: sends HTTP requests
- Game backend → HTTP API client: returns responses
- Game coordinator → Game backend: exchanges game updates
- Game coordinator → Session and room storage: loads and persists state
- Session and room storage → Browser local storage: reads and writes
- Game coordinator → Game and domain types: uses domain definitions
- Game coordinator → Navigation bar: renders navigation
- Game coordinator → Phase header: renders phase status
- Game coordinator → Connection status: renders connection state
- Room lobby → Player card: renders players
- Night action selector → Icons: uses icons
- Discussion chat → Icons: uses icons