Amanmandal-M / Mock_6_Backend

This is Air ticket Booking backend system where user can login and view thier flights after login and book flights according given slots.

Home Page:https://air-ticket-booking-vn6t.onrender.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Air Ticket Booking Backend System

About


This is Air Ticket Booking System where user can register with their credentials and login with their credentials and after authentication user can view the flights and book flights , edit the booked flights , and delete the booking.


Clone Repository

https://github.com/Amanmandal-M/Mock_6_Backend.git

Installation

npm install

Start the Backend server

npm run start
node index.js
nodemon start
nodemon index.js

Note : You can use any of them


MVC Structure

├── index.js
├── configs
|    └── db.js
├── models
|    └── userModel.js
|    └── flightModel.js
|    └── bookingModel.js
├── routes
|    └── userRoute.js
|    └── flightRoute.js
|    └── bookingRoute.js
├── middlewares
|    └── authenticationMiddleware.js
├──controllers
|    └── userController.js
|    └── flightController.js
|    └── bookingController.js

Note:

  • Before doing anything first create .env file and put PORT , MONGO_URL , NORMAL_KEY.
  • PORT is for listening the server.
  • MONGO_URL is for running database and store your data in database so put your mongo link.
  • NORMAL_KEY is for authentication jsonwebtoken so basically this is your secret key .

Swagger API documentation and Schemas

Swagger


Schema Design


User Schema

{
  _id: ObjectId,
  name: String,
  email: String,
  password: String
}

Flight Schema

{
  _id: ObjectId,
  airline: String,
  flightNo: String,
  departure: String,
  arrival: String,
  departureTime: Date,
  arrivalTime: Date,
  seats: Number,
  price: Number
}

Booking Schema

{
	 _id: ObjectId,
	 user   : { type: ObjectId, ref: 'User' },
	 flight : { type: ObjectId, ref: 'Flight' }
}

Endpoints

METHOD ENDPOINT DESCRIPTION STATUS CODE
POST /api/register This endpoint should allow users to register. 201
POST /api/login This endpoint should allow users to login. 201
GET /api/flights This endpoint should return a list of all available flights. 200
GET /api/flights/:id This endpoint should return the details of a specific flight identified by its ID. 200
POST /api/flights This endpoint should allow users to add new flights to the system. 201
PUT / PATCH /api/flights/:id This endpoint should allow users to update the details of a specific flight identified by its ID. 204
DELETE /api/flights/:id This endpoint should allow users to delete a specific flight identified by its ID. 202
POST /api/booking This endpoint should allow the user to book flights. 201
GET /api/dashboard This point should list all the bookings so far with the user and flight details. 200

About

This is Air ticket Booking backend system where user can login and view thier flights after login and book flights according given slots.

https://air-ticket-booking-vn6t.onrender.com


Languages

Language:JavaScript 100.0%