A simple full-stack Hotel Management System with a Node.js + Express backend, MySQL database, and a basic frontend served using Python HTTP server.
Make sure the following are installed on your system:
- Git
- Node.js & npm
- MySQL Server
- Python (Python 3 recommended)
- VS Code (optional but recommended)
- Create a new empty folder
- Open the folder in VS Code
- Open the terminal and run:
git init
git remote add origin https://github.com/goodachari-master/Hotel_Management.git
git pull origin mainOpen Command Prompt / Terminal and run:
mysql -u root -pEnter your MySQL root password.
sql code
CREATE DATABASE hotel_db;
USE hotel_db;sql code
CREATE TABLE rooms (
id INT AUTO_INCREMENT PRIMARY KEY,
room_number VARCHAR(10),
type VARCHAR(50),
price DECIMAL(10,2),
available BOOLEAN DEFAULT TRUE
);sql code
CREATE TABLE bookings (
id INT AUTO_INCREMENT PRIMARY KEY,
room_id INT,
customer_name VARCHAR(100),
from_date DATE,
to_date DATE,
FOREIGN KEY (room_id) REFERENCES rooms(id)
);Open VS Code or some other editor, and open a new Terminal
cd backendnpm init -ynpm install express mysql2 cors-
Open the file
db.jsinside thebackendfolder. -
You will see the following code:
const mysql = require("mysql2");
const db = mysql.createConnection({
host: "localhost",
user: "root",
password: "Veejnas@4002",
database: "hotel_db"
});
db.connect(err => {
if (err) throw err;
console.log("MySQL Connected");
});
module.exports = db;- Change the password value to your own MySQL server password.
password: "your_mysql_password"- Save the file after updating the password.
cd ..
cd frontendnpm install axiosOpen a new terminal:
cd backend
node server.jsBackend will start running.
Open another terminal:
cd frontend
python3 -m http.server 8081Open your browser and visit:
http://localhost:8081/index.html