Full-stack real-time quiz application where hosts can create quizzes, start live sessions, and players can join and answer questions with a live scoreboard.
| Area | Details |
|---|---|
| Frontend | React 19, TypeScript, Vite, Tailwind CSS 4 |
| Backend | Express 5, MySQL/MariaDB, Socket.IO |
| Realtime | Room-based quiz sessions, live user count, live scoreboard |
| Auth | Register/login with bcrypt, token-based socket identity |
| Media | Optional image upload for quiz questions |
- Quiz creation with multiple questions, options, timer, and correct answer
- Public/private quiz visibility
- Real-time host/admin/broadcast/player flow with Socket.IO rooms
- Live scoreboard updates during gameplay
- User registration and login
- Quiz dashboard for listing, editing, and deleting authored quizzes
- Image upload and file serving for quiz content
| Frontend | Backend |
|---|---|
| React 19 | Express 5 |
| TypeScript 5 | MySQL via mysql2 |
| Vite 7 | Socket.IO 4 |
| Tailwind CSS 4 | bcrypt, helmet, cors, express-rate-limit |
| react-router-dom 7 | express-validator, multer, jsonwebtoken |
- Node.js 20+
- npm
- MySQL 8+ or MariaDB 10+
git clone <repo-url>
cd quiz
cd client
npm install
cd ../server
npm install
# import database schema
mysql -u root -p < quiz.sqlCreate environment files (see Setup), then run backend and frontend.
git clone <repo-url>
cd quizcd client
npm install
cd ../server
npm installCreate a database (example name: quiz) and import:
mysql -u root -p < server/quiz.sqlCreate server/.env:
PORT=3001
CORS_ORIGIN=http://localhost:5173
DB_HOST=localhost
DB_USER=root
DB_PASSWORD=your_password
DB_NAME=quiz
JWT_SECRET=replace_with_a_long_random_secret
API_URL=http://localhost:3001/apiCreate client/.env:
VITE_API_URL=http://localhost:3001/api
VITE_SOCKET_URL=http://localhost:3001
VITE_URL=http://localhost:5173
VITE_GITHUB_URL=https://github.com/<your-profile>From the server folder:
node app.jsFrom the client folder:
npm run devhttp://localhost:5173
| Command | Description |
|---|---|
npm run dev |
Start Vite development server |
npm run build |
Type-check and build frontend |
npm run preview |
Preview production build |
npm run lint |
Run ESLint |
npm run format |
Format source files with Prettier |
| Command | Description |
|---|---|
npm start |
Starts Node using configured entry script |
npm run eslint |
Run ESLint |
npm run format |
Format server files with Prettier |
- Backend listens on
PORT. - Frontend reads API base URL from
VITE_API_URL. - Socket client connects through
VITE_SOCKET_URL. - CORS is restricted to
CORS_ORIGIN.
Base URL: /api
| Method | Path | Description |
|---|---|---|
POST |
/register |
Register a new user |
POST |
/login |
Login with username and password |
| Method | Path | Description |
|---|---|---|
POST |
/saveQuiz |
Save a new quiz |
POST |
/getQuizzes |
Get public quizzes and own quizzes |
POST |
/getQuizForEdit |
Load an authored quiz for editing |
POST |
/updateQuiz |
Update an authored quiz |
POST |
/deleteQuiz |
Delete an authored quiz |
POST |
/startQuiz |
Start a quiz session and create share URL |
POST |
/endQuiz |
End quiz session |
POST |
/getQuiz |
Get quiz questions from active session URL |
POST |
/getCode |
Resolve active URL to original quiz code |
POST |
/isQuizCodeAvailable |
Check whether a session URL is active |
| Method | Path | Description |
|---|---|---|
POST |
/getUserData |
Fetch username/email |
POST |
/updateUserData |
Update username/email |
| Method | Path | Description |
|---|---|---|
POST |
/upload |
Upload image for quiz content |
POST |
/delete |
Delete uploaded image |
GET |
/files/:filename |
Serve uploaded image |
adminCon,verifyAdmin,setAdminUsernamejoinRoom,userCon,broadcastConstartRoom,getQuiestions,nextTrigger,endOfQuizcorrectAns,scoreboardUpdate,usersUpdate
The schema is in server/quiz.sql.
Main tables:
user: registered usersquizzes: quiz questions grouped by quiz codeactive: active quiz sessions and generated join URLs
quiz/
|- client/
| |- src/
| | |- components/ # UI components (alerts, scoreboard)
| | |- pages/ # Route pages (home, login, create, host, quiz, etc.)
| | |- scripts/ # Socket + session helper hooks
| | `- types/ # Shared frontend types
| `- vite.config.ts
|- server/
| |- src/
| | |- db.js # Database connection
| | |- login.js # Auth endpoints
| | |- quiz_express.js # Quiz REST endpoints
| | |- quiz_socket.js # Socket.IO live quiz logic
| | `- file.js # Image upload/file endpoints
| |- images/ # Uploaded quiz images
| |- quiz.sql # Database schema
| `- app.js # Express + Socket.IO entry
`- README.md
- No automated test suite is configured yet.
- The server package
startscript may require aligning with the actual entry file if you prefernpm startovernode app.js.
Provided as-is for learning and portfolio purposes.