A comprehensive PG (Paying Guest) and Mess management system with integrated payment processing, user authentication, and administrative features.
- User Management: Student and Admin authentication
- Payment Processing: Integrated Razorpay payment gateway
- Room Allocation: Automated room assignment and management
- Mess Subscription: Silver, Gold, and Platinum meal plans
- Dashboard Analytics: Real-time statistics and reporting
- Complaint System: Maintenance request tracking
- Attendance Tracking: Daily attendance monitoring
- HTML5, CSS3, JavaScript (ES6+)
- Font Awesome for icons
- Responsive design with mobile support
- Node.js with Express.js
- JWT authentication
- Razorpay payment integration
- In-memory storage (easily upgradeable to MongoDB)
- Node.js (v14 or higher)
- npm or yarn
-
Clone the repository
git clone <repository-url> cd pgmess
-
Install dependencies
npm install
-
Environment Configuration
Copy
.envfile and update the values:cp .env.example .env
Update the following variables in
.env:# Server Configuration PORT=3000 NODE_ENV=development # JWT Secret JWT_SECRET=your_jwt_secret_key_here_change_in_production # Payment Gateway Configuration RAZORPAY_KEY_ID=your_razorpay_key_id RAZORPAY_KEY_SECRET=your_razorpay_key_secret # Email Configuration (optional) EMAIL_HOST=smtp.gmail.com EMAIL_PORT=587 EMAIL_USER=your_email@gmail.com EMAIL_PASS=your_app_password # Frontend URL (for CORS) FRONTEND_URL=http://localhost:5500 -
Start the backend server
# For development npm run dev # For production npm start
-
Access the application
- Backend API: http://localhost:3000
- Frontend: Open
index.htmlin your browser or use a live server extension - API Documentation: http://localhost:3000/api/health
- Email: student@example.com
- Password: student123
- Email: admin@happylivingpg.com
- Password: admin123
POST /api/v1/auth/login- User loginPOST /api/v1/auth/register- User registrationPOST /api/v1/auth/refresh- Refresh access tokenPOST /api/v1/auth/logout- User logoutPOST /api/v1/auth/forgot-password- Forgot passwordPOST /api/v1/auth/reset-password- Reset password
POST /api/v1/payments/create-order- Create payment orderPOST /api/v1/payments/process- Process paymentGET /api/v1/payments- Get payment historyGET /api/v1/payments/:id- Get payment detailsPOST /api/v1/payments/:id/refund- Refund payment
GET /api/v1/users/profile- Get user profilePUT /api/v1/users/profile- Update user profileGET /api/v1/users/allocation- Get room allocationGET /api/v1/users/mess-subscription- Get mess subscriptionPUT /api/v1/users/mess-subscription- Update mess subscriptionGET /api/v1/users/dashboard- Get dashboard data
The system integrates with Razorpay for payment processing:
- Order Creation: Frontend creates a payment order
- Payment Processing: User completes payment via Razorpay
- Verification: Backend verifies and records the transaction
- Receipt Generation: Digital receipt is generated
- Create a Razorpay account at https://razorpay.com
- Get your API keys from the Razorpay dashboard
- Update the
.envfile with your credentials:RAZORPAY_KEY_ID=your_key_id RAZORPAY_KEY_SECRET=your_key_secret
pgmess/
├── server.js # Main server file
├── package.json # Dependencies and scripts
├── .env # Environment variables
├── routes/ # API routes
│ ├── auth.js # Authentication routes
│ ├── payments.js # Payment routes
│ └── users.js # User management routes
├── js/ # Frontend JavaScript
│ ├── auth-service.js # Authentication service
│ ├── payment.js # Payment service
│ └── main.js # Main application logic
├── css/ # Stylesheets
├── student/ # Student pages
├── admin/ # Admin pages
└── index.html # Landing page
npm run devThis will start the server with nodemon for automatic restarts.
- Backend: Add new routes in the
routes/directory - Frontend: Update JavaScript files in the
js/directory - Styling: Modify CSS files or add new stylesheets
The current implementation uses in-memory storage for demo purposes. To integrate with a database:
-
Install MongoDB and Mongoose:
npm install mongoose
-
Update the models and routes to use database operations
-
Configure MongoDB connection in
server.js
- JWT-based authentication
- Rate limiting on API endpoints
- Helmet.js for security headers
- CORS configuration
- Input validation and sanitization
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
This project is licensed under the MIT License.
For support and queries, please contact the development team.
Note: This is a demonstration system. For production use, ensure proper security measures, database integration, and error handling.