The Flight Service Backend Project is based on a microservice architecture, comprising four distinct microservices that collectively provide a comprehensive flight management system.
The first microservice, Flight Service, acts as the core component and encompasses multiple models, including airplane, airport, city, flight, and seat models. This microservice handles all the essential functionalities related to flights, airports, and cities. It enables efficient scheduling and allocation of airplanes, manages flight routes and durations, and facilitates seat reservations for passengers.
The second microservice, Flight Booking Service, focuses on the booking process and includes the booking model. It incorporates cron jobs that run every 30 minutes to automatically check for pending or initiated bookings with expired payment times. In such cases, the bookings are automatically canceled. Additionally, this microservice utilizes RabbitMQ to send booking information to a queue for further processing by the fourth microservice.
The third microservice, Flight API Gateway Service, provides a centralized entry point for accessing the flight service's functionalities. It incorporates user and role models for managing user information and permissions. This microservice includes features such as rate limiting to control API usage, reverse proxy for efficient routing, authentication system using JWT (JSON Web Tokens) for user authentication, and an authorization system to ensure access control based on user roles.
The fourth microservice, Flight Notification Service, is responsible for sending notifications to users regarding their flight bookings. Once a booking is successfully processed and confirmed, the second microservice sends the relevant information to a queue. The Flight Notification Service then consumes the messages from the queue and uses Node Mailer to send emails to users, providing them with details about their successful bookings.
Collectively, these microservices work together to create a robust flight management system. The Flight Service microservice handles flight-related operations and models, the Flight Booking Service automates booking cancellations and manages booking queues, the Flight API Gateway Service provides a secure and efficient gateway for user interactions, and the Flight Notification Service ensures timely and accurate notifications to users via email.
- Node Js
- Express Js
- mySQL
- Sequelize
- RabbitMQ
This microservice provides APIs and endpoints to facilitate the flight booking process. When a user wants to book a flight, they interact with the system, providing essential details like the flight they want to book (flightId), the number of seats they wish to reserve (noOfSeats), and their user identification (userId).
This Service has a model booking
- Automatic Cancellation of Expired Bookings using cron jobs that runs every 30 seconds.
- Status Management: The booking model includes a "status" field, which helps in tracking the progress of a booking.
- Cost Calculation: The booking model also contains a "totalCost" field, which is calculated based on the number of seats reserved (noOfSeats) and the corresponding cost per seat.
- Integration with RabbitMQ: When a booking is successfully made this microservice sends relevant booking information to the Flight Notification Service. It consume these messages and carry out additional actions.
-
Download this template from github and open it in your favourite text editor.
-
Go inside the folder path and execute the following command:
npm install
-
In the root directory create a
.env
file and add the following env variablesPORT=<port number of your choice>
ex:
PORT=3000
-
go inside the
src
folder and execute the following command:npx sequelize init
-
By executing the above command you will get migrations and seeders folder along with a config.json inside the config folder.
-
If you're setting up your development environment, then write the username of your db, password of your db and in dialect mention whatever db you are using for ex: mysql, mariadb etc
-
If you're setting up test or prod environment, make sure you also replace the host with the hosted db url.
-
To run the server execute
npm run dev