A modern, responsive full-stack student management application and academic administration workspace built with Node.js, Express, MongoDB (Mongoose), JWT authentication, and Vanilla HTML5/CSS3/JavaScript.
- Features
- Technology Stack
- Prerequisites
- Step-by-Step Installation Guide
- Environment Configuration (
.env) - Database Seeding (Admin & Sample Students)
- Running the Application
- User Roles & Access Control
- API Documentation
- Project Architecture
- Troubleshooting & FAQs
- Deployment (Vercel + MongoDB Atlas)
- Student Academic Hub & Services Portal:
- Attendance Guardian & 75% Calculator: Visual gauge tracking attendance against the university 75% threshold, with an interactive calculator determining how many classes can be safely skipped or must be attended.
- Weekly Timetable: Interactive Monday-to-Friday schedule with periods, locations, and faculty.
- Subject-wise Breakdown: Course-level attendance tracking with shortage warnings.
- Campus Notice Board: Priority exam notices, hackathon announcements, and library alerts.
- Academic Downloads: Instant access to syllabus schemes, academic calendars, and question banks.
- Student Profile Dossiers: One-click modal to inspect any student's full academic file (USN, attendance metrics, CGPA, fee status, enrolled courses, and advisor remarks).
- Dark & White (Light) Mode: Modern theme toggle (☀️ Light / 🌙 Dark) with smooth transitions, persistent user preference in
localStorage, and automatic system preference detection. - Modern UI & Responsive Design: Elevated aesthetic with glassmorphism modal dialogs, colorful department pills, live status indicators, pastel avatar gradients, and responsive mobile/desktop layouts.
- Authentication & Security: JWT-based stateless authentication, bcrypt password hashing (cost factor 12), Helmet HTTP security headers, CORS origin filtering, and Express rate limiting.
- Role-Based Access Control (RBAC): Distinct permissions for Administrators and Students.
- Student Directory:
- Real-time search across Name, USN, and Email.
- Multi-criteria filtering by Department (CSE, ISE, ECE, EEE, ME, CIV, AIML, DS, OTHER), Semester (1–8), and Status (Active, On Leave, Graduated).
- Paginated table with responsive mobile & desktop UI.
- Admin Management Operations (CRUD):
- Add new student records with form validation.
- Edit existing student details directly through interactive modal dialogs.
- Delete student records with confirmation prompts.
- One-click CSV export of the full student roster with CSV injection protection.
- Overview Dashboard:
- Metric cards for Total Students, Active Students, Distinct Departments, and Semester Breakdown.
- Automatic avatar generation with student initials and status badges.
- Pre-populated Sample Data: Ready-to-use temporary database seeder with realistic student records.
- Backend: Node.js (v20+), Express.js 4.x
- Database: MongoDB with Mongoose ODM
- Authentication: JSON Web Tokens (
jsonwebtoken),bcryptjs - Security & Utilities:
helmet,cors,compression,express-rate-limit,morgan,dotenv - Frontend: Responsive Vanilla HTML5, modern CSS3 (Custom Properties & Flexbox/Grid), JavaScript (ES6+ async/await)
- Deployment: Vercel serverless function routing (
vercel.json) + static asset serving
Before starting, ensure you have the following installed on your machine:
- Node.js: Version 20.x or higher (
node -v) - npm: Version 9.x or higher (
npm -v) - MongoDB:
- Local instance: MongoDB Community Server running locally on
mongodb://127.0.0.1:27017 - OR Cloud instance: A free MongoDB Atlas connection URI.
- Local instance: MongoDB Community Server running locally on
Follow these steps to set up and run the project from scratch:
git clone https://github.com/your-username/student-management.git
cd student-managementInstall all required Node.js packages:
npm installCopy the provided .env.example file to create your .env configuration:
cp .env.example .envOpen .env in your text editor and review the configuration:
NODE_ENV=development
PORT=5000
MONGODB_URI=mongodb://127.0.0.1:27017/student-management_students
JWT_SECRET=replace_with_a_long_random_secret_at_least_32_characters
JWT_EXPIRES_IN=1d
CLIENT_ORIGIN=http://localhost:5000
ADMIN_NAME=Project Administrator
ADMIN_EMAIL=admin@example.com
ADMIN_PASSWORD=ChangeThisAdminPassword123!| Variable | Description | Default / Example |
|---|---|---|
NODE_ENV |
Application environment (development, production, test). |
development |
PORT |
Local port number the web server listens on. | 5000 |
MONGODB_URI |
MongoDB connection string. Use local or your Atlas URI. | mongodb://127.0.0.1:27017/student-management_students |
JWT_SECRET |
Secret key used to sign and verify JWT authentication tokens. Must be at least 32 characters. | Long random string |
JWT_EXPIRES_IN |
Token expiration period. | 1d (1 day) |
CLIENT_ORIGIN |
Allowed client origin(s) for CORS. Can be comma-separated for multiple URLs. | http://localhost:5000 |
ADMIN_NAME |
Display name of the initial seeded administrator account. | Project Administrator |
ADMIN_EMAIL |
Login email for the administrator. | admin@example.com |
ADMIN_PASSWORD |
Password for the administrator. Must be at least 12 characters. | ChangeThisAdminPassword123! |
The project includes built-in seeding scripts to immediately populate your database with an administrator account and realistic student records.
npm run seedThis runs both the admin seeder and the sample student generator sequentially.
-
Seed / Update Administrator Only:
npm run seed:admin
Creates or updates the admin account configured in your
.envfile (ADMIN_EMAIL&ADMIN_PASSWORD). -
Seed Sample Students Only:
npm run seed:students
Populates the database with 18 realistic sample student records across all departments (CSE, ISE, ECE, EEE, ME, CIV, AIML, DS), varied semesters (1 through 8), and statuses (Active, On Leave, Graduated). Note: The script is idempotent; re-running it safely updates records by USN without creating duplicates.
npm run devnpm run startOnce started, open your browser and navigate to:
http://localhost:5000
The application implements strict Role-Based Access Control (RBAC):
┌─────────────────────────────────────────────────────────────┐
│ Public User │
│ - View login & registration page │
│ - Register a new Student account │
│ - Sign in │
└──────────────────────────────┬──────────────────────────────┘
│
┌──────────────────┴──────────────────┐
▼ ▼
┌───────────────────────────┐ ┌───────────────────────────┐
│ Student Role │ │ Administrator Role │
│ - View student directory │ │ - Everything Students can │
│ - Search & filter records │ │ - Add new students │
│ - View metrics & stats │ │ - Edit student records │
│ - View individual records │ │ - Delete student records │
│ │ │ - Export directory to CSV │
└───────────────────────────┘ └───────────────────────────┘
- How to sign in as Admin:
Use the credentials defined in your
.env:- Email:
admin@example.com - Password:
ChangeThisAdminPassword123!
- Email:
- Admin Capabilities:
- The UI displays an ADMINISTRATOR badge.
- Top action buttons: "+ Add student" and "↓ Export CSV" are visible and active.
- Table column ACTIONS displays Edit and Delete buttons for each student.
- Access to all admin-only REST API endpoints (
POST,PUT,DELETE, and/export.csv).
- How to access as a Student:
- Click on the "Create account" tab on the login screen.
- Provide Full Name, Email, and Password (minimum 8 characters).
- Public registration automatically assigns the
studentrole.
- Student Capabilities:
- The UI displays a STUDENT badge.
- Full read access to the directory: search, filter, paginate, and view dashboard analytics.
- Admin-only action buttons and mutation endpoints are hidden and protected with HTTP
403 Forbidden.
All routes under /api/students require authentication via standard Bearer token header:
Authorization: Bearer <token>
| Method | Endpoint | Access Level | Description |
|---|---|---|---|
GET |
/api/health |
Public | Service health status check |
POST |
/api/auth/register |
Public | Register a new student user account |
POST |
/api/auth/login |
Public | Authenticate user and receive JWT token |
GET |
/api/auth/me |
Authenticated | Retrieve authenticated user profile |
GET |
/api/students |
Authenticated | List students with search, filters & pagination |
GET |
/api/students/stats |
Authenticated | Get summary metrics and department/semester counts |
GET |
/api/students/:id |
Authenticated | Retrieve details for a single student |
POST |
/api/students |
Admin Only | Create a new student record |
PUT |
/api/students/:id |
Admin Only | Update an existing student record |
DELETE |
/api/students/:id |
Admin Only | Remove a student record |
GET |
/api/students/export.csv |
Admin Only | Download full student directory as CSV |
- Pagination:
/api/students?page=1&limit=8 - Keyword Search:
/api/students?search=Aarav(matches Name, USN, or Email) - Filtered Query:
/api/students?department=CSE&semester=5&status=Active
student-management/
├── api/
│ └── index.js # Server entry point (exports Express app for Vercel/Node)
├── src/
│ ├── app.js # Express app setup, middleware, CORS, rate limits
│ ├── config/
│ │ └── db.js # Mongoose connection manager with global connection caching
│ ├── controllers/
│ │ ├── authController.js # Auth handlers (register, login, me)
│ │ └── studentController.js # Student CRUD, metrics aggregation, CSV export
│ ├── middleware/
│ │ ├── auth.js # JWT verification (protect) & admin role enforcement (adminOnly)
│ │ └── errors.js # Centralized error handler and 404 handler
│ ├── models/
│ │ ├── Student.js # Mongoose schema for Student records
│ │ └── User.js # Mongoose schema for User accounts (Admin & Student)
│ └── routes/
│ ├── authRoutes.js # /api/auth routing
│ └── studentRoutes.js # /api/students routing
├── public/
│ ├── index.html # Single-page application markup & modal dialogs
│ ├── styles.css # Responsive modern design system
│ └── app.js # Frontend client logic, state management, API calls
├── scripts/
│ ├── seedAdmin.js # Admin account provisioning script
│ └── seedStudents.js # Temporary/sample student dataset seeding script
├── postman/
│ └── Student Management-API.postman_collection.json # API Postman collection
├── .env.example # Environment variable template
├── package.json # Project scripts and dependencies
├── vercel.json # Vercel deployment configuration
└── README.md # Project documentation
- Cause: MongoDB is not running on your local machine.
- Fix: Start the MongoDB service.
- Linux (systemd):
sudo systemctl start mongod - macOS (Homebrew):
brew services start mongodb/brew/mongodb-community - Or use a free cloud database URI from MongoDB Atlas in your
.env.
- Linux (systemd):
- Cause: The
JWT_SECRETin.envis too short or missing. - Fix: Open
.envand setJWT_SECRETto a random string with 32 or more characters.
- Cause: Admin password set in
.envhas fewer than 12 characters. - Fix: Ensure
ADMIN_PASSWORDin.envis at least 12 characters long before runningnpm run seed:admin.
- Cause: Another process is already running on port 5000.
- Fix: Change
PORT=5001in.envand updateCLIENT_ORIGIN=http://localhost:5001, or terminate the process using port 5000 (lsof -i :5000/kill <PID>).
-
MongoDB Atlas:
- Create a free cluster on MongoDB Atlas.
- Create a database user and configure Network Access (
0.0.0.0/0for cloud serverless access). - Copy the connection string (e.g.
mongodb+srv://<user>:<password>@cluster.mongodb.net/students?retryWrites=true&w=majority).
-
Deploy to Vercel:
- Push your code to GitHub (do not commit your
.envfile). - Import the repository in your Vercel Dashboard.
- Under Project Settings → Environment Variables, add:
NODE_ENV=productionMONGODB_URI=<Your MongoDB Atlas URI>JWT_SECRET=<Random 32+ character secret>JWT_EXPIRES_IN=1dCLIENT_ORIGIN=https://your-project.vercel.appADMIN_NAME=Project AdministratorADMIN_EMAIL=admin@example.comADMIN_PASSWORD=<Strong password with 12+ characters>
- Click Deploy.
- Push your code to GitHub (do not commit your
-
Seed Production Database: From your local development machine, temporarily point
MONGODB_URIin.envto your Atlas URI, then run:npm run seed
This seeds the admin and sample students directly into your production Atlas database.
- Cause: MongoDB is not running on your local machine.
- Fix: Start the MongoDB service.
- Linux (systemd):
sudo systemctl start mongod - macOS (Homebrew):
brew services start mongodb/brew/mongodb-community - Or use a free cloud database URI from MongoDB Atlas in your
.env.
- Linux (systemd):
- Cause: The
JWT_SECRETin.envis too short or missing. - Fix: Open
.envand setJWT_SECRETto a random string with 32 or more characters.
- Cause: Admin password set in
.envhas fewer than 12 characters. - Fix: Ensure
ADMIN_PASSWORDin.envis at least 12 characters long before runningnpm run seed:admin.
- Cause: Another process is already running on port 5000.
- Fix: Change
PORT=5001in.envand updateCLIENT_ORIGIN=http://localhost:5001, or terminate the process using port 5000 (lsof -i :5000/kill <PID>).
-
MongoDB Atlas:
- Create a free cluster on MongoDB Atlas.
- Create a database user and configure Network Access (
0.0.0.0/0for cloud serverless access). - Copy the connection string (e.g.
mongodb+srv://<user>:<password>@cluster.mongodb.net/students?retryWrites=true&w=majority).
-
Deploy to Vercel:
- Push your code to GitHub (do not commit your
.envfile). - Import the repository in your Vercel Dashboard.
- Under Project Settings → Environment Variables, add:
NODE_ENV=productionMONGODB_URI=<Your MongoDB Atlas URI>JWT_SECRET=<Random 32+ character secret>JWT_EXPIRES_IN=1dCLIENT_ORIGIN=https://your-project.vercel.appADMIN_NAME=Project AdministratorADMIN_EMAIL=admin@example.comADMIN_PASSWORD=<Strong password with 12+ characters>
- Click Deploy.
- Push your code to GitHub (do not commit your
-
Seed Production Database: From your local development machine, temporarily point
MONGODB_URIin.envto your Atlas URI, then run:npm run seed
This seeds the admin and sample students directly into your production Atlas database.