A full-featured online quiz application with multiplayer support built with Next.js, TypeScript, and SQLite.
This application was completely generated by AI. There is no guarantee that the code will work correctly or is secure. Use at your own risk. This project is provided as-is for educational and experimental purposes.
Internationalization: Supports English (default) and German with per-quiz language settings.
This project is licensed under the MIT License - see the LICENSE file for details.
- Multi-Language Support: English (default) and German
- Per-Quiz Language Settings: Each quiz can have its own language, independent of the global interface language
- Global Language Selector: Users can switch the admin interface language in the admin section
- Language Persistence: User's language preference is saved in cookies
- Automatic Language Application: Quiz gameplay automatically uses the quiz's configured language
- Dynamic Browser Titles: Shows quiz names in the browser tab
- Custom Favicon: Purple-blue gradient icon matching the app design
- Responsive Design: Optimized for desktop and mobile
- Mobile-Optimized: Color-coded answers and full-screen views
- Quiz Management: Create, edit, and delete quizzes
- Question Management: Add, edit, and delete questions with optional title, description, and image
- Image Upload: Upload images directly (stored locally)
- Answer Management: Each question has 2-4 possible answers, with flexible configuration and image support
- Quiz Overview: Display all created quizzes with question count and metadata
- Session Management: View and manage all active multiplayer game sessions
- Real-time session monitoring with automatic refresh
- Individual and bulk session deletion
- Mark Player to Win: Special feature for celebrations - mark a player who will automatically win (crown emoji visible only in admin)
- Quiz Selection: Browse and select available quizzes
- Interactive Gameplay: Answer questions one by one with visual feedback
- Scoring System: 1 point for each correct answer
- Progress Indicator: Live progress bar during gameplay
- Results Screen: Final score and percentage with options to retry or choose another quiz
- Host Interface: Host games, generate QR codes, view real-time player list
- Player Join: Join via QR code or 6-digit session code
- Real-time Updates: Server-Sent Events (SSE) for live synchronization between host and players
- Flexible Control: Host can manually reveal answers at any time, even if not all players have answered
- Live Scoreboard: Real-time leaderboard during gameplay
- Final Rankings: Final leaderboard with avatars and scores
- Avatar System: Customizable avatars with "Switch Avatar" button - players can change their avatar in the waiting room and it persists throughout the game
- Framework: Next.js 14+ (App Router)
- Language: TypeScript
- Database: SQLite with Prisma ORM
- Real-time: Server-Sent Events (SSE)
- Styling: Tailwind CSS
- Internationalization: next-intl
- QR Codes: qrcode library
- Avatars: Multiavatar library
- Deployment: Docker & Docker Compose
- Node.js 18+
- npm or yarn
- Clone the repository
- Install dependencies:
npm install- Create
.envfile (copy from.env.example):
cp .env.example .env- Update the
.envfile with your configuration:
DATABASE_URL="file:./prisma/dev.db"
NEXT_PUBLIC_APP_URL="http://localhost:3210"
DEFAULT_LANG="en" # Default language: 'en' (English) or 'de' (German)
ADMIN_PASSPHRASE="" # Optional passphrase for admin access
- Set up the database:
npx prisma migrate dev
npx prisma generate- Start the development server:
npm run dev- Open http://localhost:3210 in your browser
/app # Next.js App Router pages and API routes
/admin # Quiz management interface
/game # Single and multiplayer game modes
/api # REST and SSE endpoints
/components # Shared React components
/lib # Utility functions and configurations
/locales # i18n translation files (en.json, de.json)
/prisma # Database schema and migrations
/public/uploads # User-uploaded images
- id (primary key)
- title
- description (optional)
- language (default: 'en', supports 'en' and 'de')
- createdAt
- updatedAt
- id (primary key)
- quizId (foreign key)
- title (optional)
- questionText
- description (optional)
- imageUrl (optional)
- orderIndex
- createdAt
- id (primary key)
- questionId (foreign key)
- answerText
- isCorrect
- orderIndex
- id (primary key)
- quizId (foreign key)
- sessionCode (6-digit unique code)
- status (waiting, in_progress, finished)
- currentQuestion (index)
- createdAt, startedAt, finishedAt
- id (primary key)
- sessionId (foreign key)
- playerName
- score
- joinedAt
- isConnected
- markedToWin (boolean, default: false)
- id (primary key)
- sessionId (foreign key)
- playerId (foreign key)
- questionId (foreign key)
- answerId (foreign key)
- answeredAt
- isCorrect
- timeToAnswer
- Navigate to
/adminin your browser - Click "Create New Quiz"
- Enter title and optional description
- Select the quiz language (English or German)
- Click "Create Quiz"
- Add questions with optional title, description, and image
- Optionally upload an image for each question
- Enter 2-4 answers and mark the correct answer
Note: The quiz language setting determines what language will be used during gameplay, independent of the admin interface language.
- From the homepage, click "Browse Games" or navigate to
/games - Select a quiz from available options
- Choose "Play Solo"
- Read each question and click your answer
- Get immediate feedback (green = correct, red = incorrect)
- Progress through all questions
- View your final score
Note: The interface will use the language configured for the selected quiz.
As Host:
- From the homepage, click "Browse Games" or navigate to
/games - Select a quiz and choose "Host Multiplayer"
- Share the QR code or 6-digit session code with players
- Wait for all players to join
- Start the game
- Manually reveal answers or wait until all have answered
- Proceed to next question
- View final leaderboard at the end
As Player:
- On the homepage, enter the 6-digit session code or scan the QR code
- Enter your name (2-20 characters)
- Wait for the host to start the game
- Answer questions as quickly as possible
- View your position in the leaderboard at the end
Note: All players will see the interface in the language configured for the quiz being played.
When you make changes to the Prisma schema:
npx prisma migrate dev --name description_of_changesnpx prisma generatenpx prisma studioThis project uses Semantic Versioning (SemVer) for version management.
- Current Version: v1.1.0
- Release Notes: See CHANGELOG.md for detailed release notes
- GitHub Releases: View all releases
Versions follow the MAJOR.MINOR.PATCH format:
- MAJOR (1.0.0 → 2.0.0): Breaking changes or major new features
- MINOR (1.0.0 → 1.1.0): New features, backwards-compatible
- PATCH (1.0.0 → 1.0.1): Bug fixes, backwards-compatible
Note: The main branch is protected and requires pull requests.
There are two ways to create a release:
The easiest way to create a release is through the GitHub Actions workflow:
- Go to Actions tab in GitHub
- Select "Automated Release" workflow
- Click "Run workflow"
- Choose version type (patch/minor/major)
- Optionally enable dry run to test
- Click "Run workflow"
The workflow will automatically:
- Bump version in
package.json - Validate CHANGELOG entry exists
- Create release PR with extracted notes
- Merge PR (or wait for approval)
- Create and push git tag
- Trigger Docker build and GitHub release
Documentation: See .github/workflows/RELEASE.md for detailed instructions
Requirements:
- CHANGELOG.md must be updated with release notes
- All tests must pass
Alternatively, use the command-line release script:
# Patch release (bug fixes): 1.0.0 → 1.0.1
./scripts/release.sh patch
# Minor release (new features): 1.0.0 → 1.1.0
./scripts/release.sh minor
# Major release (breaking changes): 1.0.0 → 2.0.0
./scripts/release.sh major
# Preview changes without committing
./scripts/release.sh patch --dry-runThe release script will:
- Ensure you're on the latest main branch
- Update
package.jsonversion - Verify
CHANGELOG.mdhas been updated - Run tests
- Create a release branch and commit
- Create and merge a Pull Request to main (using admin privileges)
- Create and push an annotated git tag
- Trigger the CI/CD pipeline
Requirements:
- GitHub CLI (
gh) must be installed and authenticated - Repository admin access (for merging protected branch)
- All tests must pass
Important: Before creating a release with either method, update CHANGELOG.md with your changes following the Keep a Changelog format.
Every release automatically triggers a GitHub Actions workflow that:
- Builds multi-platform Docker images (linux/amd64, linux/arm64)
- Publishes to GitHub Container Registry (ghcr.io)
- Creates version-specific tags (e.g.,
v1.0.0,1.0.0,1.0,1) - Updates the
latesttag - Automatically creates a GitHub Release with:
- Release notes extracted from CHANGELOG.md
- Docker image pull commands
- Supported architectures information
Monitor builds: GitHub Actions
This application is ready to deploy using Docker. You can either use pre-built images from GitHub Container Registry or build locally.
Pre-built Docker images are automatically published to GitHub Container Registry on every commit to main.
- Pull the latest image:
docker pull ghcr.io/splagemann/quiz-app:latest- (Optional) Configure environment variables by creating a
.envfile:
cp .env.example .env
# Edit .env to set DEFAULT_LANG and ADMIN_PASSPHRASE if needed- Run with Docker Compose:
# The docker-compose.yml is already configured to use pre-built images
docker compose up -d- The application will be available at
http://localhost:3210
Available Image Tags:
latest- Latest stable build from main branchmain- Latest commit on main branchv1.0.0- Specific version tagssha-abc1234- Specific commit builds
- Clone the repository:
git clone git@github.com:splagemann/quiz-app.git
cd quiz-app- Edit
docker-compose.ymlto use local build:
# Comment out the 'image' line
# image: ghcr.io/splagemann/quiz-app:latest
# Uncomment the 'build' section
build:
context: .
dockerfile: Dockerfile- Build and start the application:
docker compose up -d --build- The application will be available at
http://localhost:3210
- Build the Docker image:
docker build -t quiz-app .- Create a volume for persistent data:
docker volume create quiz-data
docker volume create quiz-uploads- Run the container:
docker run -d \
--name quiz-app \
-p 3210:3000 \
-e DATABASE_URL=file:/app/data/quiz.db \
-e NEXT_PUBLIC_APP_URL=http://localhost:3210 \
-e DEFAULT_LANG=en \
-e ADMIN_PASSPHRASE="" \
-v quiz-data:/app/data \
-v quiz-uploads:/app/public/uploads \
--restart unless-stopped \
quiz-appView logs:
docker-compose logs -f
# or
docker logs -f quiz-appStop the application:
docker-compose down
# or
docker stop quiz-appUpdate the application:
git pull
docker-compose down
docker-compose up -d --build- Update
NEXT_PUBLIC_APP_URLto your actual domain - Use a reverse proxy (nginx/traefik) with SSL/TLS for HTTPS
- Set up regular backups of the Docker volumes (database and uploads)
- Mount the volumes to specific host directories for easier backup:
volumes: - ./data:/app/data - ./uploads:/app/public/uploads