Skip to main content
Showdown Trivia Game Interface

What is Showdown Trivia?

Showdown Trivia is a web-based real-time multiplayer trivia game platform where players compete head-to-head in fast-paced trivia competitions. Challenge your friends or join random players in trivia battles across multiple categories, with customizable game settings for endless entertainment. The platform leverages WebSocket technology to deliver instant, synchronized gameplay where every second counts. Create your own game rooms, customize difficulty and categories, or join existing games to test your knowledge against other players.

Get Started

Quickstart Guide

Get up and running with your first trivia game in minutes

Live Demo

Try out Showdown Trivia in action (may take a moment to wake up)

Source Code

Explore the codebase and contribute to the project

Deployment

Deploy your own instance with Docker or from source

Key Features

Experience synchronized, real-time trivia competitions powered by WebSocket connections. All players see questions simultaneously, and answers are processed instantly with live score updates.
// WebSocket hub manages all active game rooms
type Hub struct {
    Logger *slog.Logger
    rooms  RoomList
    m      *metrics.Metrics
}
Secure user registration and authentication system with password hashing and session management using Gorilla sessions.
// User signup with secure password hashing
hashedPassword, err := hashPassword(form.Password)
u := user.NewUser(form.Username, form.Email, hashedPassword)
_, err = userService.AddUser(u)
Create games tailored to your preferences:
  • Categories: Choose from 32+ trivia categories from the Open Trivia Database
  • Question Count: Set 1-50 questions per game
  • Timer: Adjust answer time from 2-20 seconds per question
// Game configuration validation
if category < 0 || category > 32 {
    f.Errors["category"] = "category can't be less 0 or greater than 32"
}
if amount < 1 || amount > 50 {
    f.Errors["amount"] = "number of questions can't be less than 1 or greater than 50"
}
if time < 2 || time > 20 {
    f.Errors["timer"] = "timer can't be less than 2 or greater than 20"
}
Real-time score updates throughout the game. Players earn points for correct answers, with instant feedback after each question.
// Score calculation at end of each question
func (g *Game) endOfQuestion(question entities.Question, answers map[string]string) {
    for username, answer := range answers {
        if question.CorrectAnswer == answer {
            g.score(username)
        }
    }
}
Create private game rooms or browse and join active public games. Room owners control when games start and can configure settings.
// List all available game rooms
func (h *Hub) ListRooms() []webentities.RoomData {
    var rooms []webentities.RoomData
    for _, r := range h.rooms {
        if r.Game.GameStarted {
            continue
        }
        rooms = append(rooms, webentities.RoomData{
            Owner:   r.owner,
            Id:      r.Id,
            Players: r.getUsers(),
        })
    }
    return rooms
}
Built-in metrics collection for production monitoring:
  • Active WebSocket connections tracking
  • Request duration histograms for game creation
  • Exposed metrics endpoint at /metrics
// Metrics tracked by the application
type Metrics struct {
    WebsocketConns prometheus.Gauge      // Active WebSocket connections
    ReqDuration    *prometheus.HistogramVec // Request duration for game creation
}

Technology Stack

Showdown Trivia is built with modern, performant technologies:

Go

High-performance backend with net/http standard library

HTMX

Dynamic UI updates without heavy JavaScript frameworks

WebSockets

Real-time bidirectional communication via gorilla/websocket

MongoDB

Persistent storage for user data and game history

Prometheus

Production-ready metrics and monitoring

Templ

Type-safe Go templating for HTML generation

Architecture Overview

The application follows a clean architecture pattern with clear separation of concerns:
├── cmd/web/              # Application entry point
├── internal/
│   ├── core/            # Business logic
│   │   ├── game/        # Game mechanics and state management
│   │   ├── question/    # Question service interfaces
│   │   └── user/        # User service interfaces
│   ├── web/             # HTTP handlers, routes, WebSocket hub
│   ├── repository/      # Data persistence layer
│   ├── trivia_api/      # Open Trivia DB integration
│   └── config/          # Configuration management
├── cmd/web/ # Application entry point ├── internal/ │ ├── core/ # Business logic │ │ ├── game/ # Game mechanics and state management │ │ ├── question/ # Question service interfaces │ │ └── user/ # User domain logic │ ├── web/ # HTTP handlers and WebSocket │ │ ├── handlers/ # HTTP request handlers │ │ ├── ws/ # WebSocket hub and client management │ │ ├── metrics/ # Prometheus metrics │ │ └── views/ # Templ templates │ ├── repository/ # Data access layer │ ├── trivia_api/ # Open Trivia DB integration │ └── config/ # Configuration management

<Note>
  **Question Source**: Trivia questions are fetched from the [Open Trivia Database API](https://opentdb.com), providing a vast collection of verified trivia questions across multiple categories and difficulty levels.
</Note>

## What's Next?

Ready to start playing? Follow our [Quickstart Guide](/quickstart) to set up your own instance and start your first game.

Looking to contribute or customize the platform? Check out the [source code on GitHub](https://github.com/Lafetz/multiplayer-trivia).

Build docs developers (and LLMs) love