Skip to content

[FOSSOVERFLOW-25] Feat: Real-time Quiz System Overhaul -1v1 Matchmaking & Multiplayer Lobby #135

@aviralsaxena16

Description

@aviralsaxena16

🚀 Feature Request: Real-time Competitive Quiz Architecture

This is a core architectural update. The logic involves real-time state management via Redis and WebSockets. You must coordinate with the mentor before starting implementation to understand the existing Redis/Socket setup.


📝 Description

We are overhauling the Quiz Section to create a clean, unified competitive experience.
Currently, we have a Solo Quiz (Gemini-generated questions stored in DB).
We need to fix/implement the 1v1 PvP Mode and introduce a new Mass Multiplayer (Lobby) Mode.

Both new modes must reuse the existing question bank (which includes AI-generated questions) and utilize Redis for low-latency state management.

🎯 Key Features & Requirements

1. 1v1 PvP Mode (Fix & Implement)

  • Matchmaking:
    • Random: Use Redis queues to match two online users instantly.
    • Invite: Ability to generate a link/code to play against a specific friend.
  • Gameplay:
    • Both players see the same set of 5 Questions (fetched from existing DB).
    • Win Condition: Player with the most correct answers wins.
    • Tie-Breaker: If scores are equal, the player with the faster total time wins.
  • Rewards:
    • Users earn "Coins" for every individual question solved correctly, regardless of match outcome.

2. "Battle Royale" Lobby Mode (New Feature)

  • Capacity: Support 20-30 concurrent users in a single lobby.
  • Gameplay:
    • All users face the same set of 10 Questions.
    • Questions are served synchronously (everyone moves to Q2 at the same time, or at their own pace—coordinate with mentor).
  • Live Leaderboard:
    • A leaderboard must be displayed and updated via Sockets after every question.
    • Shows current rank based on score and speed.
  • Final Results: A podium display at the end of the 10 questions.

3. Shared Infrastructure & Rewards

  • Question Bank: All modes (Solo, 1v1, Lobby) must pull from the central question collection (Gemini-generated).
  • Concurrency: The system must handle state (scores, active players) using Redis to ensure speed.
  • Coin System: Integrate with the user profile to credit coins immediately upon correct answers.

🛠️ Technical Implementation

  • Frontend: Next.js (React).
  • Real-time Engine: Socket.io (or similar) for live score updates and game state syncing.
  • State/Queue: Redis (Critical for 1v1 queues and Lobby leaderboards).
  • Database: Firebase (Persistent storage for Questions and User Coin Balances).

✅ Acceptance Criteria

  • 1v1: Random matchmaking works via Redis queue.
  • 1v1: Friend invite system works.
  • 1v1: Winner is correctly determined (Score > Time).
  • Lobby: Can support 20+ users simultaneously without lag.
  • Lobby: Live leaderboard updates correctly after each question.
  • General: Coins are credited to the user's DB for every correct answer.
  • General: Questions are correctly fetched from the existing mixed DB source.

🏷️ Labels

Foss Overflow advanced backend redis sockets gamification

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions