How pacomariano28/songuess works
Songuess is a browser-based, real-time music-trivia game. Players authenticate, create or join a room, choose a playlist, then compete in server-authoritative rounds: shared previews, first-to-lock guesses, scoring, and rematches. The graph shows the frontend and gateway, authentication and playlist/content services, and the game state machine. Cross-service and deployment links are documented in the README; source excerpts and the SOURCE INDEX support the shown internal calls. Unsampled routes and service wiring are not inferred beyond documented relationships.
Main entry points: index.ts Request gateway · match.service.ts Match orchestrator · playlist.controller.ts Playlist service · auth.service.ts Auth service
Components 34
Browser experience
- React application
srcs/frontend/src/App.tsx - Auth provider
srcs/frontend/src/auth/AuthProvider.tsx - Room pages
srcs/frontend/src/pages/RoomLobbyPage.tsx - Match experience
srcs/frontend/src/pages/MatchPage.tsx - Match event sync
srcs/frontend/src/match/hooks/useMatchSocket.ts - Guess search
srcs/frontend/src/match/hooks/useSpotifyGuessSearch.ts
API gateway
- Request gateway
srcs/backend/api-gateway/src/index.ts - Access checks
srcs/backend/api-gateway/src/middlewares/auth.middleware.ts - Game routing
srcs/backend/api-gateway/src/routes/game.routes.ts
Identity and content
- Auth service
srcs/backend/auth-service/src/services/auth.service.ts - Auth endpoints
srcs/backend/auth-service/src/controllers/auth.controller.ts - Spotify OAuth
srcs/backend/auth-service/src/controllers/oauth.controller.ts - Spotify identity sync
srcs/backend/auth-service/src/services/spotifyAuth.service.ts - Access tokens
srcs/backend/auth-service/src/lib/jwt.ts - Refresh sessions
srcs/backend/auth-service/src/lib/refreshTokens.ts - Auth database
srcs/backend/auth-service/src/lib/prisma.ts - Spotify catalog access
srcs/backend/content-service/src/services/spotify.service.ts - Catalog search
srcs/backend/content-service/src/controllers/search.controller.ts - Token cache
srcs/backend/content-service/src/lib/redis.ts
Gameplay runtime
- Socket routes
srcs/backend/game-service/src/routes/socket.routes.ts - Match events
srcs/backend/game-service/src/controllers/match.controller.ts - Round events
srcs/backend/game-service/src/controllers/round.controller.ts - Match orchestrator
srcs/backend/game-service/src/services/match.service.ts - Match lifecycle and rules
srcs/backend/game-service/src/services/match - Live match state
srcs/backend/game-service/src/services/match.service.ts - Identity validation client
srcs/backend/game-service/src/clients/auth.client.ts
Playable catalog
- Playlist service
srcs/backend/playlist-service/src/controllers/playlist.controller.ts - Playlist selection
srcs/backend/playlist-service/src/services/playlistGenerator.ts - Clip preparation
srcs/backend/playlist-service/src/services/clipWorker.service.ts - Reusable audio media
srcs/backend/playlist-service/src/lib/mediaFiles.ts - Playlist database
srcs/backend/playlist-service/src/lib/prisma.ts
Other components
- Player browser
- HTTPS Nginx
- Spotify Web API
Connections 41
- Player browser → HTTPS Nginx: uses HTTPS
- HTTPS Nginx → React application: serves app
- HTTPS Nginx → Request gateway: routes API
- React application → Auth provider: wraps routes
srcs/frontend/src/App.tsx - React application → Room pages: routes rooms
srcs/frontend/src/App.tsx - React application → Match experience: routes matches
srcs/frontend/src/App.tsx - Player browser → Request gateway: requests services
- Request gateway → Access checks: checks access
- Request gateway → Auth service: routes auth
- Request gateway → Spotify catalog access: routes content
- Request gateway → Playlist service: routes playlists
- Request gateway → Socket routes: proxies sockets
- Auth endpoints → Auth service: calls
srcs/backend/auth-service/src/controllers/auth.controller.ts - Auth service → Auth database: reads and writes
srcs/backend/auth-service/src/services/auth.service.ts - Auth service → Access tokens: signs access
srcs/backend/auth-service/src/services/auth.service.ts - Auth service → Refresh sessions: rotates tokens
srcs/backend/auth-service/src/services/auth.service.ts - Spotify OAuth → Spotify identity sync: handles callback
srcs/backend/auth-service/src/controllers/oauth.controller.ts - Spotify identity sync → Spotify Web API: requests identity
srcs/backend/auth-service/src/services/spotifyAuth.service.ts - Spotify identity sync → Auth database: stores profile
srcs/backend/auth-service/src/services/spotifyAuth.service.ts - Spotify identity sync → Refresh sessions: issues session
srcs/backend/auth-service/src/services/spotifyAuth.service.ts - Catalog search → Spotify catalog access: searches catalog
- Spotify catalog access → Spotify Web API: queries catalog
- Spotify catalog access → Token cache: caches tokens
srcs/backend/content-service/src/services/spotify.service.ts - Socket routes → Match events: registers events
srcs/backend/game-service/src/routes/socket.routes.ts - Socket routes → Round events: registers events
srcs/backend/game-service/src/routes/socket.routes.ts - Match events → Match orchestrator: dispatches actions
srcs/backend/game-service/src/controllers/match.controller.ts - Round events → Match orchestrator: dispatches actions
srcs/backend/game-service/src/controllers/round.controller.ts - Match orchestrator → Match lifecycle and rules: delegates rules
srcs/backend/game-service/src/services/match.service.ts - Match orchestrator → Live match state: owns state
srcs/backend/game-service/src/services/match.service.ts - Identity validation client → Auth service: validates identity
- Playlist service → Playlist selection: selects tracks
srcs/backend/playlist-service/src/controllers/playlist.controller.ts - Playlist service → Clip preparation: prepares clips
srcs/backend/playlist-service/src/controllers/playlist.controller.ts - Clip preparation → Reusable audio media: reuses media
srcs/backend/playlist-service/src/controllers/playlist.controller.ts - Playlist service → Playlist database: stores catalog
- Playlist service → Spotify catalog access: requests metadata
- Match orchestrator → Playlist service: prepares playlists
- Match orchestrator → Spotify catalog access: gets track data
- Match event sync → Player browser: exchanges events
srcs/frontend/src/match/hooks/useMatchSocket.ts - Match experience → Match event sync: syncs match
- Guess search → Catalog search: searches songs
srcs/frontend/src/match/hooks/useSpotifyGuessSearch.ts - Guess search → Socket routes: submits guess
srcs/frontend/src/match/hooks/useSpotifyGuessSearch.ts