How daniyalahmed21/flight-booking-system works
Project type and purpose
• This is a microservices-based flight booking system structured as a monorepo.
• Its purpose is to provide a full end-to-end booking workflow: clients call the API gateway, which routes to the flight catalog, booking orchestration, and notification services.
File–structure analysis
• Top-level folders:
• api-gateway – single HTTP entrypoint, authentication, routing.
• flight-service – manages flights, airports, cities, seats (MySQL via Sequelize).
• booking-service – booking creation/cancellation, seat allocation, payment orchestration, uses a message queue for inter-service events.
• notification-service – delivers booking events via email/SMS.
• Each service follows a layered structure: config, controllers, middlewares, models/migrations, repositories, services, routes, utils.
• docker-compose.yml ties the services together for local/dev orchestration.
Key insights from README
• Architecture is client → api-gateway → individual services.
• Each service owns its own data store (MySQL for flight, optionally MongoDB for booking, another for notifications).
• Uses Node.js + Express for all services, Sequelize ORM, Winston for logging, dotenv for config, Docker for containers.
a. Main components
• Clients (web/mobile)
• API Gateway (Express, authentication, routing)
• Flight Service (Express + Sequelize + MySQL)
• Booking Service (Express + queue integration + database)
• Notification Service (Express + email/SMS delivery + database)
• Message broker/Queue (e.g., RabbitMQ or built-in queue)
• Databases (MySQL instances, MongoDB if used)
• External services (SMTP server, SMS gateway, payment provider)
b. Relationships and interactions
• Clients send requests to API Gateway.
• Gateway routes “flight search” requests to Flight Service.
• Booking requests go to Booking Service via the gateway.
• Booking Service allocates seats by calling Flight Service APIs or directly via shared queue.
• Booking Service publishes “booking created/cancelled” events to the message broker.
• Notification Service subscribes to booking events, then sends emails/SMS.
• All services read their own environment variables, log to Winston, and persist domain data to their own DBs.
• Docker Compose links all containers and the broker/network.
c. Architectural patterns and principles
• Microservices with bounded contexts (flight, booking, notification).
• API Gateway pattern for cross-cutting concerns (auth, rate limiting).
• Layered architecture within each service (controllers → services → repositories → models).
• Event-driven integration via message broker for loose coupling.
• Independent persistence per service (database per microservice).
• Containerized deployment (Docker + Compose).
d. Technologies and frameworks
• Node.js + Express
• Sequelize ORM (Flight Service, potentially Notification)
• MongoDB driver or ORM for Booking Service (if used)
• RabbitMQ or similar queue (config/queueConfig.js in booking-service)
• Winston for logging
• dotenv for configuration
• Docker & Docker Compose