Skip to content

Player Matchmaking and Skill-Based Queue Service #240

@Mkalbani

Description

@Mkalbani

Location: Backend API
Estimated Time: 6 hours
Difficulty: Medium

Description

Implement a matchmaking service that pairs players for head-to-head puzzle challenges based on their skill rating. Players join a queue, the system finds the closest-rated opponent within a configurable ELO range, and creates a match session. Queue wait time expands the ELO window every 30 seconds to prevent indefinite waits.

Tasks

  • MatchmakingQueue entity: playerId, puzzleType, rating, joinedAt, status (waiting/matched/cancelled)
  • POST /matchmaking/join — player joins queue with preferred puzzle type
  • DELETE /matchmaking/leave — player leaves queue
  • GET /matchmaking/status — returns current queue position and estimated wait
  • Background job runs every 10 seconds: scans queue, pairs players within ELO range (starts at ±50, expands ±25 every 30s)
  • On match found: creates GameSession with both players; emits WebSocket event match_found to both
  • GET /matchmaking/history — player's past match results and opponents
  • Graceful handling: if opponent disconnects before game starts, re-queue the waiting player
  • Tests: queue join, pairing algorithm, ELO expansion, re-queue on disconnect, concurrent queue safety

Acceptance Criteria

  • Players matched within ELO range
  • ELO window expands correctly over wait time
  • Both players notified via WebSocket on match
  • Disconnection handled gracefully with re-queue
  • Tests verify pairing logic and edge cases

Metadata

Metadata

Assignees

Labels

Stellar WaveIssues in the Stellar wave program

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions