The Flight Service is a core microservice-based API responsible for managing all flight, airport, and city-related operations, including creating, updating, deleting, and retrieving flight data.
It serves as the primary data provider for other services such as the Flight Booking Service and Notification Service. Ensuring clean separation of concerns, scalability, and maintainable architecture across the system.
This service is built as part of a microservice-oriented flight booking platform, inspired by real-world systems like MakeMyTrip and Expedia. While the Flight Service handles all flight-related business logic, other microservices manage bookings, seat availability, and user notifications, working together to form a complete, production-style backend system.
This folder contains all the actual source code for the project, excluding tests (consider creating a separate test/ folder).
Let's explore the src/ folder structure:
Config: Contains all configurations and setup files for libraries and modules.Example:server-config.js- Sets up the server with dotenv for cleaner environment variable usageExample: Logging library configurations for meaningful application logs
Registers routes with their corresponding middleware and controllers.
Intercepts incoming requests for validation, authentication, and other preprocessing tasks.
Acts as the final middleware layer before business logic execution.
- Receives incoming requests and data
- Passes data to the business layer
- Structures API responses and sends output
Contains all database interaction logic.
- Raw SQL queries
- ORM queries
- Database-specific operations
Whole business logic and interacts with repositories for database operations.
Contains helper methods, error classes, and utility functions.
- Clone this repo in your local machine from GitHub
- Open it in your favorite text editor
Create a .env file in the root directory and add the following:
npm install
PORT=<port number of your choice>
Example:
PORT=3000
Inside the src/config/ folder, create a file named config.json with the following content:
{
"development": {
"username": "root",
"password": null,
"database": "database_development",
"host": "127.0.0.1",
"dialect": "mysql"
},
"test": {
"username": "root",
"password": null,
"database": "database_test",
"host": "127.0.0.1",
"dialect": "mysql"
},
"production": {
"username": "root",
"password": null,
"database": "database_production",
"host": "127.0.0.1",
"dialect": "mysql"
}
}
Go Inside `src/ Then Paste the given command in intregratrd terminal:-
npx sequelize init
- By executing the above command you will get migrations and seeders along with a
config.jsoninside the Config Folder.
Update the following fields in the development section:
username- Your database usernamepassword- Your database passworddialect- Your database type (mysql, postgres, sqlite, etc.)
For test or production environments:
- Replace all database credentials accordingly
- Important: Replace the
hostvalue with your hosted database URL
npm run dev