Airline Management System

Flight Operations & Booking Platform

Design the booking side of an airline: search flights, hold a seat while the passenger pays, confirm, cancel under a fare rule, check in, and board by group, with a seat never sold twice.

Overview

An airline system sells seats on scheduled flights and then moves each passenger through check-in and boarding. A flight has a number, a route, a departure time and a seat map; each seat belongs to a cabin (first, business or economy). A booking ties one passenger to one seat on one flight and moves through a fixed set of states until the passenger boards or the booking is canceled.

The problem is broad, so the interviewer is testing scope as much as code. Pick the booking core and say what you leave out (crew, aircraft maintenance, loyalty points). Then show three things: a seat is never given to two people even when many buyers click at once; a seat held during payment comes back if the payment never finishes; and the flight and the booking each follow a state machine, so an impossible step (boarding a canceled booking, landing a flight that never left) is refused.

A strong answer scopes in two minutes, draws the two state machines, puts the lock around the seat check, and ends with a demo that covers a race, an expired hold and a refund.

Scoping the problem

Spend the first two minutes on seven questions. Each comes with why it matters and the answer interviewers usually give.

  • Which part: booking, operations (crew, aircraft), or both? The whole airline is too big for an hour. The usual answer is booking, check-in and boarding.
  • One flight per booking, or multi-leg trips? Multi-leg trips need all-or-nothing holds. The usual answer is one flight, with multi-leg as a follow-up.
  • Is a seat held while the passenger pays? That adds a hold with a time limit. The usual answer is yes, for a few minutes.
  • How are refunds decided? Fare rules change often, so they belong in a Strategy. The usual answer is by the fare bought.
  • Is overbooking in scope? It changes the seat inventory model. The usual answer is to discuss it, not code it.
  • Who is told about delays and cancellations? That adds notifications. The usual answer is every passenger booked on the flight.
  • Many sales channels at once? This decides the locking. The usual answer is yes, and a seat must never be sold twice.

Functional requirements

  • search(origin, destination, cabin, now) returns flights still selling, with their free seats in that cabin
  • hold(passenger, flight, seat, fare, rule, now) takes a free seat for a limited time and returns a booking reference
  • confirm(pnr, now) turns a live hold into a booking after payment; an expired hold is refused
  • cancel(pnr, now) frees the seat and returns the refund the fare rule allows (nothing for an unpaid hold)
  • check_in(pnr, gate) issues a boarding pass with a boarding group from the cabin
  • board(pnr, group_called) boards a checked-in passenger once the flight is boarding and the group is called
  • Flight status changes follow a transition table and notify every passenger booked on the flight

Non-functional requirements

  • A seat is never held or sold to two passengers at once
  • The lock covers the seat check only, never a payment call
  • Abandoned holds free their seats without a background job
  • Refund rules and boarding order change without editing the Airline class
  • Deterministic: time is passed in, so expiry and refunds are exact in tests

Interview questions

  • Two agents sell seat 1A at the same moment. How do you stop a double sale, in memory and in a database?
  • The flight is canceled. What happens to its passengers?
  • How would you support overbooking?
  • Where do times and time zones fit in?

Sign up free to read the full topic

More Low-Level Design topics

Start free on Cariara · Coding problems · System design studio