# Task ID: 11 # Title: Room Management Backend (Create, Join, Match) # Status: pending # Dependencies: 2, 4, 9 # Priority: high # Description: Develop the backend logic for managing game rooms: creating private rooms (with password, config), joining rooms via code, and implementing a basic random matchmaking queue. # Details: Implement `Room` model in MongoDB and cache active room states in Redis. Create API endpoints for `createRoom`, `joinRoom`, `leaveRoom`. For matchmaking, use a Redis List or Set as a queue; when two players are in the queue, create a room for them. Implement room code generation (6-digit numeric). Handle host permissions and room configuration (e.g., round time limit, AI difficulty). # Test Strategy: Unit test room creation with various configs (password, no password). Test joining valid/invalid rooms. Simulate multiple users joining a matchmaking queue and verify room creation. Test room status updates in Redis.