Feature
Description
User Registration
Customer sign-up with name, email, phone, and password
Authentication
Login system with email/password verification
Room Browsing
Browse available rooms by type, capacity, and pricing
Room Booking
Book rooms with guest details, check-in/out dates
Room Filtering
Filter rooms by type (Single, Double, Superior), capacity, and price range
Module
Features
Room Management
Add, view, update, and delete room listings with type, capacity, and pricing
Employee Management
Complete employee CRUD with department, designation, and contact details
Payroll System
Record and track salary payments with employee linkage
Inventory Management
Track hotel inventory items with quantity, restock alerts, and history
Supplier Management
Manage suppliers with contact info and full purchase history tracking
Booking Management
View and manage all room bookings with guest information
JWT-based admin authentication with bcrypt password hashing
RESTful API design with modular Express route groups
PDF report generation using jsPDF with auto-table support
Responsive UI with Bootstrap 5 and styled-components
Selenium test suite with automated login flow testing
Customer Portal
Room Browsing
Admin Dashboard
Management Panel
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β CLIENT (React) β
β localhost:3000 β
β β
β ββββββββββββ ββββββββββββ ββββββββββββ ββββββββββββ β
β β Customer β β Room β β Employee β β Inventoryβ β
β β Portal β β Booking β β Manager β β Manager β β
β βββββββ¬βββββ ββββββ¬ββββββ ββββββ¬ββββββ ββββββ¬ββββββ β
β β β β β β
β βββββββ΄βββββ ββββββ΄ββββββ ββββββ΄ββββββ ββββββ΄ββββββ β
β β Supplier β β Admin β βDashboard β β Auth β β
β β Manager β β Login β β β β System β β
β βββββββ¬βββββ ββββββ¬ββββββ ββββββ¬ββββββ ββββββ¬ββββββ β
ββββββββββ΄βββββββββββββ΄βββββββββββββββ΄βββββββββββββββ΄βββββββββββ€
β Axios HTTP Client β
β (REST API Requests) β
ββββββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββ
β HTTP (JSON)
ββββββββββββββββββββββββββββΌββββββββββββββββββββββββββββββββββββ
β SERVER (Express.js) β
β localhost:5000 β
β β
β βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β Middleware Layer β β
β β CORS β cookie-parser β express.json β JWT Verify β β
β βββββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββ β
β β β
β ββββββββββββ¬βββββββββββ¬ββββ΄βββββββ¬βββββββββββ¬βββββββββββ β
β β/customer β/booking β/room β/employeesβ/inventoryβ β
β β/supplier β/adminlog β/supplier β/paidsalarβ β β
β β β β history β ies β β β
β ββββββββββββ΄βββββββββββ΄βββββββββββ΄βββββββββββ΄βββββββββββ β
β β β
β ββββββββββββββββββββββββββββΌβββββββββββββββββββββββββββββββ β
β β Mongoose ODM (Schema + Models) β β
β ββββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββ β
βββββββββββββββββββββββββββββββΌβββββββββββββββββββββββββββββββββ
β MongoDB Driver
βββββββββββββββββββββββββββββββΌβββββββββββββββββββββββββββββββββ
β MongoDB Atlas (Cloud) β
β β
β Collections: β
β ββββββββββββ ββββββββββββ ββββββββββββ ββββββββββββ β
β βcustomers β βrooms β βbookings β βemployees β β
β βadminloginβ βinventory β βsuppliers β βpaidsalar β β
β β β β β βsupplier β β ies β β
β β β β β β history β β β β
β ββββββββββββ ββββββββββββ ββββββββββββ ββββββββββββ β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Technology
Version
Role
Node.js
β₯ 14
JavaScript runtime
Express.js
4.17
Web framework & REST API routing
Mongoose
8.19
MongoDB ODM with schema validation
MongoDB Atlas
β
Cloud-hosted NoSQL database
JWT
9.0
JSON Web Token authentication
bcrypt.js
2.4
Password hashing (salted)
cookie-parser
1.4
HTTP cookie handling
CORS
2.8
Cross-Origin Resource Sharing
dotenv
10.0
Environment variable management
nodemon
2.0
Hot-reload development server
concurrently
6.2
Run backend + frontend simultaneously
Technology
Version
Role
React
17.0.2
UI component framework
React Router DOM
5.2
Client-side routing (Switch/Route)
Axios
0.21
HTTP client for API communication
Bootstrap
5.1
Responsive CSS framework
Bootstrap Icons
1.5
Icon library
styled-components
5.3
CSS-in-JS component styling
jsPDF + AutoTable
2.3 / 3.5
PDF report generation and export
React Icons
4.3
Icon components (FontAwesome, etc.)
validator
13.6
Input validation (email, phone)
SoloAlert
1.1
Custom alert/notification popups
Technology
Role
Selenium WebDriver
Browser automation for E2E tests
pytest
Python test runner with fixtures
Chrome DevTools
Screenshot capture on test pass/fail
Node.js β₯ 14 and npm β₯ 6
MongoDB Atlas account (free tier works) or local MongoDB instance
Python 3.8+ (only for Selenium tests)
# Clone the repository
git clone https://github.com/cazy8/Hotel-Management-System-Mern-Stack.git
cd Hotel-Management-System-Mern-Stack
cd backend
npm install
# Create environment file (see Environment Variables section)
cp .env.example .env
# Edit .env with your MongoDB URI and JWT secret
# Start backend server (with hot-reload)
npm run dev
Backend runs on http://localhost:5000
cd frontend
npm install
# Start React development server
npm start
Frontend runs on http://localhost:3000
# From the backend directory
npm run dev
# This uses concurrently to launch both servers
π Environment Variables
Create a backend/.env file using the provided template:
cp backend/.env.example backend/.env
Variable
Description
Example
MONGO_CONNECT
MongoDB Atlas connection string
mongodb+srv://<user>:<pass>@cluster.mongodb.net/Hotel_DB
JWT_SECRET
Secret key for signing JWT tokens
Any random 64+ character string
PORT
Backend server port (optional)
5000
Generate a Secure JWT Secret
node -e " console.log(require('crypto').randomBytes(64).toString('hex'))"
β οΈ Never commit .env files to version control. The .gitignore is configured to exclude them.
Method
Endpoint
Description
POST
/adminlogin/add
Register new admin
GET
/adminlogin/retrieve
Get all admin records
POST
/adminlogin/login
Admin login
Method
Endpoint
Description
POST
/customer/register
Customer registration
POST
/customer/login
Customer login
Method
Endpoint
Description
POST
/room/add
Add new room
GET
/room/
Get all rooms
GET
/room/:id
Get room by ID
PUT
/room/update/:id
Update room details
DELETE
/room/delete/:id
Delete room
Method
Endpoint
Description
POST
/booking/add
Create new booking
GET
/booking/
Get all bookings
GET
/booking/:id
Get booking by ID
DELETE
/booking/delete/:id
Cancel booking
Method
Endpoint
Description
POST
/employees/add
Add employee
GET
/employees/
Get all employees
GET
/employees/:id
Get employee by ID
PUT
/employees/update/:id
Update employee
DELETE
/employees/delete/:id
Delete employee
Method
Endpoint
Description
POST
/paidsalaries/add
Record salary payment
GET
/paidsalaries/
Get all salary records
Method
Endpoint
Description
POST
/inventory/add
Add inventory item
GET
/inventory/
Get all inventory
GET
/inventory/:id
Get item by ID
PUT
/inventory/update/:id
Update item
DELETE
/inventory/delete/:id
Delete item
Method
Endpoint
Description
POST
/supplier/add
Add supplier
GET
/supplier/
Get all suppliers
GET
/supplier/:id
Get supplier by ID
PUT
/supplier/update/:id
Update supplier
DELETE
/supplier/delete/:id
Delete supplier
POST
/supplierhistory/add
Add supplier history record
GET
/supplierhistory/
Get all history records
Hotel-Management-System-Mern-Stack/
β
βββ backend/ # Express.js API Server
β βββ server.js # Entry point β Express app, MongoDB connection, route mounting
β βββ package.json # Backend dependencies and scripts
β βββ .env.example # Environment variable template
β β
β βββ models/ # Mongoose schemas & models
β β βββ adminlogin.js # Admin user schema (username, password, role)
β β βββ rooms.js # Room model
β β βββ customer/
β β β βββ customerModel.js # Customer schema (name, email, phone, password)
β β βββ room-booking/
β β β βββ bookingModel.js # Booking schema (guest info, room type, dates)
β β βββ emp-manager/
β β β βββ employees.js # Employee schema (name, dept, designation, salary)
β β β βββ paidsalaries.js # Salary payment records
β β βββ employee-manager/
β β β βββ roomModel.js # Room schema (type, capacity, price, description)
β β βββ inventory-manager/
β β β βββ inventoryModel.js # Inventory schema (item, quantity, restock level)
β β βββ supplier-manager/
β β βββ suppliermodel.js # Supplier schema (name, contact, items supplied)
β β βββ supplierhistorymodel.js # Supplier transaction history
β β
β βββ routes/ # Express route handlers
β βββ adminlogin.js # Admin auth routes (register, login, retrieve)
β βββ rooms.js # Room routes
β βββ customer/
β β βββ customerRoute.js # Customer registration & login
β βββ room-booking/
β β βββ bookingRoute.js # Booking CRUD
β βββ emp-manager/
β β βββ employees.js # Employee CRUD
β β βββ paidsalaries.js # Salary records
β βββ employee-manager/
β β βββ RoomRoute.js # Room CRUD
β βββ inventory-manager/
β β βββ inventoryRoute.js # Inventory CRUD
β βββ supplier-manager/
β βββ supplierRoute.js # Supplier CRUD
β βββ supplierhistoryRoute.js # Supplier history
β
βββ frontend/ # React Application
β βββ package.json # Frontend dependencies and scripts
β βββ public/
β β βββ index.html # HTML entry point
β β βββ favicon.ico # Browser tab icon
β β βββ cover.jpeg # Hotel cover image
β β βββ logo.png # Hotel logo
β β
β βββ src/
β βββ App.js # Root component β React Router configuration
β βββ index.js # ReactDOM entry point
β βββ App.css # Global styles
β βββ context.js # React Context for room data
β βββ data.js # Static room data
β βββ Contentful.js # Contentful CMS integration
β β
β βββ components/
β β βββ auth/ # Authentication
β β β βββ cusLogin.js # Customer login form
β β β βββ CusRegister.js # Customer registration form
β β β βββ adminRegister.js # Admin registration
β β β
β β βββ room/ # Room Management (Admin)
β β β βββ AddRoom.js # Add new room form
β β β βββ ViewAllRooms.js # Room listing table
β β β βββ ViewOneRoom.js # Single room details + edit
β β β βββ RoomBookings.js # Create booking form
β β β βββ ViewAllRoomBookings.js # All bookings list
β β β
β β βββ employee/ # Employee Management
β β β βββ AddEmployee.js # Add employee form
β β β βββ ViewEmployee.js # Employee listing
β β β βββ ViewOneEmployee.js # Employee details + edit
β β β βββ AddPaidSalary.js # Record salary payment
β β β βββ ViewPaidSalary.js # Salary payment history
β β β
β β βββ inventory/ # Inventory Management
β β β βββ AddInventory.js # Add inventory item
β β β βββ ViewAllInventory.js # Inventory listing
β β β βββ ViewOneInventory.js # Item details + edit
β β β βββ RestockInventory.js # Restock existing items
β β β
β β βββ supplier/ # Supplier Management
β β β βββ AddSupplier.js # Add supplier form
β β β βββ ViewAllSuppliers.js # Supplier listing
β β β βββ ViewOneSupplier.js # Supplier details + edit
β β β βββ ViewAllSupplierHistoryRecords.js # Purchase history
β β β βββ ViewOneSupplierHistoryRecords.js # Single record
β β β
β β βββ layouts/ # Shared Layout Components
β β β βββ topnav.js # Top navigation bar
β β β βββ Navbar.js # Customer navigation
β β β βββ EMPsidenav.js # Employee section sidebar
β β β βββ EmpDetailsSideNav.js # Employee details sidebar
β β β βββ Roomsidenav.js # Room management sidebar
β β β βββ InventorySideNav.js # Inventory sidebar
β β β βββ Supsidenav.js # Supplier sidebar
β β β
β β βββ Dashboard.js # Admin dashboard overview
β β βββ Banner.js # Hero banner component
β β βββ FeaturedRooms.js # Featured rooms carousel
β β βββ Hero.js # Hero section
β β βββ Navbar.js # Main navigation
β β βββ Room.js # Room card component
β β βββ RoomsContainer.js # Room list container
β β βββ RoomsFilter.js # Room filtering controls
β β βββ RoomsList.js # Room grid layout
β β βββ Services.js # Hotel services section
β β βββ StyledHero.js # Styled hero with background
β β βββ Title.js # Section title component
β β βββ Loading.js # Loading spinner
β β
β βββ pages/ # Page-level components
β β βββ Home.js # Landing page
β β βββ Rooms.js # All rooms page
β β βββ SingleRoom.js # Individual room page
β β βββ Error.js # 404 error page
β β
β βββ images/ # Static assets (room images, logos, GIFs)
β
βββ frontend/tests/ # E2E Test Suite
β βββ selenium/python/
β βββ conftest.py # pytest fixtures (driver, test user creation)
β βββ pytest.ini # pytest configuration
β βββ requirements.txt # Test dependencies (selenium, pytest)
β βββ test_cases.md # Test case documentation
β βββ tests/
β βββ test_login.py # Login flow tests (valid + invalid)
β
βββ image.png # Screenshot β Customer portal
βββ image-1.png # Screenshot β Room browsing
βββ image-2.png # Screenshot β Admin dashboard
βββ image-3.png # Screenshot β Management panel
βββ .gitignore # Git ignore rules
βββ LICENSE # MIT License
βββ README.md # This file
The project includes automated browser tests for the login workflow:
cd frontend/tests/selenium/python
# Install test dependencies
pip install -r requirements.txt
# Run tests (both servers must be running)
pytest tests/ -v
# Run in headless mode
HEADLESS=1 pytest tests/ -v
Test Case
Description
Expected Result
TC-001
Login with valid credentials
Redirects to /rooms or /dashboard
TC-002
Login with invalid password
Alert shown, stays on login page
Environment Variables for Tests
Variable
Default
Description
BASE_URL
http://localhost:3000
Frontend URL
BACKEND_URL
http://localhost:5000
Backend API URL
HEADLESS
0
Set to 1 for headless Chrome
SCREENSHOT_DIR
./screenshots
Screenshot output directory
This project follows security best practices:
β
Environment Variables β All secrets (MongoDB URI, JWT key) stored in .env, never in source code
β
.gitignore configured β .env files excluded from version control
β
bcrypt password hashing β User passwords hashed with salt before storage
β
JWT authentication β Stateless token-based auth for admin routes
β
CORS restricted β Only localhost:3000 allowed in development
β
Clean git history β No credentials in commit history
Production Recommendations
Area
Recommendation
Database
Create restricted Atlas user (not admin), whitelist specific IPs
JWT
Use RS256 algorithm with key rotation
HTTPS
Enable TLS for all traffic in production
Rate Limiting
Add express-rate-limit middleware
Input Validation
Add server-side validation with express-validator
Helmet
Add helmet middleware for security headers
Fork the repository
Create a feature branch (git checkout -b feature/amazing-feature)
Commit changes (git commit -m 'Add amazing feature')
Push to branch (git push origin feature/amazing-feature)
Open a Pull Request
Harsh Gupta β @cazy8 Β· LinkedIn
This project is licensed under the MIT License β see the LICENSE file for details.
If you found this useful, consider giving it a β