Skip to content

sarthaksinha2003/Quizify

Repository files navigation

Quizify

Quizify is a quiz web app with category-based quizzes, user registration and login, custom test creation, a leaderboard, and MongoDB-backed data.

Features

  • Home (Main.html): Browse categories (History, Science, Sports, and more), open the quiz flow, design a custom quiz, or pick existing user-created tests.
  • Quiz session (index.html): Choose number of questions, difficulty, and question type; questions are loaded from the API.
  • Auth (register.html, login.html): Register and log in with email and password (JWT returned on success).
  • Create test (create-test.html): Build a named quiz with category, difficulty, and embedded questions.
  • Existing tests (select-test.html): List saved tests and load questions for a selected test.
  • Leaderboard: Scores are submitted after a quiz and ranked on the leaderboard API.

Tech stack

  • Backend: Node.js, Express, Mongoose
  • Database: MongoDB (local), database name quizzify
  • Frontend: Static HTML, CSS, and inline/fetch-based JavaScript

Prerequisites

  • Node.js (LTS recommended)
  • MongoDB running locally (default mongodb://localhost:27017)

Setup

  1. Clone or copy this project and open the project folder in a terminal.

  2. Install dependencies:

    npm install
  3. Start MongoDB so it accepts connections on localhost:27017.

Running the app

The project uses several Express servers on different ports. Start each in its own terminal from the project root:

File Port Role
quiz.js 3000 Fetches filtered questions for the main quiz (/get-questions)
leaderboardServer.js 4000 Leaderboard read/write (/api/leaderboard)
server.js 5000 Register, login, list questions, create test (/api/*)
server-selecting-test.js 5005 List tests and test questions for “Existing Quizzes”

Example:

node quiz.js
node leaderboardServer.js
node server.js
node server-selecting-test.js

Open Main.html in the browser. Because the pages call http://localhost:..., use a local static server if plain file:// causes issues (for example, the “Live Server” extension in VS Code, or npx serve .).

API overview (for reference)

  • Port 3000 (quiz.js): GET /get-questions?num=&level=&type=&category=
  • Port 4000 (leaderboardServer.js): GET|POST /api/leaderboard
  • Port 5000 (server.js): POST /api/register, POST /api/login, GET /api/questions, POST /api/create-test
  • Port 5005 (server-selecting-test.js): GET /quizzify/tests, GET /api/test-questions/:testId

Data models

Models live under models/ (for example User, Question, Test, Leaderboard). Seed the questions collection in MongoDB so category quizzes return data.

Security note

server.js uses a hard-coded JWT secret for development. For any real deployment, move secrets to environment variables and use a strong random value.

License

This project is for educational / portfolio use unless you add your own license.

About

A fun and interactive quiz website where users can test their knowledge on various topics. Challenge yourself with engaging quizzes!

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors