The goal of this project is design a Golang application serving an HTTP API to return the person's original flight path, given a list of flights.
The application architecture follows the principles of the Clean Architecture, originally described by Robert C. Martin. The foundation of this kind of architecture is the dependency injection, producing systems that are independent of external agents, highly testable and easier to maintain.
You can read more about Clean Architecture here.
The algorithm used to find out the original flight path is quite simple. It consists in search the origin that never appears as a destination, and the opposite as well, search the destination that never appears as a origin. Within these values in hands, we have the first origin and last destination.
As a performant algorithm, it runs on a linear time complexity, O(n).
- Method:
POST - Path:
/calculate - Headers
-
- Content-Type: application/json
- Payload:
[
{
"source": "IND",
"destination": "EWR"
},
{
"source": "SFO",
"destination": "ATL"
},
{
"source": "GSO",
"destination": "IND"
},
{
"source": "ATL",
"destination": "GSO"
}
]- Response:
{
"source": "SFO",
"destination": "EWR"
}make helpto see all commands;make upto starts the app serving the http api;make testto run all tests.
- validate corner cases: today the api validation is pretty simple, validating only non-empty and duplicated flights
- flights data generator: implement a function returning a huge list of flights
- benchmark: would be a good improvement running a benchmark to evaluate the current algorithm, and compare with future changes.