A real-time quiz application inspired by Mentimeter, enabling admins to create and manage quizzes while students participate live via WebSockets. This backend service handles user authentication, quiz management, and real-time interactions using Node.js and MongoDB.
- Create quizzes,
- add questions,
- initiate live sessions,
- show questions, and
- display results.
- Join live quizzes,
- receive questions in real-time,
- submit answers,
- and see personal scores and overall results.
- Powered by WebSockets for seamless, instant updates.
- JWT for authentication,
- bcrypt for password hashing,
- and Zod for schema validation.
- MongoDB with Mongoose
- JWT, bcrypt
- Zod, WebSocket (ws)
The system uses in-memory state to manage live quiz sessions, tracking users, questions, answers, and scores. Admins control the flow by starting quizzes, showing questions, and revealing results, while students submit answers and receive acknowledgments.
| Role | Events |
|---|---|
| Admin | START_QUIZ, SHOW_QUESTION, SHOW_RESULT |
| Student | SUBMIT_ANSWER |
MONGO_URI: MongoDB connection string JWT_SECRET: Secret for JWT signing
`npm start`Server runs on http://localhost:3000. Use Postman for API testing and wscat for WebSockets.
- Register as admin/student via the signup endpoint.
- Login to obtain a JWT token.
- Admins: Create and manage quizzes via API, then initiate and control live sessions over WebSocket.
- Students: Connect to the WebSocket with JWT and quiz ID to join and participate.