Skip to content

sebdanielsson/respondeo

Repository files navigation

Respondeo

A modern, full-stack quiz application built with Next.js 16, featuring OIDC authentication, real-time leaderboards, and a comprehensive REST API with API key authentication.

πŸ“š Documentation

Complete documentation is available at: /docs or online at https://quiz-app-docs.example.com

Quick links:

Features

  • 🎯 Quiz Management β€” Create, edit, and delete quizzes with multiple-choice questions
  • ✨ AI Generated Content β€” Use AI to help generate questions and answers
  • πŸ”Ž Image Browser β€” Browse and select images via Unsplash API integration
  • πŸ” OIDC Authentication β€” Secure sign-in via OpenID Connect (configurable provider)
  • πŸ‘‘ Role-Based Access β€” Admin permissions based on OIDC groups claim
  • πŸ† Leaderboards β€” Per-quiz and global leaderboards with rankings
  • ⏱️ Timed Quizzes β€” Optional time limits with timeout tracking
  • πŸ”„ Randomization β€” Shuffle questions for each attempt
  • πŸ”‘ API Keys β€” Programmatic access with scoped permissions and rate limiting
  • πŸ“– OpenAPI Docs β€” Interactive API documentation with Scalar
  • πŸŒ“ Dark Mode β€” System-aware theme switching

Tech Stack

  • Monorepo: Bun workspaces + Turborepo 2.4+
  • Framework: Next.js 16 (App Router, Turbopack)
  • Runtime: Bun
  • Database: PostgreSQL with Drizzle ORM (via bun:sql)
  • Cache: Valkey/Redis (optional, via Bun native client)
  • Auth: BetterAuth with OIDC + API Key plugins
  • UI: shadcn/ui (Base UI - Nova), Lucide Icons
  • Validation: Zod
  • AI: AI SDK with multi-provider support
  • Images: Unsplash API integration

Quick Start

Create a New App (Recommended)

The fastest way to get started is using create-respondeo-app:

# Using Bun (recommended)
bun create respondeo-app my-quiz-app

# Or with npm
npx create-respondeo-app my-quiz-app

# Or with pnpm
pnpm create respondeo-app my-quiz-app

This will:

  • Download the latest template
  • Install dependencies
  • Set up environment files
  • Show you the next steps

Then:

cd my-quiz-app
# Configure .env.local with your database and OIDC settings
bun run db:migrate    # Run database migrations
bun run dev           # Start development server

Manual Setup

If you prefer to clone the repository directly:

Prerequisites

  • Bun >= 1.3.8
  • PostgreSQL database
  • An OIDC provider (e.g., Keycloak, Auth0, Okta, Pocket ID)

Installation

# Clone and install
git clone <repository-url>
cd quiz-app
bun install

# Start database
docker compose up -d

# Configure environment
cp apps/web/.env.example apps/web/.env.local
# Edit apps/web/.env.local with your settings

# Run migrations
bun run db:migrate

# Start development server
bun run dev

Open http://localhost:3000 in your browser.

See Installation Guide for detailed setup instructions.

Configuration

Minimum required environment variables:

# App
NEXT_PUBLIC_APP_URL=http://localhost:3000

# Auth
BETTER_AUTH_SECRET=your-32-character-secret
BETTER_AUTH_URL=http://localhost:3000

# OIDC Provider
OIDC_ISSUER=https://your-oidc-provider.com
OIDC_CLIENT_ID=your-client-id
OIDC_CLIENT_SECRET=your-client-secret

# Database
DATABASE_URL=postgresql://user:password@localhost:5432/quiz_app

See Configuration Guide for all available options.

Development

bun run dev          # Start development server
bun run build        # Build for production
bun run start        # Start production server
bun run tsc          # Type checking
bun run lint         # Run ESLint
bun run format       # Format code
bun run db:migrate   # Run database migrations
bun run db:studio    # Open Drizzle Studio
bun test             # Run tests

See Scripts Reference for all available commands.

Project Structure

quiz-app/
β”œβ”€β”€ apps/
β”‚   β”œβ”€β”€ web/              # Main Next.js application
β”‚   └── docs/             # Fumadocs documentation site
β”œβ”€β”€ docs/                 # Documentation source (MDX files)
β”œβ”€β”€ package.json          # Workspace root
└── turbo.json            # Turborepo configuration

See Architecture Guide for detailed system architecture.

API

Respondeo provides a comprehensive REST API. Get started:

  1. Create an API key at /settings (admin only)
  2. Include it in the x-api-key header
  3. Explore endpoints in the API Reference

Interactive API documentation available at /docs when running the app.

Deployment

The app can be deployed to:

  • Vercel β€” Easiest, with Vercel Postgres
  • Docker β€” Use included compose.yaml
  • VPS β€” Any server with Bun and PostgreSQL
  • Railway, Fly.io β€” Docker-based platforms

See Deployment Guide for detailed instructions.

Documentation

This repository includes a Fumadocs-powered documentation site in apps/docs/.

To run the docs locally:

bun run dev --filter=docs

Visit http://localhost:3001

All documentation source files are in the /docs directory at the repository root.

License

MIT

Support

Scope Description
quizzes:read List and view quizzes, view leaderboards
quizzes:write Create, update, and delete quizzes (requires admin role)
attempts:read View quiz attempts
attempts:write Submit quiz attempts

Rate Limiting

API keys are rate-limited to 100 requests per minute by default. When rate-limited, the API returns a 429 Too Many Requests response.

API Documentation

Interactive API documentation is available at /docs powered by Scalar. The documentation includes:

  • πŸ“‹ Full endpoint reference with request/response schemas
  • πŸ§ͺ "Try it" functionality to test endpoints directly in the browser
  • πŸ“¦ Code snippets in multiple languages (JavaScript, Python, cURL, etc.)
  • πŸ” Authentication setup for API key configuration

Error Responses

All endpoints return consistent error responses:

{
  "error": "Error message describing what went wrong"
}
Status Code Description
400 Bad Request β€” Invalid input data
401 Unauthorized β€” Missing or invalid API key
403 Forbidden β€” Insufficient permissions
404 Not Found β€” Resource doesn't exist
429 Too Many Requests β€” Rate limit exceeded
500 Internal Server Error β€” Something went wrong

Scripts

Command Description
bun --bun run dev Start development server
bun --bun run build Build for production
bun --bun run start Start production server
bun --bun run tsc TypeScript type checking
bun --bun run lint Run ESLint
bun --bun run format Format code with Prettier
bun --bun run format:check Check code formatting with Prettier
bun --bun run stylelint Run Stylelint for CSS files
bun --bun run db:push Push schema changes to database
bun --bun run db:generate Generate migration files
bun --bun run db:migrate Run migrations
bun --bun run db:studio Open Drizzle Studio
bun test Run tests

License

MIT

Sponsor this project

Packages

 
 
 

Contributors