Skip to content
WareBarPublic

About

Quizzy is a quiz platform where you can pick a topic and play at your own pace, or bring everyone together for a live quiz night.

Topics

Resources

Stars

2 stars

Watchers

1 watching

Forks

Latest commit

 

History

91 Commits

Folders and files

Repository files navigation

Quizzy

Small questions. Bright minds. Good company.

Quizzy is a quiz platform where you can pick a topic and play at your own pace, or bring everyone together for a live quiz night. Hosts can build quizzes by hand or generate questions with AI, then review and edit everything before the quiz is created.

Status: MVP in active development. Quizzy is a Turborepo monorepo with a Fastify API (apps/server), a React web app (apps/client), and shared Zod schemas (packages/shared).


Table of contents


Features

Play your way

  • Solo play: pick a topic from the dashboard and play at your own pace.
  • Live quizzes: a host starts a session, shares a short join code, and signed-in players join together in real time.
  • A world of topics: questions are organized by category (science, history, art, music, geography, and more).

Learn as you play

  • Explanations: the correct choice can carry an explanation, so each answer is a small "aha" moment.
  • Points and bonuses: correct answers earn the question's points, with a speed bonus for the top 3 fastest players.
  • Leaderboards: each session has its own leaderboard, plus a weekly global board.

Host tools

  • Manual quiz creation: write your own questions and choices, set their order, and build a quiz in the dashboard.
  • AI quiz generation: describe a topic and the host gets a set of generated questions. The output is fully editable before the quiz is created: reword questions, change or remove choices, fix the correct answer, edit explanations, add or delete questions, and only then save. Nothing generated goes live until the host approves it.
  • Reusable quizzes: run the same quiz as many times as you like. Every run is its own session with its own participants and results.
  • Configurable timer: set seconds per question for each session. Countdowns are server-authoritative and recover after a refresh or reconnect; when time expires, the selected answer is submitted automatically after a short grace period, and both solo and live sessions advance automatically.
  • Quiz detail page: open any saved quiz to review play stats and browse questions, including who answered each choice.

How it works

Quizzy separates content from play:

Concept What it is
Quiz The reusable content: title, category, and an ordered list of questions. Source is MANUAL or AI.
Quiz session One play-through of a quiz: mode (SOLO or LIVE), join code, status, timer, participants, and results.
Participant A user inside one session. Answers belong to the participant, so replays and repeat sessions never collide.

A solo play is simply a session with one participant. A live game moves through LOBBY → ACTIVE → FINISHED.

Question progression is driven by server deadlines rather than browser-only intervals. The client derives remaining time from the persisted question start time and the session's configured seconds per question, then resyncs after a reconnect. Answers submitted after the grace window are rejected, duplicate submissions are ignored, and expired questions advance automatically.

Sessions use HttpOnly cookies for the access and refresh tokens. Refresh tokens rotate on use, and unsafe HTTP requests require an X-CSRF-Token header that matches the csrf_token cookie. WebSocket connections reuse the access cookie and verify the origin against CORS_ORIGINS.

The quiz detail page lives at /dashboard/quiz/:id. It reads GET /quiz/:id/stats and authenticated GET /quiz/:id/questions; answer review during a session uses GET /session/:id/answers.

The data model lives in apps/server/prisma/schema.prisma. For a visual overview, see apps/server/db.dbdiagram and apps/server/db.dbml.


Tech stack

Layer Technology
Monorepo Turborepo + pnpm workspaces
Language TypeScript
Backend Fastify 5
Validation Zod (shared schemas via @quizzy/shared)
Database PostgreSQL
Cache / rate limiting Redis
Object storage Supabase Storage for uploaded images
ORM Prisma 7 (with the pg driver adapter)
Authentication HttpOnly cookie sessions (JWT access + rotating refresh tokens), CSRF double-submit tokens, and bcryptjs
Frontend React 19 + Vite
Routing React Router 7
Data fetching TanStack Query
Styling / UI Tailwind CSS v4 + shadcn/ui (Base UI)
HTTP client Axios
AI generation Groq (groq-sdk), reviewed by the host before saving

Project structure

quizzy/
├── apps/
│   ├── client/              # React web app (Vite)
│   │   └── src/
│   │       ├── pages/       # Landing, auth, dashboard, host tools
│   │       ├── components/  # UI and shared components
│   │       ├── context/     # Auth and theme providers
│   │       └── hooks/       # Query and data hooks
│   └── server/              # Fastify API
│       ├── prisma/          # Schema and migrations
│       └── src/
│           ├── modules/     # auth, users, quiz, category, question, session, ai
│           ├── plugins/     # Prisma, JWT, Redis cache/rate limit, Supabase uploads, query builder
│           └── config/      # Environment validation
├── packages/
│   └── shared/              # Zod schemas, timer helpers, and shared types
├── turbo.json
├── pnpm-workspace.yaml
└── package.json

Getting started

Prerequisites

  • Node.js 20 or later
  • pnpm 10 or later (corepack enable is recommended)
  • PostgreSQL 14 or later
  • Redis for caching and rate limiting
  • A Supabase project with a storage bucket for uploaded images
  • A Groq API key for AI quiz generation

Installation

# 1. Clone the repository
git clone https://github.com/WareBar/quizzy.git
cd quizzy

# 2. Install all workspace dependencies
pnpm install

Environment variables

Create apps/server/.env from the example file:

cp apps/server/.env.example apps/server/.env

Then fill in the values:

NODE_ENV=development
PORT=3000
DATABASE_URL="postgresql://USER:PASSWORD@localhost:5432/quizzy"
JWT_SECRET="replace-with-a-long-random-secret"
ACCESS_TOKEN_TTL=15m
REFRESH_TOKEN_TTL=7d
CORS_ORIGINS=http://localhost:5173,http://127.0.0.1:5173
COOKIE_DOMAIN=
COOKIE_SECURE=false
COOKIE_SAME_SITE=lax
GROQ_API_KEY="your-groq-api-key"
SUPABASE_URL="https://your-project.supabase.co"
SUPABASE_KEY="your-supabase-key"
SUPABASE_BUCKET="quizzy"
REDIS_URL="redis://localhost:6379"

ACCESS_TOKEN_TTL, REFRESH_TOKEN_TTL, CORS_ORIGINS, and the COOKIE_* values have defaults, but setting them explicitly keeps local and deployed behavior aligned.

Optionally, point the client at the API by creating apps/client/.env:

VITE_BACKEND_URL=127.0.0.1:3000

The client prepends http for 127.0.0.1/localhost addresses and https otherwise. Do not include the protocol, trailing slash, or trailing whitespace in VITE_BACKEND_URL.

Never commit your .env files.

Cross-site deployment

The deployed web app and API are on different sites:

App Origin
Client https://quizzylo.vercel.app
API https://quizzyserver-production-c4124e03.up.railway.app

Use these API env values:

CORS_ORIGINS=https://quizzylo.vercel.app
COOKIE_SECURE=true
COOKIE_SAME_SITE=none
COOKIE_DOMAIN=

And this client env value:

VITE_BACKEND_URL=quizzyserver-production-c4124e03.up.railway.app

Because the origins differ, browser JavaScript cannot read the API host's csrf_token cookie. The client calls GET /auth/csrf, keeps the returned token in memory, and sends it as X-CSRF-Token on unsafe requests. Login, register, and refresh reuse the existing CSRF token instead of rotating it. This setup still relies on third-party cookies being allowed by the browser.

Database setup

# Apply migrations and generate the Prisma client
pnpm --filter @quizzy/server prisma:migrate
pnpm --filter @quizzy/server prisma:generate

Run the app

pnpm dev

Turbo starts both apps with hot reload:

Demo account

Use this dummy account to explore the dashboard and test the app:

Username Password
barrydam barrydam123

Useful commands

Command Description
pnpm dev Run all apps in development mode
pnpm build Build all apps (client and server type-check as part of the build)
pnpm lint Lint packages that define a lint task
pnpm typecheck Type-check packages that define a typecheck task
pnpm --filter @quizzy/server prisma:studio Open Prisma Studio

AI quiz generation

  1. The host chooses a topic, difficulty, and number of questions.
  2. The backend asks Groq to produce questions with choices, a correct answer, and an explanation for each.
  3. The host reviews the generated draft and can edit, replace, reorder, or delete anything.
  4. Only when the host confirms is the quiz saved, with source = AI.

Generated content is a draft, not a final result. The host is always the editor of record.


Roadmap

  • Turborepo monorepo with pnpm workspaces and shared Zod schemas
  • Fastify API with Prisma, PostgreSQL, and cookie-based JWT sessions
  • Frontend shell: landing page, auth, dashboard, and profile
  • Manual quiz creation with the question builder
  • AI quiz generation wired into the host review flow
  • Solo play flow
  • Live sessions with join codes and real-time updates
  • Per-session leaderboards and top-3 speed bonus
  • Weekly global leaderboard
  • Guest players (join with just a code and nickname)
  • Server-authoritative question timers with reconnect-safe countdowns and auto-advance
  • Auto-submit of the selected answer when time expires
  • Quiz detail page with stats and answer review
  • Redis-backed caching and rate limiting
  • Supabase image uploads

Contributing

This is currently a personal project. Issues and suggestions are welcome.

License

MIT


© 2025 Quizzy

About

Quizzy is a quiz platform where you can pick a topic and play at your own pace, or bring everyone together for a live quiz night.

Topics

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages