couponservice

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

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

Go to latest
Published: Feb 22, 2021 License: Apache-2.0 Imports: 14 Imported by: 0

README

CouponService

A Coupon Microservice that extends Google's Online Boutique Microservices Demo. This Microservice enables the customers to redeem coupons (discount codes) during checkout and get discounts on their purchases.

Design

CouponService has been designed to be a very minimal Microservice. It receives the requests from CheckoutService, validates it by checking whether the queried code can be found in its in-memory database (populated with entries from coupons.csv) and responds with the discount in percentage. If the coupon is invalid, the discount will be 0 percent, and if it's valid it will be in range ]0,100].

The actual discount is then applied in CheckoutService internally and the new prices will be reflected in all other Services (e.g. PaymentService, EmailService) that use the order information.

Configuration

To change the list of valid discount codes, please edit the coupons.csv file.

To change the port of the service, please change the variable PORT in Dockerfile

Running standalone

This Service is meant to be run with other Services, in particular at least with the CheckoutService. In order to run standalone:

docker build . -t couponservice
docker run couponservice

Running with other services

For running with other services, please follow the local deployment quickstart instructions in microservices repo.

Architecture

Screenshots

Invalid coupon code Valid coupon code with 40% discount
Checkout with invalid coupon code Checkout with valid coupon code
Completed order with invalid coupon code Completed order with valid coupon code

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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