Skip to content

A pet-project shop application using Tagless Final approach

Notifications You must be signed in to change notification settings

Mee-Tree/shopping-cart

Repository files navigation

Shopping Cart

Scala CI Scala Steward badge Cats friendly

Tech Stack

Every used library can be found in Dependencies.scala.

Overview

A pet-project shop application using Tagless Final approach.

Open HTTP endpoints


  • POST /auth/register
    • 201: user was successfully created
    • 400: invalid username or password
    • 409: the username is already taken
  • POST /auth/login
    • 200: user was successfully logged in
    • 403: invalid username or password
  • GET /brands
    • 200: returns a list of brands
  • GET /categories
    • 200: returns a list of categories
  • GET /items
    • 200: returns a list of items
  • GET /items?brand={name}
    • 200: returns a list of items with the specified brand

Secure HTTP endpoints (requiring an Auth Token returned by /auth endpoints)

All of them can return the following response statuses in addition to the specific ones.

  • 401: unauthorized user, needs to log in
  • 403: the user does not have permission to perform this action

  • POST /auth/logout
    • 204: user was successfully logged out
  • GET /cart
    • 200: returns the cart for the current user
  • POST /cart
    • 201: item was added to the cart
    • 409: item is already in the cart
  • PUT /cart
    • 200: quantity of some items were updated in the cart
    • 400: quantities must be greater than zero
  • DELETE /cart/{itemId}
    • 204: the specified item was removed from the cart, if it existed
  • POST /checkout
    • 201: order was processed successfully
    • 400: invalid card details
  • GET /orders
    • 200: returns the list of orders for the current user
  • GET /orders/{orderId}
    • 200: returns specific order for the current user
    • 404: order not found

Admin HTTP endpoints (can be accessed only by admins with a specific Access Token)

Can return 401 and 403 for the same reasons as Secure HTTP endpoints.


  • POST /brands
    • 201: brand successfully created
    • 409: brand name is already taken
  • POST /categories
    • 201: category successfully created
    • 409: category name is already taken
  • POST /items
    • 201: items successfully created
    • 409: some of the items already exist
  • PUT /items
    • 200: item’s price successfully updated
    • 400: the price must be greater than zero

Tests

To run Unit Tests:

sbt test

To run Integration Tests you need to run both PostgreSQL and Redis:

docker-compose up
sbt IntegrationTest/test
docker-compose down

Payment Client

The configured payment client is a fake API (https://beeceptor.com/console/payments) that always returns 200 with a Payment Id.

About

A pet-project shop application using Tagless Final approach

Resources

Stars

Watchers

Forks

Languages