Robust Node.js backend for a full-fledged education + quiz platform with JWT Auth, role-based dashboards, course management, quiz creation, scoring, leaderboards, and student performance tracking.
β Built from scratch using Node.js, Express, and MongoDB, this backend powers student-teacher interaction for an interactive learning platform. Designed for clarity, security, and extensibility.
- β Secure JWT-based login & registration
- β
Roles:
student
,teacher
- β Role-based route access (middleware protected)
- π¨βπ« Teachers can create, manage their courses
- π©βπ Students can enroll only via backend-auth
-
π Teachers can create quizzes:
- Add any number of questions
- Associate them with existing courses
- Control visibility (draft / publish)
- Set quiz start & end time β³
-
π Students can:
- View only enrolled course quizzes
- Take quiz once (attempt restriction)
- Receive immediate scoring
- Receive certificate if passed threshold criteria π
- Receive feedback for each answer (correct/wrong)
- Receive email report after quiz attempt π§
- Blocked from accessing quiz outside time window
- β Quiz-specific leaderboard
- β Global leaderboard across all quizzes
- β View enrolled courses
- β View available quizzes
- β View attempt score history
- β View per-quiz detailed per-question feedback
- β View all created courses
- β View quizzes with stats (students, attempts)
- β Access any studentβs dashboard via dropdown
- β Teachers can monitor individual student entire performance history
π¦ Quiz-App-Backend
βββ controllers/
β βββ authController.js
β βββ courseController.js
β βββ quizController.js
β βββ dashboardController.js
βββ middleware/
β βββ authMiddleware.js
β βββ roleMiddleware.js
βββ models/
β βββ User.js
β βββ Course.js
β βββ Quiz.js
β βββ QuizAttempt.js
β βββ Certificate.js
βββ routes/
β βββ authRoutes.js
β βββ courseRoutes.js
β βββ quizRoutes.js
β βββ dashboardRoutes.js
βββ server.js
βββ config/
β βββ db.js
βββ utils/
βββ tokenUtils.js
βββ emailSender.js
Layer | Tech Used |
---|---|
Language | JavaScript (ES6) |
Backend | Node.js + Express |
Database | MongoDB + Mongoose ORM |
Auth | JWT Tokens |
Role Guard | Middleware based restriction |
Nodemailer (Gmail SMTP) | |
Testing | Postman |
/api/auth/register β create account
/api/auth/login β returns token + user info
π All routes except login/register are protected.
π Student/Teacher routes have role guard.
Method | Route | Description |
---|---|---|
POST | /api/auth/register | Register as student/teacher |
POST | /api/auth/login | Login, returns JWT |
POST | /api/courses/:id/enroll | Student enrolls in course |
GET | /api/courses | View all courses (by role) |
POST | /api/quizzes | Create a quiz (teacher) |
GET | /api/quizzes | Get available quizzes (by role) |
GET | /api/quizzes/:id | Get specific quiz |
POST | /api/quizzes/:quizId/attempt | Submit a quiz |
GET | /api/quizzes/:quizId/leaderboard | Quiz leaderboard |
GET | /api/leaderboard/global | Global leaderboard |
GET | /api/dashboard/student | Studentβs own dashboard |
GET | /api/dashboard/:id/student | Teacher views any student |
GET | /api/quizzes/:id/certificate | Receive Certificate if eligible |
- Clone the repo and run:
npm install
npm run dev
-
Use Postman to:
- Register/login as both roles
- Create course (teacher)
- Enroll (student)
- Create quiz (set startTime, endTime, and duration)
- Attempt quiz (respect time window!)
- Check leaderboard & dashboard routes
- Confirm email is received after attempt
- Confirm cert is generated if passed
- β Draft/Publish quizzes
- β One attempt per student
- β Quiz feedback (per question)
- β Global leaderboard
- β Email report to student after attempt
- β Timed/expiring quizzes β³
- π Tag-based quiz filters
- π Certificate verification link
Built by Mehul Khanna
Crafted with β€οΈ, caffeine, and hundreds of test requests.