Skip to content

Ujjawall12/travel-site

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 

Repository files navigation

Travel Booking System Project Overview This project is a simple Travel Booking System backend application powered by Node.js and Express.js. It sets up a basic server that handles HTTP requests and responses. The server currently runs a simple route to demonstrate the functionality and can be extended further for real-world use cases.

Technologies Used Node.js (v20+ preferred for stability) Express.js (Web framework) NPM (Node Package Manager) Project Structure The file structure is as follows:

bash Copy code travel_booking_system/ │ ├── backend/ │ ├── index.js # Main backend server file │ ├── controllers/ # Folder for controller logic (optional) │ ├── models/ # Folder for database models (optional) │ ├── routes/ # Folder for API routes (optional) │ ├── .env # Environment variables file (optional) │ ├── frontend/ │ ├── public/ # Static files (e.g., images, icons, etc.) │ ├── src/ # Source files for the frontend (React/HTML) │ ├── package.json # Project metadata and dependencies ├── package-lock.json # Lockfile for dependencies └── README.md # Project documentation Installation Steps Follow these steps to set up and run the project:

Step 1: Prerequisites Ensure you have the following installed:

Node.js (Recommended LTS version: 20.x) NPM (Comes with Node.js) Verify installations:

bash Copy code node -v npm -v Step 2: Clone the Repository Clone the project from your source (e.g., GitHub):

bash Copy code git clone https://github.com/yourusername/travel_booking_system.git cd travel_booking_system Step 3: Install Dependencies Run the following command in the project root directory:

bash Copy code npm install Step 4: Run the Backend Server Navigate to the backend folder and start the server:

bash Copy code cd backend npm start By default, the server will run at:

arduino Copy code http://localhost:5000 How It's Working Here’s a step-by-step breakdown of how the project works:

  1. Backend Server Setup The backend server is built using Express.js. The index.js file is the entry point of the server. It initializes the Express server and listens for incoming HTTP requests on a specific port (5000). Example Code in backend/index.js:

javascript Copy code const express = require('express'); // Import express const app = express();

const PORT = 5000; // Define a port number

// Basic route: Respond to GET requests at "/" app.get('/', (req, res) => { res.send('Server is running...'); });

// Start the server app.listen(PORT, () => { console.log(Server running on http://localhost:${PORT}); }); 2. Route Handling The server listens for requests made to the root endpoint /. When a user visits http://localhost:5000/ in their browser or makes a GET request to this route, the server sends back a simple message: "Server is running...". 3. Package.json Configuration The package.json file includes metadata and scripts to manage the server:

Example Configuration:

json Copy code { "name": "travel-booking-system", "version": "1.0.0", "main": "backend/index.js", "scripts": { "start": "node backend/index.js" }, "dependencies": { "express": "^4.18.2" } } "scripts": Defines commands like npm start to run the server. "dependencies": Lists required modules, such as express. 4. How to Run the Server Use npm start to execute the server script in backend/index.js.

The server starts and logs a confirmation message:

arduino Copy code Server running on http://localhost:5000 Open a browser and go to http://localhost:5000/. You will see the response "Server is running...".

Conclusion This project sets up a basic Node.js and Express.js backend server. It listens for incoming HTTP requests, serves a simple response, and can be extended to include more complex functionality like routing, database integration, and a frontend UI.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published