GithubHelp home page GithubHelp logo

challengue-recipes's Introduction

Project Documentation for Technical Evaluation

Project description

The project is developed in Spring Boot 2.7.17.RELEASE on Java 17. It exposes two Full REST services that allow queries on an H2 database, which is loaded with data obtained from spoonacular API.

Previous requirements

Make sure you have Java and Maven installed on your system before running this project.

Project Configuration

  1. Clone the Repository:

    git clone https://github.com/marianocamarzana/challengue-recipes
    
  2. Compile the Project:

    mvn clean install

Project execution

  1. Run the Application:

    mvn spring-boot:run

    The application will be available in http://localhost:8080.

  2. Available Endpoints

    Task 1. API for Data Sourcing:

    • POST /api/challengue/recipe
      • { "query": "burger"}:
      • Steps
        • 1 - Retrieve the recipes according to the QUERY filter through the spoonacular API
        • 2 - Recipes are persisted in the H2 database as long as they have not been previously persisted.

    Task 2. APIs to Serve Data to a Recipes App:

    • GET /api/challengue/recipe

      • ids: ids is a list of recipe identifiers that will be used to retrieve recipes from the database.
      • Retrieves the list of recipes from the H2 Database filtering by the list of ids. If ids are not sent, all recipes are recovered.
    • PATCH /api/challengue/recipe/{id}/score

      • { "score": "4" }
      • Update a specific recipe with the indicated score.

    Task 3. APIs to Serve Data to a Recipes App:

    • PATCH /api/challengue/recipe/{id}/detail
      • 1 - The recipe detail is retrieved from the API and instead of mapping the model that involves many relationships, it is uses the ResponseEntity object, where the response body is of type String. To extract the desired field from the JSON response Jackson library is used.
      • 2 - The specific recipe is recovered from the database
      • 3 - The recipe is updated and subsequently persisted in the database
  3. Additional configuration

    • Configuration was added to the project so that the solution can be embedded within the following docker image openjdk:11.0.6-jre.
      • Run the following command to build the Docker image:
        mvn spring-boot:run
      • Run the Docker container:
        • Once the Docker image is successfully built, you can run the container with the following command:
        docker run -p 8080:8080 image-name
        This will map port 8080 of the container to port 8080 of your local machine, allowing you to access your Spring application through http://localhost:8080.
  4. Security

    • For the challenge, authentication was added to the application through Spring Security using Basic Auth, for commercial applications OAuth2 is used since it provides a more robust level of security compared to Basic Authentication. Instead of sending credentials (username and password) in each request, OAuth2 uses access tokens that have a limited lifespan and do not contain sensitive information. This reduces the risk of credential exposure and improves the overall security of the application.

Project Structure

The project structure follows the conventions of a Spring Boot project:

  • src/main/java: Contains the source code of the application.
    • com.evaluacion.tecnica: Main package.
      • configuration: Application Settings.
      • controller: Endpoint drivers.
      • Model: Contains the models used for the persistence layer.
      • dto: Common models used as responses in own services.
      • repository: JPA repository.
      • service: Interface where the methods that will carry out the business logic are declared.
      • service.impl: Implementation of the methods that will carry out the business logic.

Use of Lombok

This project uses Lombok to reduce code verbosity. Make sure you have the Lombok plugin installed in your IDE for proper functioning.

Exception handling and validations.

Different use cases were considered in which exceptions and validations must be treated correctly.

Swagger

The project is documented using Swagger. To access its documentation with the possibility of carrying out invocation tests, go to: http://localhost:8080/swagger-ui/index.html

Postman

The Postman collection is available with the developed endpoints codeChallengueRecipes.postman_collection

Main Technologies Used

  • Spring Boot: Framework for the development of Java applications based on the principle of convention over configuration.
  • Lombok: Library that speeds up development by eliminating the need to write boilerplate code.
  • ModelMapper: Allows mapping between entities and DTOs automatically.
  • H2 Database: Embedded database written in Java.

License

This project is licensed MIT.

challengue-recipes's People

Contributors

marianocamarzana avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.