A Java API to return recipes based on what ingredients you have on your fridge.
- Make sure you have:
Java (min. version 8)
installedMaven
installed
- Import the project -> Select the
root
folder -> Next - Select Import project from external model -> Select Maven line -> Next
- Select use auto-import checkbox -> Finish
Note: If the code is not working, open the Maven tab Press Reimport all Maven projects
- The
Application.java
class is the main class. Run itsmain
method.
- On the project
root
folder runmvn spring-boot:run
cd /yourFolder/rootProjectFolder mvn spring-boot:run
- On the project
root
folder runmvn test
cd /yourFolder/rootProjectFolder mvn test
/lunch?ingredients={ingredients}
- If you pass any valid ingredient, the return will the recipes with it.
- If an ingredient is past its use-by date, recipes with it will not appear.
- If an ingredient is past its best-before date but not the use-by date, recipes with it will appear at the bottom of the response.
For the development, I tried my best to follow some software development best practices such as OOP, SOLID, TDD and Language(Java) conventions and patterns, I used the Google style guide and the Spring boot framework. When separating the classes, I chose to do it by domain. I created some packages as described below, the tests packages reflects it.
-
ingredient Contains the
models(POJOs)
andrepository
classes for the Ingredient domain. -
recipe Contains the
models(POJOs)
andrepository
classes the Recipe domain. -
lunch Contains the
controller
andservice
classes, which contains the API requests/routing and brings the business rules and logic together. -
Application
&ApplicationConfig
These are the runner classes for the API.
Note: I like to follow this template for documenting my architectural decisions.
Here I documented the ARDs for this project.