MiniQuiz is a small full-stack trivia game with a TypeScript Express backend, a React + Vite frontend, and SQLite persistence via Prisma.
- Start timed quiz sessions with configurable duration.
- Answer multiple-choice questions and receive instant validation and explanations.
- Server-authoritative scoring with session persistence.
- Submit high scores to a persistent leaderboard.
- Auto-generated Swagger reference at
/api/docs. - Shared TypeScript types between server and client.
miniquiz-vibecoded/
package.json # root scripts (install, dev, build, test)
.env.example # environment variables
server/ # Express API + Prisma ORM
web/ # React + Vite frontend
-
Environment
cp .env.example server/.env cp .env.example .env
Adjust
DATABASE_URLorPORTif needed. -
Install dependencies
npm install npm run prisma:generate npm run prisma:migrate npm run prisma:seed
-
Run in development
npm run dev
- Backend: http://localhost:3010
- Frontend: http://localhost:5170 (Vite proxies
/apito the backend).
-
Build for production
npm run build npm start
Express serves the static client from
server/dist/clientwhenCLIENT_DISTis configured (defaults are already wired inindex.ts).
- Run all tests:
npm test - Backend tests (
server): Vitest + Supertest hit the Express app. Tests bootstrap the SQLite schema automatically and write toserver/prisma/test.db. - Frontend tests (
web): Vitest + Testing Library; DOM helpers are set up viaweb/vitest.setup.ts.
- Swagger docs: http://localhost:3010/api/docs
- Question options are JSON-encoded arrays in SQLite and never expose
correctIndexto the client. POST /api/answers/validateaccepts an optionalsessionId. When provided, the server records authoritative correctness for that session.POST /api/scores/applyignores the client-providedcorrectflag and recomputes scoring using stored validation data.- Scores award +10 points per correct answer and keep
totalAnswered,correctCount, andcurrentScorein sync with theAnsweredtable.
/startstarts a 60-second session and redirects to/play./playloads question batches (3 at a time), validates answers, and forwards results to/update./updateapplies scoring, shows the live timer and score, and routes to the next question or/summary./summarydisplays the final score and lets the user submit their name to the leaderboard./leaderboardshows the top 20 scores ordered by score (DESC) and timestamp (ASC).
- The Prisma seed script (
npm run prisma:seed) loads a dozen starter questions so the game works immediately. - Static client assets are served automatically when they exist; otherwise Express hosts only the API.
- Shared API contracts live in
server/src/types/api.tsand are re-exported for the frontend atweb/src/types/api.ts.