Skip to content

Repository files navigation

PuzzleLab

A real-time quiz platform built on .NET and PostgreSQL, engineered to handle 1,000 concurrent users. Quiz sessions are synchronized live via SignalR, while post-session processing is offloaded to a RabbitMQ-backed background worker — keeping the API responsive under load.

Highlights

  • 1,000 concurrent users — Kestrel + SignalR keep all clients in sync without polling
  • Event-driven finalization — quiz results are processed asynchronously via RabbitMQ, decoupling submission from scoring
  • Server-authoritative timingTimeHub broadcasts server time to every client, preventing clock-skew cheating
  • Clean Architecture + CQRS — domain logic is isolated from infrastructure; every operation is a MediatR command or query
  • Fully containerized — one docker compose up spins up the entire stack

Architecture

PuzzleLab/
├── src/
│   ├── PuzzleLab.API              # ASP.NET Core REST API + SignalR hub (port 3000)
│   ├── PuzzleLab.Web              # Blazor frontend (port 8000)
│   ├── PuzzleLab.Domain           # Entities, repository interfaces, domain events
│   ├── PuzzleLab.Application      # MediatR command/query handlers (CQRS)
│   ├── PuzzleLab.Infrastructure   # EF Core, PostgreSQL, RabbitMQ, JWT
│   ├── PuzzleLab.Shared           # Shared DTOs
│   └── PuzzleLab.BackgroundWorker # Async quiz finalization consumer
└── diagram/                       # Entity Relationship Diagram

How it fits together

Browser (Blazor)
    │  REST + SignalR
    ▼
PuzzleLab.API ──── PostgreSQL
    │
    │  publishes domain event on quiz completion
    ▼
RabbitMQ Queue
    │
    ▼
BackgroundWorker ── finalizes scores ──► PostgreSQL

Tech Stack

Layer Technology
Backend ASP.NET Core 8.0
Frontend Blazor (Server-Side Rendering)
Database PostgreSQL
ORM Entity Framework Core 9.0
Messaging RabbitMQ
Real-time SignalR
Auth JWT Bearer
Containerization Docker Compose

Getting Started

Run with Docker (recommended)

docker compose up --build
Service Port Description
Web (Blazor) 8000 Frontend UI
API 3000 REST API + SignalR hub
Background Worker Quiz finalization consumer
PostgreSQL 5432 Database
RabbitMQ 5672 / 15672 Message broker + management UI

Open http://localhost:8000. The database is seeded with sample users, questions, and quizzes on first run.

Local Development

Requirements: .NET SDK 8.0 (see global.json), PostgreSQL, RabbitMQ

dotnet run --project src/PuzzleLab.API
dotnet run --project src/PuzzleLab.Web
dotnet run --project src/PuzzleLab.BackgroundWorker

Features

Admin

  • Manage users and assign quizzes
  • Create question packages with optional image support
  • Schedule quizzes with enforced start/end time windows
  • View results and per-participant statistics

User

  • View and take assigned quizzes within their scheduled window
  • Real-time countdown timer synchronized from the server
  • Personal quiz history and performance statistics

API Documentation

Swagger UI: http://localhost:3000/swagger

Database Schema

See diagram/PuzzleLab_ERD.jpg for the full entity relationship diagram.

About

Real-time quiz platform with .NET, SignalR, and PostgreSQL, built for high concurrency and async scoring.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages