This microservice is responsible for handling flight bookings within a larger, microservices-based airline booking system.

This service operates within an ecosystem of interconnected microservices that form the backbone of the airline booking system. Below are other critical services within the ecosystem:
-
Authentication Service
Manages user registration, login, and authentication logic, utilizing JWT for secure access and role-based access control. -
Flight & Search Service
Handles flight listings, availability checks, and provides flight search and filter functionalities. -
Reminder Service
Sends booking reminders and notifications, implementing RabbitMQ for event-driven messaging. -
API Gateway
Serves as the entry point for all client requests, routing traffic to the appropriate services and handling shared gateway tasks.
The following technologies and frameworks are used in this project:
- Node.js - For non-blocking, event-driven I/O.
- Express - A minimal and flexible Node.js web application framework.
- Sequelize ORM - An easy-to-use ORM for relational databases.
- MySQL / PostgreSQL - Supported databases, configurable to suit your needs.
- RabbitMQ - Message broker used for reliable, asynchronous messaging.
To set up this project in your local development environment, follow these steps:
Clone the repository and navigate to the project directory:
git clone <your-repo-url>
cd <project-directory>Install the necessary dependencies by running the following command:
npm installCreate a .env file in the root of the project directory and configure the following environment variables:
PORT=3000
# External Services
FLIGHT_SERVICE_PATH=http://localhost:4000
# RabbitMQ / Message Broker
EXCHANGE_NAME=reminder_exchange
REMINDER_BINDING_KEY=reminder_key
MESSAGE_BROKER_URL=amqp://localhostEnsure that the values are adjusted based on your local or production environment.
Initialize Sequelize by navigating to the src directory and running:
cd src
npx sequelize initThis will generate the following directory structure:
config/config.jsonmodels/migrations/seeders/
Update the config/config.json file with your database credentials:
"development": {
"username": "your_db_username",
"password": "your_db_password",
"database": "your_db_name",
"host": "127.0.0.1",
"dialect": "mysql"
}If using a database other than MySQL (e.g., PostgreSQL or MariaDB), replace
mysqlwith the appropriate dialect.
Navigate back to the project root and start the application with the following command:
npm run devThe application will be accessible at http://localhost:<PORT>.
The service exposes the following route for booking creation:
routes.post('/bookings', bookingController.create);This route accepts booking data and triggers the appropriate controller logic to process and store the booking.
You can test the API using tools like Postman or curl.
POST /bookings
Content-Type: application/json
{
"flightId": "1234",
"userId": "5678",
"seats": 2
}The project's folder structure is organized as follows:
project-root/
├── src/
│ ├── config/
│ ├── controllers/
│ ├── models/
│ ├── routes/
│ └── services/
├── .env
├── package.json
└── README.md
We welcome feedback and contributions:
- Found a bug? Open an issue.
- Want to contribute? Submit a pull request.
Maintained by Sandeep Gupta.