Coder Social home page Coder Social logo

appzara's Introduction

Rest API APPZARA

This is a microservice rest for ZARA recruitment.

About this project

About

Business rules

Given a day and time, a database search is carried out to bring up the price with the tariff to be applied. If more than one element is found, some rules will apply:

  • If the result finds two rates that coincide, the one with the highest value will apply.

Architecture

Architecture-hexagonal.png

APPLICATION

Layer that implements the UseCase and contains the business rule

BOOTSTRAP

This module is responsible for instantiating the other modules of the application. As the name suggests, it is the bootstrap.

DOMAIN

Module containing the application entities.

INFRASTRUCTURE

Infrastructure layer that connects to database and other services.

Technologies

  • Java 21
  • Spring boot 3.2.3
  • Spring Data
  • Database H2 Memory
  • Mapstruct
  • Junit
  • Mockito
  • Jacoco Reporter

How to Run

Clone the repository:

git clone clone https://github.com/LauroSilveira/appzara.git

Get in the appzara folder:

cd appzara/appzara

how to execute the Spring context put following command in your prompt:

mvn spring-boot:run

And how to stop:

ctrl c

In the Infrastructure module there is a PriceController with a GET endpoint with the following parameters:

  • startDate (mandatory): date must be int the format yyyy-MM-dd-HH.mm.ss e.g. 2020-06-16-21.00.00
  • productId (mandatory): id of product e.g. 35455
  • brandId (mandatory): id of brand e.g: 1 (ZARA)

Lets see some examples of request

Request to day 14 of 2020 at 10:00 hrs

curl --location 'http://localhost:8080/price/startDate/2020-06-14-10.00.00/productId/35455/brandId/1'

The response will be:

{
  "brandId": 1,
  "productId": "35455",
  "priority": 1,
  "rate": 4,
  "startDate": "2020-06-15T16:00:00",
  "endDate": "2020-12-31T23:59:59",
  "amount": 38.95
}

Request to day 14 of 2020 at 16:00 hrs

curl --location 'http://localhost:8080/price/startDate/2020-06-14-16.00.00/productId/35455/brandId/1'

The response will be:

{
  "brandId": 1,
  "productId": "35455",
  "priority": 1,
  "rate": 4,
  "startDate": "2020-06-15T16:00:00",
  "endDate": "2020-12-31T23:59:59",
  "amount": 38.95
}

Request to day 14 of 2020 at 21:00 hrs

curl --location 'http://localhost:8080/price/startDate/2020-06-14-21.00.00/productId/35455/brandId/1'

The response will be:

{
    "brandId": 1,
    "productId": "35455",
    "priority": 1,
    "rate": 4,
    "startDate": "2020-06-15T16:00:00",
    "endDate": "2020-12-31T23:59:59",
    "amount": 38.95
}

Request to day 15 of 2020 at 21:00 hrs

curl --location 'http://localhost:8080/price/startDate/2020-06-15-21.00.00/productId/35455/brandId/1'

The response will be:

{
  "brandId": 1,
  "productId": "35455",
  "priority": 1,
  "rate": 3,
  "startDate": "2020-06-15T00:00:00",
  "endDate": "2020-06-15T11:00:00",
  "amount": 30.50
}

Request to day 16 of 2020 at 21:00 hrs

curl --location 'http://localhost:8080/price/startDate/2020-06-16-21.00.00/productId/35455/brandId/1'

The response will be:

{
    "brandId": 1,
    "productId": "35455",
    "priority": 1,
    "rate": 3,
    "startDate": "2020-06-15T00:00:00",
    "endDate": "2020-06-15T11:00:00",
    "amount": 30.50
}

How to run Tests

This project has jacoco-report with we are able to see coverage after execute tests. There is unit tests and integration test. The integration test has the annotation @ActiveProfile("test") with you want to execute it. To execute all test just run:

mvn test

After execute tests jacoco-report will generate an index.html file with coverage. The directory of this file is appzara/bootstrap/target/site/jacoco-aggregate/index.html.

directory_index_jacoco.png

Open it in your default browser to see the coverage of each module

coverage-updated.png

Contributors

@LauroSilveira

appzara's People

Contributors

laurosilveira avatar

Stargazers

Alexandro Castro 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.