Skip to content

Latest commit

 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Live Quiz Platform


🚀 Project Overview


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.



✨ Key Features

Admin Capabilities:

  • Create quizzes,
  • add questions,
  • initiate live sessions,
  • show questions, and
  • display results.

Student Capabilities:

  • Join live quizzes,
  • receive questions in real-time,
  • submit answers,
  • and see personal scores and overall results.

Real-Time Communication:

  • Powered by WebSockets for seamless, instant updates.

Security:

  • JWT for authentication,
  • bcrypt for password hashing,
  • and Zod for schema validation.


Tech Stack

    Backend:

  • Node.js, Express.js

  • Database:

  • MongoDB with Mongoose
  • Auth & Security:

  • JWT, bcrypt
  • Validation & Real-Time:

  • Zod, WebSocket (ws)


🔌 WebSocket Integration

Connect via: ws://localhost:3000/ws?token=<JWT>&quizId=<quizId>

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.


Key Events

Role Events
Admin START_QUIZ,
SHOW_QUESTION,
SHOW_RESULT
Student SUBMIT_ANSWER

The flow ensures validation at each step:

  • users connect and are added to the session;
  • admins broadcast questions and results to all participants;
  • students get immediate feedback on submissions, preventing duplicates and updating scores in real-time.

🛠️ Installation

Clone the repository:

Bash
`git clone https://github.com/Deepcode007live-quiz-platform.git cd live-quiz-platform`

Install dependencies:

Bash
`npm install`

Set up environment variables (e.g., .env file):

MONGO_URI: MongoDB connection string JWT_SECRET: Secret for JWT signing

Run the server:

Bash
`npm start`

💡 Quick Tip:


Server runs on http://localhost:3000. Use Postman for API testing and wscat for WebSockets.

🎮 Usage

  • 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.

🤝 Contributing

Contributions are welcome! Please fork the repo, create a feature branch, and submit a pull request with clear descriptions.

📄 License

MIT License

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages