Skip to content

yigithanbalci/shopping-cart

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

68 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

shopping-cart

Shopping cart example

CircleCI Coverage Maintainability Rating Reliability Rating Security Rating

run

mvn spring-boot run

swagger docs

http://localhost:8080/swagger-ui.html

AWS Deployment with ECS (Fargate), ECR and EC2 loadbalancer

terraform init
terraform apply
docker build -t shopping-cart-ecr-repo .
docker tag shopping-cart-ecr-repo:latest your-ecr-link.amazonaws.com/shopping-cart-ecr-repo:latest
docker push your-ecr-link.amazonaws.com/shopping-cart-ecr-repo:latest

Users for authentication and authorizatioon

Username Password Role
admin admin ADMIN
user1 user1 USER
user2 user2 USER
user3 user3 USER
user4 user4 USER

Http Status

  • 200 OK: The request has succeeded
  • 201 Created: The request has created
  • 401 UnAuthorized: The request lacks valid authentication credentials for the target resource
  • 403 Forbidden: The server understood the request but refuses to authorize it.
  • 404 Not Found: The requested resource cannot be found
  • 500 Internal Server Error: The server encountered an unexpected condition

Sample Jsons


item

{
  "drink": {
    "name": "Latte",
    "price": 6.0
  },
  "toppings": [
    {
      "name": "Milk",
      "price": 2.0
    }
  ],
  "amount": 8.0
}

cart

{
  "items": [
    {
      "drink": {
        "name": "Black Coffee",
        "price": 5.0
      },
      "toppings": [
        {
          "name": "Maple Syrup",
          "price": 2.0
        }
      ],
      "amount": 2.0
    }
  ],
  "amount": 7.0
}

topping

{
  "name": "Lemon",
  "price": 1.0
}

example requests via curl

POST DRINK
curl -u admin:admin -X POST "http://localhost:8080/admin/products/drinks" -H "accept: application/json" -H "Content-Type: application/json" -d "{\"name\":\"Americano\",\"price\":5.0}"

DELETE TOPPING
curl -u admin:admin -X DELETE "http://localhost:8080/admin/products/toppings/1" -H "accept: */*"

GET TOPPINGS
curl -u user1:user1 -X GET "http://localhost:8080/products/toppings" -H "accept: application/json"

GET TOTAL ORDERS
curl -u admin:admin -X GET "http://localhost:8080/admin/reports/users/total-orders" -H "accept: application/json"

PUT ITEM
curl -u user2:user2 -X PUT "http://localhost:8080/users/2/cart" -H "accept: application/json" -H "Content-Type: application/json" -d "{\"drink\":{\"name\":\"Latte\",\"price\":5.0},\"toppings\":[{\"name\":\"Lemon\",\"price\":1.0}],\"amount\":6.0}"

PUT CART (CHECKOUT CART)
curl -u user1:user1 -X PUT "http://localhost:8080/users/1/cart/checkout" -H "accept: application/json"

Note

Coverage not included dev, config and dto classes.
Documentatıon might be out-dated check swagger-ui to be sure.
Needs some refactor especially in cleanness of tests.
Feel free to contribute!

About

Shopping cart example

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published