All projects

projects.app / cloudtrip-flight-booking

professionalJun 2025 – Aug 2025

Flight booking system with dynamic pricing and seat management.

Overview

CloudTrip is a flight search and seat reservation app. The frontend supports searching for and booking a single leg. The backend also provides an API that reserves two selected legs in one transaction.

Key features

  • City lookup — The backend returns distinct, sorted city names for origin and destination suggestions. Users can refresh the list from the search form.
  • Flight search — Search by origin, destination, departure date, passenger count, and cabin class. The backend checks the route, schedule, and seat availability.
  • Fare breakdown — Flight cards show the base fare, price per person, dynamic surcharge, and total fare for the group.
  • Single-leg booking — The frontend submits the selected flight and passenger count to POST /api/book and displays the booking result.
  • Two-leg booking API — POST /api/round_trip_booking validates both selected legs and rolls back the first inventory update if the second booking fails. This flow is available through the backend API.

Architecture

Backend class diagram

Technical decisions

  • Separate flight templates from dated inventory. Flight and BaseFlightSeat hold reusable schedule details, base fares, and capacity. FlightSchedule and FlightScheduleSeat track a specific date and remaining seats per cabin. Search creates dated records on demand for eligible recurring flights.
  • Calculate fares on the backend. Separate pricing strategies calculate surcharges based on the proportion of seats sold and the time remaining before departure. The search service adds both to the base fare and calculates the group total.
  • Protect inventory during booking. FlightBookingService locks the seat inventory row, rechecks availability, and decrements the count. The round-trip controller wraps both updates in a database transaction. Reservations are reflected in inventory changes.
  • Cache the city list in the frontend. CitiesProvider shares city data through React Context, and TanStack Query treats it as fresh for 24 hours. The search form and flight cards keep interaction state locally.