Travel Finder is a simple application where the goal is to find the cheapest trip between two points doesn't matter how many hops. The solution implemented is based in theShortest path algorytm.
The project follows the Clean architecture where deliveries
and repositories
are the external interfaces, services
are the use cases and entity
is the business rules.
There are two ways to build the project: one is using Golang version >= 1.14 and the second is using Docker.
For your convenience you can use make
commands to run the tests and the projects.
You can execute the app with the following commands:
make run database=database.csv
or
make docker-run database=database.csv
If the binary was already built, you can run using it:
./travel_finder database.csv
If you would like to only build and not run the application, you can use:
make build
make docker-build
The same way from other commands, you can run the tests using the make commands:
make tests
make docker-tests
You can also see the code coverage info typing:
make coverage
It will open a webpage with the coverage data.
The API communication is given through port number 8080. There are two routes for this API.
To insert a new route you should use the request below:
POST /origins/:origin/destinations/:destination/values/:value
Sample:
curl -X POST -v http://localhost:8080/origins/gru/destinations/fln/values/10
Response codes:
- 201
- 400
- 500
To find the cheapest route between two points, you should use the request:
GET /origins/:origin/destinations/:destination
Sample:
curl -v http://localhost:8080/origins/gru/destinations/orl
Response codes:
- 200
- 400
- 404
- 500
Some improvements points to be implemented in future versions:
- Create a proper API documentation using swagger;
- Refactor the package
command
to be able to implement unit test; - Handle with the current routes instead of duplicate them;
- Use a database instead of a .csv file;