Quizify is a quiz web app with category-based quizzes, user registration and login, custom test creation, a leaderboard, and MongoDB-backed data.
- 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.
- Backend: Node.js, Express, Mongoose
- Database: MongoDB (local), database name
quizzify - Frontend: Static HTML, CSS, and inline/fetch-based JavaScript
-
Clone or copy this project and open the project folder in a terminal.
-
Install dependencies:
npm install
-
Start MongoDB so it accepts connections on
localhost:27017.
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.jsnode leaderboardServer.jsnode server.jsnode server-selecting-test.jsOpen 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 .).
- 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
Models live under models/ (for example User, Question, Test, Leaderboard). Seed the questions collection in MongoDB so category quizzes return data.
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.
This project is for educational / portfolio use unless you add your own license.