Implementation of a route service that given some connections among airports returns the cheapest route along with the cost.
- Maven
- JDK 1.8
The application needs a csv file containing the routes as input, the file named input-routes.csv along with the initialization script is at infrastructure folder. At project folder run the sh start.sh script passing the path to csv file as argument.
- E.g. sh start.sh "/Users/root/Downloads/input-routes.csv"
Exists two ways to use the application:
-
Command Line: when the application starts you can see a welcome message, just type the route (e.g GRU-CDG) and press enter to see the result.
-
Rest API: using Rest API it's possible to make a GET request passing the source and destination as parameter (e.g http://localhost:8080/routes/GRU/ORL).
- To create a new route make a POST request to append a new route at csv file.
POST Request
{
"source": "ORL",
"destination": "BRC",
"cost": 1
}
To implement the application base was used the Dijkstra Algorithm and this Java Implementation.
- controller: contains application controllers, responsible for receiving requests;
- models: application models with the data estructure;
- repository: since we do not have a database the resources are been handle using Collection at this package;
- utility: Utility classes that can be used for one or more classes;
- processor: here we have the application processors (web and command line) implementing Route Processor and also the bussines logics for each interface;
- App: starts the application by using observer pattern to initialize all implementation of Route Processors.
Some integration and unit test can be found at test directory.