An open source version of kahoot
Find a file
Joey Yakimowich-Payne af21f2bcdc
feat: add comprehensive game configuration system
Add a centralized game configuration system that allows customizable
scoring mechanics and game rules. Users can now set default game
configurations that persist across sessions, and individual quizzes
can have their own configuration overrides.

## New Features

### Game Configuration Options
- Shuffle Questions: Randomize question order when starting a game
- Shuffle Answers: Randomize answer positions for each question
- Host Participates: Toggle whether the host plays as a competitor
  or spectates (host now shows as 'Spectator' when not participating)
- Streak Bonus: Multiplied points for consecutive correct answers,
  with configurable threshold and multiplier values
- Comeback Bonus: Extra points for players ranked below top 3
- Wrong Answer Penalty: Deduct percentage of max points for incorrect
  answers (configurable percentage)
- First Correct Bonus: Extra points for the first player to answer
  correctly on each question

### Default Settings Management
- New Settings icon in landing page header (authenticated users only)
- DefaultConfigModal for editing user-wide default game settings
- Default configs are loaded when creating new quizzes
- Defaults persist to database via new user API endpoints

### Reusable UI Components
- GameConfigPanel: Comprehensive toggle-based settings panel with
  expandable sub-options, tooltips, and suggested values based on
  question count
- DefaultConfigModal: Modal wrapper for editing default configurations

## Technical Changes

### Frontend
- New useUserConfig hook for fetching/saving user default configurations
- QuizEditor now uses GameConfigPanel instead of inline toggle checkboxes
- GameScreen handles spectator mode with disabled answer buttons
- Updated useGame hook with new scoring calculations and config state
- Improved useAuthenticatedFetch with deduped silent refresh and
  redirect-once pattern to prevent multiple auth redirects

### Backend
- Added game_config column to quizzes table (JSON storage)
- Added default_game_config column to users table
- New PATCH endpoint for quiz config updates: /api/quizzes/:id/config
- New PUT endpoint for user defaults: /api/users/me/default-config
- Auto-migration in connection.ts for existing databases

### Scoring System
- New calculatePoints() function in constants.ts handles all scoring
  logic including streaks, comebacks, penalties, and first-correct bonus
- New calculateBasePoints() for time-based point calculation
- New getPlayerRank() helper for comeback bonus eligibility

### Tests
- Added tests for DefaultConfigModal component
- Added tests for GameConfigPanel component
- Added tests for QuizEditor config integration
- Added tests for useUserConfig hook
- Updated API tests for new endpoints

## Type Changes
- Added GameConfig interface with all configuration options
- Added DEFAULT_GAME_CONFIG constant with sensible defaults
- Quiz type now includes optional config property
2026-01-14 01:43:23 -07:00
authentik Phase 1 done 2026-01-13 14:14:30 -07:00
components feat: add comprehensive game configuration system 2026-01-14 01:43:23 -07:00
docs Add ability to edit AI generated content 2026-01-13 23:37:08 -07:00
hooks feat: add comprehensive game configuration system 2026-01-14 01:43:23 -07:00
scripts Phase 1 done 2026-01-13 14:14:30 -07:00
server feat: add comprehensive game configuration system 2026-01-14 01:43:23 -07:00
services feat: add comprehensive game configuration system 2026-01-14 01:43:23 -07:00
src/config Add user setup config 2026-01-13 16:18:46 -07:00
tests feat: add comprehensive game configuration system 2026-01-14 01:43:23 -07:00
.env.example Complete stage 7 2026-01-13 20:21:47 -07:00
.gitignore Add ability to edit AI generated content 2026-01-13 23:37:08 -07:00
ai-todo.md Complete stage 7 2026-01-13 20:21:47 -07:00
App.tsx feat: add comprehensive game configuration system 2026-01-14 01:43:23 -07:00
Caddyfile.example Complete stage 7 2026-01-13 20:21:47 -07:00
constants.ts feat: add comprehensive game configuration system 2026-01-14 01:43:23 -07:00
docker-compose.caddy.yml Complete stage 7 2026-01-13 20:21:47 -07:00
docker-compose.yml Add document AI gen support 2026-01-13 22:48:43 -07:00
features.md Add ability to edit AI generated content 2026-01-13 23:37:08 -07:00
IMPLEMENTATION_PLAN.md Complete stage 7 2026-01-13 20:21:47 -07:00
index.html Configurable theme, change default to blue 2026-01-13 11:04:52 -07:00
index.tsx Phase 6 complete 2026-01-13 16:52:57 -07:00
metadata.json Initial commit 2026-01-13 07:23:30 -07:00
package-lock.json Add tests and edit works 2026-01-13 23:52:04 -07:00
package.json Add tests and edit works 2026-01-13 23:52:04 -07:00
README.md Complete stage 7 2026-01-13 20:21:47 -07:00
tasks.md Rebrand to kaboot 2026-01-13 10:59:50 -07:00
tsconfig.json Add tests and edit works 2026-01-13 23:52:04 -07:00
types.ts feat: add comprehensive game configuration system 2026-01-14 01:43:23 -07:00
vite.config.ts Add tests and edit works 2026-01-13 23:52:04 -07:00

GHBanner

Kaboot

Kaboot is an AI-powered quiz party game inspired by Kahoot. It leverages the Google Gemini API to instantly generate engaging quizzes on any topic, allowing users to host and join multiplayer games with ease.

Features

  • AI Quiz Generation: Create full quizzes in seconds by simply providing a topic or prompt using Google Gemini.
  • Real-time Multiplayer: Host games and have players join via game pins using Peer-to-Peer technology.
  • Single-player Arcade Mode: Play against AI bots to sharpen your skills.
  • Secure Authentication: Integrated with Authentik for robust OIDC-based user management.
  • Quiz Library: Save, manage, and reuse your AI-generated quizzes.
  • Dynamic UI: A premium, responsive interface built with React, Framer Motion, and Lucide.

Architecture

Kaboot is built with a modern decoupled architecture:

  • Frontend: React (Vite) with PeerJS for real-time communication.
  • Backend: Node.js Express server managing the quiz database and session state.
  • Database: SQLite (Better-SQLite3) for lightweight, reliable data storage.
  • Identity Provider: Authentik (running in Docker) providing OIDC authentication.
  • Infrastructure: Redis and PostgreSQL (supporting Authentik).
  • AI Engine: Google Gemini API for intelligent content generation.

Prerequisites

Before you begin, ensure you have the following installed:

  • Docker & Docker Compose: For running the backend services and authentication.
  • Node.js (v18+): For local frontend development.
  • Google Gemini API Key: Required for AI quiz generation.

Quick Start

The fastest way to get Kaboot running is using Docker Compose.

1. Initialize Environment

Run the setup script to generate necessary secrets and create your .env file:

chmod +x scripts/setup.sh
./scripts/setup.sh

2. Configure Gemini API

Open the newly created .env file and add your Gemini API key:

GEMINI_API_KEY=your_api_key_here

3. Start Services

Launch the entire stack using Docker Compose:

docker compose up -d

This will start:

  • Authentik (Port 9000)
  • PostgreSQL & Redis (Internal)
  • Kaboot Backend (Port 3001)

4. Setup Authentication

Follow the Authentik Setup Guide to configure the OIDC provider.

Development Setup

If you want to run the frontend in development mode with hot-reloading:

  1. Install Dependencies:

    npm install
    
  2. Run Development Server:

    npm run dev
    

    The frontend will be available at http://localhost:5173.

Configuration

Kaboot uses environment variables for configuration. Refer to .env.example for a complete list.

Variable Description Default
KABOOT_BACKEND_PORT Port for the Express backend 3001
AUTHENTIK_PORT_HTTP Port for Authentik web interface 9000
GEMINI_API_KEY Your Google Gemini API key (Required)
CORS_ORIGIN Allowed origin for API requests http://localhost:5173
PG_PASS PostgreSQL password for Authentik (Generated)
AUTHENTIK_SECRET_KEY Secret key for Authentik (Generated)

Testing

Backend Tests

To run the backend test suite:

cd server
npm install
npm test

Documentation

Troubleshooting

  • Authentik Initial Setup: If you can't access the setup page, ensure authentik-server container is healthy using docker compose ps.
  • CORS Errors: Verify that CORS_ORIGIN in your .env matches your frontend URL.
  • Gemini API Issues: Ensure your API key is valid and has sufficient quota. Check the browser console for specific error messages from the GenAI SDK.
  • Database Locked: If you encounter SQLite locking issues, ensure only one instance of the backend is writing to the database volume.

View your app in AI Studio: https://ai.studio/apps/drive/1N0ITrr45ZWdQvXMQNxOULCmJBQyaiWH8