Skip to content

marouaneabk/core-abstract-sample

 
 

Repository files navigation

Shoe Shop API

This application API used to expose resources to manage Stock.

Prerequisites

  • JDK 14
  • Spring Boot
  • Liquibase H2
  • Maven (wrapper to simplify ./mvnw)
  • Add lombok plugin in your favorite IDE (IntelliJ)
  • github-action

Workflow

The workflow for development is based on trunk based workflow. Master or main branch is used for current feature development, branches called next are used for next delivery. Next is branch must be stabilized by the development team for delivery, not the process of quality assurance that can slow down development, it's continuous delivery with CI / CD.

More description of the workflow is available on the git workflow

Running the project locally

Once everything is set up you can run the project using your favorite IDE or directly with maven. To start your application , simply run:

./mvnw clean install && java -jar controller/target/controller-1.0.jar

Architecture project

image

Liquibase

The database is generated by liquibase when starting the application.

H2:

The database is consulted by this console h2 http://localhost:8080/h2-console

Delivery

Pipeline is launched automatically following each push in any branch:

  • Job CI: Checkout - Build - Test - Sonar - Upload artifact in github
  • Job CD: Checkout - Deploy in heroku

Consult workflow pipeline in git repository Consult pipeline result action

Testing

To launch your application's tests, run:

./mvnw clean test

Access endpoints to test

The application exposes the API documentation, testable /swagger-ui/ of the application :

http://[host:port]/swagger-ui/ (ex en local : http://localhost:8080/swagger-ui/)

APIs REST Endpoints

Fetch stock with state:

curl -X GET "http://localhost:8080/stock" -H "accept: application/json" -H "version: 3"

Response 200 body :

{
  "state": "SOME",
  "shoes": [
    {
      "size": 12,
      "color": "BLUE",
      "quantity": 10
    },
    {
      "size": 8,
      "color": "BLUE",
      "quantity": 0
    }
  ]
}

Replace stock with collection of shoes sent as input:

curl -X PATCH "http://localhost:8080/stock" -H "accept: */*" -H "version: 3" -H "Content-Type: application/json" -d 
{
    "shoes": [
        {
            "name": "baskets",
            "color": "BLUE",
            "size": 36,
            "quantity": 10
        },
        {
            "name": "classique",
            "color": "BLUE",
            "size": 12,
            "quantity": 1
        }
    ]
}

Response:

  • 204 No content
  • 400 Stock collection contains duplication shoes or stock capacity greater than 30 shoes

Add shoes to the stock

curl -X PATCH "http://localhost:8080/stock/shoes" -H "accept: application/json" -H "version: 3" -H "Content-Type: application/json" -d 
{ 
    "name": "basket",
    "color":"BLACK",
    "quantity":0,
    "size":0
}

Response:

  • 204 No content
  • 400 Stock capacity limited of 30 shoes

Deploy to heroku:

Deploy in heroku by git:

Developer can manages Heroku app deployments with Git heroku git Consult the logs heroku:

logs --tail

Deploy in heroky by github action module:

This is a very simple GitHub action that allows you to deploy to Heroku heroku github-Action

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 100.0%