Build a service that aggregates flight availability and pricing from multiple airlines and travel agencies. The service allows users to search for flights between two cities, specifying a date range and preferences. It recommends the best flights based on price and availability, considering factors like layovers and travel duration.
- AirlineConnect: A major airline providing availability and pricing through a RESTful API.
- GlobalFlyer: A travel agency offering flight information via a GraphQL endpoint.
- BudgetWings: A budget airline that uploads a CSV file daily with flight schedules and prices.
- Allow users to specify:
- Origin and Destination cities.
- A departure date range (e.g., Jan 10–15).
- Optional preferences such as shortest travel time or lowest cost.
- Fetch flight availability and pricing from all sources.
- Return:
- The best-priced flight(s) for the selected route and date range.
- Details like layovers, total travel time, and airline.
- Include filters for:
- Direct flights only or allow layovers.
- Maximum layover duration (e.g., no more than 3 hours).
- Maximum travel time (e.g., no longer than 10 hours total).
- Fetch data from all providers concurrently.
- Cache frequently queried routes and date ranges to reduce latency.
- Use a timeout to handle slow providers.
- If a flight matching a user's preferences drops below a certain price threshold, send an alert to their email or a notification service.
Simulate this provider with an asynchronous function that returns flight data in JSON format after a delay of 200ms.
Example Response:
[
{
"flight_number": "AC101",
"origin": "JFK",
"destination": "LAX",
"price": 300,
"departure": "2025-01-10T08:00:00",
"arrival": "2025-01-10T11:00:00",
"layovers": []
},
{
"flight_number": "AC202",
"origin": "JFK",
"destination": "LAX",
"price": 250,
"departure": "2025-01-10T15:00:00",
"arrival": "2025-01-10T19:00:00",
"layovers": ["ORD"]
}
]
Simulate a GraphQL query returning flight data after a 300ms delay.
Example Query:
query {
flights(origin: "JFK", destination: "LAX", dates: ["2025-01-10", "2025-01-15"]) {
flightNumber
price
departure
arrival
layovers
}
}
flight_number,origin,destination,price,departure,arrival,layovers
BW303,JFK,LAX,200,2025-01-10T22:00:00,2025-01-11T02:00:00,""
BW404,JFK,LAX,180,2025-01-11T05:00:00,2025-01-11T09:00:00,"PHX"
- Fetch flight availability and pricing for a given route and date range from all providers.
- Aggregate the results and return the best-priced flight(s).
- Add filters for:
- Direct flights only.
- Maximum layover duration.
- Maximum travel time.
- Fetch data concurrently using asynchronous calls.
- Add caching for frequently searched routes and date ranges.
- Implement timeouts for slow providers to avoid delays in the overall response.
- Send a notification if a flight below a specific price threshold becomes available.
- Simulate provider failures (e.g., API down, CSV file missing).
- Ensure partial results are returned even if some providers fail.
- Multi-City Itineraries
- Allow users to search for multi-city routes (e.g., JFK → LAX → SFO).
- Real-Time Updates
- Implement WebSocket or push notifications for price changes in real-time.
- User Accounts
- Add user-specific preferences and saved searches.
- Pricing Trends
- Include price trends over time for users to identify the best time to book flights.