A backend service that aggregates flight search results from multiple airline providers (AirAsia, Batik Air, Garuda Indonesia, Lion Air) into a unified response format.
- Go 1.24.4+
- Create a .env file in the root directory, .env.example is provided and can just follow the value (if not created, app will run normally on default config)
- then run
go mod tidy
go run app/cmd/main.goapp should be running on designated port declared in .env folder (default port 8080)
curl -X POST http://localhost:{{PORT_NUMBER}}/api/flight/search \
-H "Content-Type: application/json" \The endpoint aggregates data; field names and structure may vary by implementation. Additionally, each flight data has "best_price_same_flight" and "best_amenities_same_flight" to give best options with the same flight route.
available request body filter field:
- origin (filter by specified origin)
- destination (filter by destination)
- departure_date (filter by departure date)
- return_date (since there is no return_date data in the mock json, this filter is going to filter by arrival_date)
- passengers (filter by number of seats available, whether X passengers is less or equal than available seats)
- cabin_class (filter by cabin class)
- min_price (filter by price thats greater than X)
- max_price (filter by price thats lower than X)
- stops (filter by number of stops)
- duration_minutes (filter by total durations in minutes, including layover)
- airline (filter by airline)
- arrival_date (filter by arrival date, same as return_date filter)
- limit (limit how many data can be shown, unlimited by default, need to be used with "page")
- page (fetch X page, need to have "limit" to be enabled)
- sort_by (sort by available key below)
available sort key (case sensitive):
- "price"
- "duration"
- "departure_time"
- "arrival_time"
for descending sort, add "-" prefix
Mock data is located in internal/provider/flightsearch/apimock
- Provider Pattern: Each airline API has its own provider implementation, allowing independent parsing of different response formats into a unified model.
- Controller/Service/Repo Layered Architecture: Clean separation between HTTP handling, business logic, and data access.
- Everything in
internal/: All application packages are private to this module, enforced by the Go compiler. Nopkg/directory since this is a standalone service, not a library. - In memory caching system: In memory caching system to get data faster, the cache system simulate redis get and set with key eviction capability.
- Retry mechanism with exponential timeoff: Built-in retry system with exponential timeout implemented for every fetch to providers.
- Timeout System: Timeout system that is declared by using the value in .env file to decide maximum time spent a request can have
- Concurrency System to fetch multiple provider: Built-in Concurrency system to fetch from multiple providers, ensuring faster fetch operation
- Model and DTO separation: Model and DTO Separation to limit what data to be shown and to make it easier to modify before reaching end-user.
- Go Fiber: Using GoFiber, built on FastAPI for lighting fast HTTP Engine.