Please refer to the Postman Docs to understand the APIs and try out Postman Collection
This is an Airline managemnet and flight booking system based on microservices architecture. It has 4 microservices:
Non functional Requirements
- We can expect more flight searching than bookings
- The system needs to be reliable in terms of booking
- Expect that we will be having 100k total users.
- 100k bookings might come up in quarter
- In one day you might be getting 100 bookings
- System should make sure that we don?t change the prices where the booking payment is going on.
- System should be able to auto scale itself atleast for 3x more traffic.
The Flight Service acts as the core component, encompassing multiple models including airplane, airport, city, flight, and seat models. This microservice handles all 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 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, automatically canceling such bookings if necessary. Additionally, this microservice utilizes RabbitMQ to send booking information to a queue for further processing by the Flight Notification Service.
The 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. Key features include:
- Rate limiting to control API usage
- Reverse proxy for efficient routing
- JWT (JSON Web Tokens) for user authentication
- Authorization system to ensure access control based on user roles
The Flight Notification Service is responsible for sending notifications to users regarding their flight bookings. Once a booking is successfully processed and confirmed, the Flight Booking Service 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 details about their successful bookings.
This is a base node js project template, which anyone can use as it has been prepared, by keeping some of the most important code principles and project management recommendations. Feel free to change anything.
- Node Js
- Express Js
- mySQL
- Sequelize
- RabbitMQ
The flight service is a backend project that I have created and implemented micrservices architecture, it is a comprehensive system that manages various aspects of a flight service.
This Service has several models airplane, airport, city, flight, and seat models for the efficient and organized operation of the flight service.
-
The airplane model includes essential information such as the airplane's model Number, seating capacity.
-
The airport model contains information about each airport, such as its name, location, City code, address. This model enables efficient handling of airport-related data like flight scheduling, arrivals, and departures.
-
The city model represents the cities or locations connected by the flight service. It stores information about each city name.
-
The flight model serves as the core entity within the system, capturing details about individual flights. It contains information such as the flight number, airplaneId, departureAirportId and arrivalAirportId, scheduled departure and arrival times, price, totalSeats and boardingGate assigned to the flight.
-
The seat model represents the seating arrangements within each airplane. It includes information about airplaneId, row, col, seatType (e.g., economy, business, first class). It enables efficient allocation of seats during the booking process.
By integrating these models within our flight service backend project, we have established a robust system that enables effective management of airplanes, airports, cities, flights, and seats.
/api/v1/airplanes
Parameter | Method | Body | Description |
---|---|---|---|
/ |
GET |
Get all Airplanes | |
/{id} |
GET |
Get Airplane by ID | |
/ |
POST |
modelNumber , capacity |
Create New Airplanes |
/{id} |
DELETE |
Delete Airplane by ID | |
/{id} |
PATCH |
capacity |
Update Airplane |
/api/v1/cities
Parameter | Method | Body | Description |
---|---|---|---|
/ |
GET |
Get all Cities | |
/ |
POST |
name |
Create New City |
/{id} |
DELETE |
Delete City by ID | |
/{id} |
PATCH |
name |
Update Airplane |
/api/v1/airports
Parameter | Method | Body | Description |
---|---|---|---|
/ |
GET |
Get all Airports | |
/{id} |
GET |
Get Airport by ID | |
/ |
POST |
name , cityId , code |
Create New Airport |
/{id} |
DELETE |
Delete Airport by ID | |
/{id} |
PATCH |
name , cityId , code (Min one field required) |
Update Airplane |
/api/v1/flights
Parameter | Method | Body | Description |
---|---|---|---|
/*[?trip=MUM-DEL] |
GET |
Get all Flights | |
/ |
POST |
flightNumber , airplaneId , departureAirportId , arrivalAirportId , arrivalTime , departureTime , price , totalSeats , boardingGate(optional) |
Create New City |
/{id} |
DELETE |
Delete Flights by ID | |
/{id}/seats |
PATCH |
seats , *[dec] |
Update Seats |
Note
-
[ ]
-> Inside this is Optional -
if Dec will not be given in the parameter it will decrease the seat by default. if given dec = false it will increase the seats.
-
By Default
\
will fetch all the flights.
Query parameter
trips
->MUM-DEL
price
->1200-7000
or2000
travellers
->2
tripDate
->02-12-23
sort
->departureTime_ASC, price_DESC
- 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