A comprehensive hostel management system with MySQL backend and modern frontend.
- Student Management: Add, edit, delete student records
- Room Management: Track room capacity and occupancy
- Room Allotment: Assign students to rooms with automatic capacity checking
- Mess Management: Track attendance and calculate fees
- Fee Management: Handle hostel and mess fee payments
- Complaint System: Track and resolve student complaints
- Notifications: Automatic notifications for fees and updates
- Dashboard: Overview statistics and recent activities
- Authentication: Secure login system
- Node.js (v14 or higher)
- MySQL Server
- Your HostelDB database (already created with tables and triggers)
-
Clone/Download the project files
-
Install Node.js dependencies
npm install
-
Configure Database Connection
- Update the
.envfile with your MySQL credentials:DB_HOST=localhost DB_USER=root DB_PASSWORD=your_mysql_password DB_NAME=HostelDB
- Update the
-
Start the server
npm start
For development with auto-restart:
npm run dev
-
Access the application
- Open your browser and go to:
http://localhost:3000 - Default login credentials:
- Username:
admin - Password:
admin123
- Username:
- Open your browser and go to:
hostel-management-system/
├── server.js # Backend API server
├── package.json # Node.js dependencies
├── .env # Environment variables
├── README.md # Setup instructions
└── public/ # Frontend files
├── index.html # Main HTML file
├── login.html # Login page
├── style.css # Styles
└── app.js # Frontend JavaScript
POST /api/login- User login
GET /api/students- Get all studentsPOST /api/students- Add new studentPUT /api/students/:id- Update studentDELETE /api/students/:id- Delete student
GET /api/rooms- Get all rooms with occupancyPOST /api/rooms- Add new room
GET /api/allotments- Get current allotmentsPOST /api/allotments- Create new allotmentPUT /api/allotments/:id/end- End allotment
GET /api/mess-attendance- Get attendance recordsPOST /api/mess-attendance- Mark attendanceGET /api/mess-pricing- Get meal pricesPUT /api/mess-pricing/:meal_type- Update meal price
GET /api/fees- Get all feesPUT /api/fees/:id/pay- Mark fee as paid
GET /api/complaints- Get all complaintsPOST /api/complaints- Add new complaintPUT /api/complaints/:id/resolve- Resolve complaint
GET /api/dashboard- Get dashboard statistics
The system connects to your existing HostelDB MySQL database with all tables and triggers. The triggers automatically:
- Prevent double room allotments
- Enforce room capacity limits
- Update room status based on occupancy
- Calculate mess fees from attendance
- Generate notifications for pending fees
- JWT-based authentication
- Password protection for admin access
- SQL injection prevention with parameterized queries
- CORS enabled for cross-origin requests
Edit the login logic in server.js:
if (username === 'your_username' && password === 'your_password') {
// Login logic
}- Add new API routes in
server.js - Update frontend in
public/app.js - Modify styles in
public/style.css
-
Database Connection Issues
- Verify MySQL is running
- Check credentials in
.envfile - Ensure HostelDB database exists
-
Port Already in Use
- Change PORT in
.envfile - Kill existing processes using the port
- Change PORT in
-
Module Not Found Errors
- Run
npm installto install dependencies - Check Node.js version compatibility
- Run
For issues or questions, check the console logs for detailed error messages.