A modern, full-stack university hostel management system built on the PERN stack (PostgreSQL, Express.js, React, Node.js). HostelHub streamlines room allocations, maintenance tracking, fee management, and warden-student communication with role-based access control, real-time notifications, and a premium dark-themed UI.
- Secure JWT-based authentication with bcrypt password hashing
- Role-based access: Student, Warden, Admin
- Protected routes on both frontend and backend
- Full CRUD for hostels and rooms
- Real-time occupancy tracking
- Room availability toggles and capacity management
- Students browse and apply for available rooms with live filtering
- Wardens review, approve, or reject allocation requests
- Automatic capacity management on approval
- Roommate compatibility scoring based on student preferences
- Students file digital maintenance tickets with categories and urgency levels
- Wardens manage tickets in a Kanban-style pipeline (Pending → In Progress → Resolved)
- Real-time status tracking with instant notifications
- Occupancy rates by hostel (donut charts)
- Maintenance distribution by category (bar charts)
- Payment status breakdowns
- Monthly trend visualizations
- Socket.io-powered instant notifications
- Polling-based fallback
- In-app notification center with unread badges
- Payment tracking per semester
- Status management (Pending, Paid, Overdue, Refunded)
- Revenue analytics
| Layer | Technology |
|---|---|
| Frontend | React 18, Vite, Tailwind CSS 3, Recharts |
| Backend | Express.js, Node.js, Socket.io |
| Database | PostgreSQL with strict relational schemas |
| Auth | JWT (JSON Web Tokens), bcryptjs |
| Validation | Zod schema validation |
Hostel Management/
├── server/ # Express.js API
│ ├── db/ # SQL schema & seed data
│ ├── src/
│ │ ├── config/ # DB pool, environment
│ │ ├── controllers/ # Business logic
│ │ ├── middleware/ # Auth, validation, errors
│ │ ├── routes/ # API route definitions
│ │ ├── validators/ # Zod schemas
│ │ ├── utils/ # Helper functions
│ │ └── server.js # Entry point
│ └── package.json
│
├── client/ # React (Vite) SPA
│ ├── src/
│ │ ├── api/ # Axios API modules
│ │ ├── components/ # Shared UI components
│ │ ├── context/ # Auth & Notification providers
│ │ ├── hooks/ # Custom React hooks
│ │ ├── pages/ # Page components
│ │ ├── utils/ # Formatters & helpers
│ │ ├── App.jsx # Router & providers
│ │ └── main.jsx # Vite entry
│ └── package.json
│
└── README.md
- Node.js v18+ and npm
- PostgreSQL v14+
# Install server dependencies
cd server
npm install
# Install client dependencies
cd ../client
npm install# Create the database
psql -U postgres -p 5433 -c "CREATE DATABASE hostel_mgmt;"
# Run schema
psql -U postgres -p 5433 -d hostel_mgmt -f server/db/schema.sql
# Seed with mock data
psql -U postgres -p 5433 -d hostel_mgmt -f server/db/seed.sqlCopy server/.env.example to server/.env and update your PostgreSQL credentials.
# Terminal 1: Start backend
cd server
npm run dev
# Terminal 2: Start frontend
cd client
npm run dev- Backend API: http://localhost:5000
- Frontend App: http://localhost:5173
| Role | Password | |
|---|---|---|
| Admin | admin@hostel.edu | password123 |
| Warden | anil.warden@hostel.edu | password123 |
| Student | amit@student.edu | password123 |
| Method | Endpoint | Auth | Description |
|---|---|---|---|
| POST | /api/auth/register |
— | Register new user |
| POST | /api/auth/login |
— | Login |
| GET | /api/auth/me |
JWT | Get current user |
| GET | /api/hostels |
JWT | List hostels |
| POST | /api/hostels |
Admin | Create hostel |
| GET | /api/rooms |
JWT | List rooms (with filters) |
| POST | /api/rooms |
Admin | Create room |
| GET | /api/allocations |
JWT | List allocations |
| POST | /api/allocations |
JWT | Submit allocation request |
| PUT | /api/allocations/:id/approve |
Admin | Approve allocation |
| PUT | /api/allocations/:id/reject |
Admin | Reject allocation |
| GET | /api/maintenance |
JWT | List maintenance requests |
| POST | /api/maintenance |
JWT | File maintenance ticket |
| PUT | /api/maintenance/:id |
Admin | Update ticket status |
| GET | /api/analytics/overview |
Admin | Dashboard statistics |
| GET | /api/notifications |
JWT | Get user notifications |
| GET | /api/payments |
JWT | List payments |
This project is built for educational purposes.