kuncie-takehome-test

command module
v0.0.0-...-e83584d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 10, 2021 License: MIT Imports: 16 Imported by: 0

README

Kuncie Backend Test

Have you shopped online? Let’s imagine that you need to build the checkout backend service that will support different promotions with the given inventory.

Build a checkout system with these items:

gambar

The system should have the following promotions:

  • Each sale of a MacBook Pro comes with a free Raspberry Pi B
  • Buy 3 Google Homes for the price of 2
  • Buying more than 3 Alexa Speakers will have a 10% discount on all Alexa speakers

Example Scenarios:

  • Scanned Items: MacBook Pro, Raspberry Pi B
    • Total: $5,399.99
  • Scanned Items: Google Home, Google Home, Google Home
    • Total: $99.98
  • Scanned Items: Alexa Speaker, Alexa Speaker, Alexa Speaker
    • Total: $295.65

Please write it in Golang or Node with a CI script that runs tests and produces a binary.

Finally, imagine that adding items to cart and checking out was a backend API. Please design a schema file for GraphQL on how you would do this.

Thank you for your time and we look forward to reviewing your solution. If you have any questions, please feel free to contact us. Please send us a link to your git repo.

Database Schema

kuncie-db-schema

Building and Running The App

Prerequisites:

Go 1.16.9
Docker
Docker Compose
Golang migrate (https://github.com/golang-migrate/migrate)

Step 1 Checkout

$ git clone https://github.com/handika/kuncie-takehome-test.git
$ cd kuncie-backend-test

Step 2 Start MySQL Service

$ docker-compose up

Step 3 Run Migration

$ migrate -database mysql://kuncie:kuncie@/kuncie_store -path ./sql up

Step 4 GraphiQL Playground

http://localhost:9090/

Step 5 Calling APIs

Scanned Items: MacBook Pro, Raspberry Pi B

mutation {
  StoreTransaction(input: {user_id: 1, items: [{product_id: 2, qty: 1}, {product_id: 4, qty: 1}]})
}

Scanned Items: Google Home, Google Home, Google Home

mutation {
  StoreTransaction(input: {user_id: 1, items: [{product_id: 1, qty: 3}]})
}

Scanned Items: Alexa Speaker, Alexa Speaker, Alexa Speaker

mutation {
  StoreTransaction(input: {user_id: 1, items: [{product_id: 3, qty: 3}]})
}

Get Transaction

query {
  GetTransactionByID(id: 1) {
    id
    date
    grand_total
  }
}

Testing App

go test ./... -cover -vet -all -v

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
pdr
mocks
Code generated by mockery v1.0.0
Code generated by mockery v1.0.0
mocks
Code generated by mockery v1.0.0
Code generated by mockery v1.0.0
ppr
mocks
Code generated by mockery v1.0.0
Code generated by mockery v1.0.0
mocks
Code generated by mockery v1.0.0
Code generated by mockery v1.0.0
mocks
Code generated by mockery v1.0.0
Code generated by mockery v1.0.0

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL