This project is a comprehensive travel application built using a Modular-monolith architecture. It provides functionalities for flight and hotel searches, bookings, payments, user management, and more. The application is designed to be scalable, maintainable, and efficient in handling various aspects of travel planning and management.
The flight search and booking feature allows users to search for available flights and make bookings. This process involves multiple steps and services working together.
sequenceDiagram
actor User
participant Gateway as Gateway Service
participant FlightSearch as Flights Search Service
participant ExternalAPI as External API Integration Service
participant Amadeus as Amadeus API
User->>Gateway: Request flight offers with criteria
Gateway->>FlightSearch: Forward request
FlightSearch->>ExternalAPI: Request flight data
ExternalAPI->>Amadeus: Query for flight offers
Amadeus->>ExternalAPI: Return flight offers
ExternalAPI->>FlightSearch: Process and return flight data
FlightSearch->>Gateway: Return processed flight offers
Gateway->>User: Respond with flight offers
- The user sends a request to the gateway-service with flight search criteria.
- The gateway-service forwards the request to the flights-search-service.
- The flights-search-service requests flight data from the external-api-integration service.
- The external-api-integration service queries the Amadeus API for flight offers based on the given criteria.
- Amadeus API returns the flight offers to the external-api-integration service.
- The external-api-integration service processes the data and returns it to the flights-search-service.
- The flights-search-service sends the processed flight offers back to the gateway-service.
- Finally, the gateway-service responds to the user with the flight offers.
sequenceDiagram
actor User
participant Gateway as Gateway Service
participant FlightSearch as Flights Search Service
participant ExternalAPI as External API Integration Service
participant Amadeus as Amadeus API
User->>Gateway: Request price for specific flight offer
Gateway->>FlightSearch: Forward price request
FlightSearch->>ExternalAPI: Request price for offer
activate ExternalAPI
ExternalAPI->>ExternalAPI: Prepare price request
ExternalAPI->>Amadeus: Query for offer price
Amadeus-->>ExternalAPI: Return offer price details
ExternalAPI->>ExternalAPI: Process price information
deactivate ExternalAPI
ExternalAPI->>FlightSearch: Return processed price data
FlightSearch->>Gateway: Return flight offer with price
Gateway->>User: Respond with priced flight offer
- The user sends a request to the gateway-service for the price of a specific flight offer.
- The gateway-service forwards this request to the flights-search-service.
- The flights-search-service requests the price data from the external-api-integration service.
- The external-api-integration service prepares the price request (this might involve formatting the offer details correctly for the Amadeus API).
- The external-api-integration service queries the Amadeus API for the specific offer price.
- Amadeus API returns the offer price details.
- The external-api-integration service processes the received price information.
- The processed price data is sent back to the flights-search-service.
- The flights-search-service returns the flight offer with the price to the gateway-service.
- Finally, the gateway-service responds to the user with the priced flight offer.
sequenceDiagram
actor User
participant Gateway as Gateway Service
participant Booking as Booking Service
participant Payment as Payment Service
participant FlightSearch as Flights Search Service
participant ExternalAPI as External API Integration Service
participant Amadeus as Amadeus API
User->>Gateway: Create flight order
Gateway->>Booking: Forward create order request
Booking->>FlightSearch: Get flight price
FlightSearch->>ExternalAPI: Request flight price
ExternalAPI->>Amadeus: Query for flight price
Amadeus-->>ExternalAPI: Return flight price
ExternalAPI-->>FlightSearch: Return processed price
FlightSearch-->>Booking: Return flight price
Booking->>Payment: Create payment order
Payment-->>Booking: Return payment order ID
Booking->>Booking: Create transaction
Booking-->>Gateway: Return payment order details
Gateway-->>User: Respond with payment order
User->>Gateway: Confirm flight order
Gateway->>Booking: Forward confirm order request
Booking->>Payment: Check payment authorization
alt Payment authorized
Payment-->>Booking: Return authorization status (success)
Booking->>ExternalAPI: Create flight order
ExternalAPI->>Amadeus: Create order in Amadeus
alt Amadeus successful
Amadeus-->>ExternalAPI: Return order details
ExternalAPI-->>Booking: Return flight order details
Booking->>Booking: Save flight booking
Booking->>Payment: Capture payment
Payment-->>Booking: Confirm payment captured
Booking-->>Gateway: Confirm order finalized
Gateway-->>User: Respond with booking confirmation
else Amadeus unavailable or order creation failed
Amadeus-->>ExternalAPI: Error or no response
ExternalAPI-->>Booking: Return error
Booking->>Payment: Void payment authorization
Payment-->>Booking: Confirm authorization voided
Booking->>Booking: Update transaction status
Booking-->>Gateway: Return order creation failure
Gateway-->>User: Respond with order creation failure
end
else Payment unauthorized
Payment-->>Booking: Return authorization status (failure)
Booking->>Booking: Update transaction status
Booking-->>Gateway: Return payment failure
Gateway-->>User: Respond with payment failure
end
- The initial flow for creating a flight order, including getting the flight price from Amadeus through the flight search and external API integration services.
- Creating a payment order based on the retrieved price.
- When the user confirms the flight order, the booking-service checks the payment authorization with the payment-service.
- If the payment is authorized (success path):
- The booking-service attempts to create the flight order through the external-api-integration service.
- If Amadeus successfully creates the order:
- The process continues, saving the booking and capturing the payment.
- If Amadeus is unavailable or fails to create the order:
- The booking-service voids the payment authorization.
- The transaction status is updated to reflect the failure.
- The user is informed about the order creation failure.
- If the payment is unauthorized (failure path):
- The transaction status is updated to reflect the failed payment.
- The user is informed about the payment failure.
The hotel search and booking feature allows users to find and book accommodations. This process is similar to flight booking but tailored for hotel reservations.
This feature handles user registration, login, and profile management. It ensures secure access to the application and personalized experiences for users.
The payment processing feature securely handles financial transactions for flight and hotel bookings. It integrates with external payment gateways to process payments and manage refunds when necessary.
This feature allows the application to communicate with external services like Amadeus for flight and hotel data. It handles API requests, data transformation, and error handling.
The logging and monitoring feature tracks application performance, user activities, and system errors. It uses the ELK (Elasticsearch, Logstash, Kibana) stack for comprehensive logging and visualization.
The auditing feature keeps track of important system events and user actions for security and compliance purposes. It maintains a detailed audit trail of all significant operations within the system.
The notifications feature keeps users informed about their bookings, payments, and other relevant information. It can send notifications through various channels such as email, SMS, or push notifications.
- Node.js
- NestJS
- PostgreSQL
- Sequelize ORM
- Docker
- pnpm (Package Manager)
- Elasticsearch, Logstash, and Kibana (ELK Stack) for logging and monitoring
The project follows a monorepo structure using NestJS for microservices. Here's an overview of the main components:
apps/
: Contains all servicesgateway-service/
: API Gatewayflights-search-service/
: Handles flight search operationshotels-search-service/
: Manages hotel search functionalitybooking-service/
: Handles booking operationsusers-service/
: Manages user-related operationspayments-service/
: Handles payment processingnotifications-service/
: Manages notificationsauthentication-service/
: Handles user authenticationauditing-service/
: Manages auditing operationsexternal-api-integration-service/
: Integrates with external APIslogging-and-monitoring-service/
: Handles logging and monitoring
libs/
: Shared librariesdatabase/
: Database configurations and modelscore/
: Core functionalities and shared utilities
-
Clone the repository:
git clone https://github.com/ahmdhusam/travel-app cd travel-app
-
Install dependencies:
pnpm install
-
Set up environment variables:
- Copy
.env.example
to.env
and fill in the necessary values.
- Copy
-
Start the services:
pnpm run start:dev
-
Build the Docker images:
docker-compose build
-
Start the services:
docker-compose up
The application uses Sequelize as an ORM. Here's a brief overview of some key models:
- User
- Flight
- Hotel
- Booking
- Payment
- Notification
For detailed model structures, refer to the files in apps/**/src/models/
.
API documentation is generated using Swagger. After starting the application, you can access the Swagger UI at:
http://localhost:3000/api/v1/docs
To run tests:
pnpm test
For end-to-end tests:
pnpm test:e2e
This project is licensed under the MIT License - see the LICENSE file for details.