- Java 8
- Maven
Build the flight-plan-core application using the Maven command line tool:
cd flight-plan-core
mvn clean packageRun the JAR file created inside target directory with the routes CSV file as a parameter:
java -jar target/flight-plan-core-1.0-SNAPSHOT.jar /path/to/routes.csvFollow the screen instructions to get the best route for your trip and have a nice vacation!
Build and install the flight-plan-core application (if you haven't done it yet):
cd flight-plan-core
mvn clean installStart the flight-plan-api service with SpringBoot Maven plugin:
cd flight-plan-api
mvn spring-boot:runIf nothing goes wrong, the service will run in 8080 port.
Call a GET call at http://localhost:8080/v1/api/routes/best with:
- origin: The origin
- destination: The destination
cURL command
curl -X GET \
'http://localhost:8080/v1/api/routes/best?origin=GRU&destination=CDG'Expected response
{
"route": "GRU >> BRC >> SCL >> ORL >> CDG",
"price": 40
}Call a POST call at http://localhost:8080/v1/api/routes with a JSON body:
- origin: The origin (String)
- destination: The destination (String)
- price: The price (Number)
cURL command
curl -X POST \
http://localhost:8080/v1/api/routes \
-H 'Content-Type: application/json' \
-d '{
"origin": "ORI",
"destination": "DES",
"price": 10.0
}'Expected response
200
- flight-plan-core
- itinerary
- Itinerary stuff as name generator and the logic the find the possible routes
- model
- The POJO's models
- repository
- Persistence logic
- route
- Route stuff as logic to find the best price route
- service
- Encapsulates the repository logic into a single interface
- itinerary
- flight-plan-api
- controller
- The endpoints
- controller
I've tried to follow the Clean Architecture which defines that classes should have a simple responsibility and split the logic into layers based in their specializations.