karenkgs / recipesAPI

A Java API to return recipes based on what ingredients you have on your fridge.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Recipes API

A Java API to return recipes based on what ingredients you have on your fridge.


Importing the Project

  • Make sure you have:
    • Java (min. version 8) installed
    • Maven installed

Installing using IntelliJ

  • Import the project -> Select the root folder -> Next import project
  • Select Import project from external model -> Select Maven line -> Next
  • Select use auto-import checkbox -> Finish auto import

    Note: If the code is not working, open the Maven tab Press Reimport all Maven projects

Running the code

  • The Application.java class is the main class. Run its main method.

Running with the terminal

  • On the project root folder run mvn spring-boot:run
    cd /yourFolder/rootProjectFolder
    mvn spring-boot:run
    

Running the tests

  • Open the src/test folder
  • Right-click on java folder -> Run all tests run tests

Running with the terminal

  • On the project root folder run mvn test
    cd /yourFolder/rootProjectFolder
    mvn test
    

Downloads

Using the API

/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.

About the Solution

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) and repository classes for the Ingredient domain.

  • recipe Contains the models(POJOs) and repository classes the Recipe domain.

  • lunch Contains the controller and service 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.

Architectural Decisions

Note: I like to follow this template for documenting my architectural decisions.

Here I documented the ARDs for this project.

About

A Java API to return recipes based on what ingredients you have on your fridge.

License:Apache License 2.0


Languages

Language:Java 100.0%