Skip to content

Latest commit

 

History

History
 
 

hipster-shop

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Cell-Based Hipster Shop Application

All details of the original application, "Hipster Shop: Cloud-Native Microservices Demo Application" can be found here.

The Hipster Shop project contains a 10-tier microservices application. The application is a web-based e-commerce app called “Hipster Shop” where users can browse items, add them to the cart, and purchase them.

Screenshots

Home Page Checkout Screen
Screenshot of store homepage Screenshot of checkout screen
Checkout Cell Frontend Cell
Screenshot of checkout cell Screenshot of front-end cell

Service Architecture

Hipster Shop is composed of many microservices written in different languages that talk to each other over gRPC.

Architecture of microservices

Service Language Description
frontend Go Exposes an HTTP server to serve the website. Does not require signup/login and generates session IDs for all users automatically.
cartservice C# Stores the items in the user's shipping cart in Redis and retrieves it.
productcatalogservice Go Provides the list of products from a JSON file and ability to search products and get individual products.
currencyservice Node.js Converts one money amount to another currency. Uses real values fetched from European Central Bank. It's the highest QPS service.
paymentservice Node.js Charges the given credit card info (mock) with the given amount and returns a transaction ID.
shippingservice Go Gives shipping cost estimates based on the shopping cart. Ships items to the given address (mock)
emailservice Python Sends users an order confirmation email (mock).
checkoutservice Go Retrieves user cart, prepares order and orchestrates the payment, shipping and the email notification.
recommendationservice Python Recommends other products based on what's given in the cart.
adservice Java Provides text ads based on given context words.
loadgenerator Python/Locust Continuously sends requests imitating realistic user shopping flows to the frontend.

Cell Architecture

Hipster Shop is composed of many microservices written in different languages that talk to each other over gRPC. This sample is structured into 5 cells:

Cell architecture of Hipster Shop services

Quick Deploy the Hipster Shop Cells

Execute the command below to deploy the pre-built cell images in one go. If you are interested in building and running the cell images, execute the steps explained here.

cellery run wso2cellery/front-end-cell:latest -n front-end-cell -l cartCellDep:cart-cell -l productsCellDep:products-cell -l adsCellDep:ads-cell -l checkoutCellDep:checkout-cell -d -y

Now view the application.

Build and Deploy the Hipster Shop Cells

1. Clone sample

Clone the wso2-cellery/samples repository and navigate to the samples/cells/hipster-shop/directory.

cd samples/cells/hipster-shop

2. Build and run ads cell

$ cd ads/
$ cellery build ads.bal wso2cellery/ads-cell:latest  

✔ Building image wso2cellery/ads-cell:latest
✔ Removing old Image
✔ Saving new Image to the Local Repository


✔ Successfully built cell image: wso2cellery/ads-cell:latest

What's next?
--------------------------------------------------------
Execute the following command to run the image:
  $ cellery run wso2cellery/ads-cell:latest
--------------------------------------------------------
$ cellery run wso2cellery/ads-cell:latest -n ads-cell
✔ Extracting Cell Image wso2cellery/ads-cell:latest

Main Instance: ads-cell

✔ Reading Cell Image wso2cellery/ads-cell:latest
✔ Validating dependencies

Instances to be Used:

  INSTANCE NAME           CELL IMAGE            USED INSTANCE   SHARED  
 --------------- ----------------------------- --------------- -------- 
  ads-cell        wso2cellery/ads-cell:latest   To be Created    -      

Dependency Tree to be Used:

 No Dependencies

? Do you wish to continue with starting above Cell instances (Y/n)? y

✔ Starting main instance ads-cell


✔ Successfully deployed cell image: wso2cellery/ads-cell:latest

What's next?
--------------------------------------------------------
Execute the following command to list running cells:
  $ cellery list instances
--------------------------------------------------------

3. Build and run products cell

$ cd ../products/
$ cellery build products.bal wso2cellery/products-cell:latest

✔ Building image wso2cellery/products-cell:latest
✔ Removing old Image
✔ Saving new Image to the Local Repository


✔ Successfully built cell image: wso2cellery/products-cell:latest

What's next?
--------------------------------------------------------
Execute the following command to run the image:
  $ cellery run wso2cellery/products-cell:latest
--------------------------------------------------------
$ cellery run wso2cellery/products-cell:latest -n products-cell
✔ Extracting Cell Image wso2cellery/products-cell:latest

Main Instance: products-cell

✔ Reading Cell Image wso2cellery/products-cell:latest
✔ Validating dependencies

Instances to be Used:

  INSTANCE NAME              CELL IMAGE              USED INSTANCE   SHARED  
 --------------- ---------------------------------- --------------- -------- 
  products-cell   wso2cellery/products-cell:latest   To be Created    -      

Dependency Tree to be Used:

 No Dependencies

? Do you wish to continue with starting above Cell instances (Y/n)? y

✔ Starting main instance products-cell


✔ Successfully deployed cell image: wso2cellery/products-cell:latest

What's next?
--------------------------------------------------------
Execute the following command to list running cells:
  $ cellery list instances
--------------------------------------------------------

4. Build and run cart cell

$ cd ../cart/
$ cellery build cart.bal wso2cellery/cart-cell:latest
Warning: Value is empty for environment variable "CART_SERVICE_ADDR"

✔ Building image wso2cellery/cart-cell:latest
✔ Removing old Image
✔ Saving new Image to the Local Repository


✔ Successfully built cell image: wso2cellery/cart-cell:latest

What's next?
--------------------------------------------------------
Execute the following command to run the image:
  $ cellery run wso2cellery/cart-cell:latest
--------------------------------------------------------
$ cellery run wso2cellery/cart-cell:latest -n cart-cell
✔ Extracting Cell Image wso2cellery/cart-cell:latest

Main Instance: cart-cell

✔ Reading Cell Image wso2cellery/cart-cell:latest
✔ Validating dependencies

Instances to be Used:

  INSTANCE NAME            CELL IMAGE            USED INSTANCE   SHARED  
 --------------- ------------------------------ --------------- -------- 
  cart-cell       wso2cellery/cart-cell:latest   To be Created    -      

Dependency Tree to be Used:

 No Dependencies

? Do you wish to continue with starting above Cell instances (Y/n)? y

Warning: Value is empty for environment variable "CART_SERVICE_ADDR"
✔ Starting main instance cart-cell


✔ Successfully deployed cell image: wso2cellery/cart-cell:latest

What's next?
--------------------------------------------------------
Execute the following command to list running cells:
  $ cellery list instances
--------------------------------------------------------

5. Build and run checkout cell

$ cd ../checkout
$ cellery build checkout.bal wso2cellery/checkout-cell:latest

✔ Building image wso2cellery/checkout-cell:latest
✔ Removing old Image
✔ Saving new Image to the Local Repository


✔ Successfully built cell image: wso2cellery/checkout-cell:latest

What's next?
--------------------------------------------------------
Execute the following command to run the image:
  $ cellery run wso2cellery/checkout-cell:latest
--------------------------------------------------------
$ cellery run wso2cellery/checkout-cell:latest -n checkout-cell -l cartCellDep:cart-cell -l productsCellDep:products-cell -d
✔ Extracting Cell Image wso2cellery/checkout-cell:latest

Main Instance: checkout-cell

✔ Reading Cell Image wso2cellery/checkout-cell:latest
✔ Validating dependency links
✔ Generating dependency tree
✔ Validating dependency tree

Instances to be Used:

  INSTANCE NAME              CELL IMAGE                 USED INSTANCE       SHARED  
 --------------- ---------------------------------- ---------------------- -------- 
  cart-cell       wso2cellery/cart-cell:latest       Available in Runtime    -      
  products-cell   wso2cellery/products-cell:latest   Available in Runtime    -      
  checkout-cell   wso2cellery/checkout-cell:latest   To be Created           -      

Dependency Tree to be Used:

 checkout-cell
   ├── cartCellDep: cart-cell
   └── productsCellDep: products-cell

? Do you wish to continue with starting above Cell instances (Y/n)? y

✔ Starting dependencies
✔ Starting main instance checkout-cell


✔ Successfully deployed cell image: wso2cellery/checkout-cell:latest

What's next?
--------------------------------------------------------
Execute the following command to list running cells:
  $ cellery list instances
--------------------------------------------------------

6. Build and run front-end cell

$ cd ../front-end
$ cellery build front-end.bal wso2cellery/front-end-cell:latest

✔ Building image wso2cellery/front-end-cell:latest
✔ Removing old Image
✔ Saving new Image to the Local Repository


✔ Successfully built cell image: wso2cellery/front-end-cell:latest

What's next?
--------------------------------------------------------
Execute the following command to run the image:
  $ cellery run wso2cellery/front-end-cell:latest
--------------------------------------------------------
$ cellery run wso2cellery/front-end-cell:latest -n front-end-cell -l cartCellDep:cart-cell -l productsCellDep:products-cell -l adsCellDep:ads-cell -l checkoutCellDep:checkout-cell -d
✔ Extracting Cell Image wso2cellery/front-end-cell:latest

Main Instance: front-end-cell

✔ Reading Cell Image wso2cellery/front-end-cell:latest
⚠ Using a shared instance cart-cell for duplicated alias cartCellDep
⚠ Using a shared instance products-cell for duplicated alias productsCellDep
✔ Validating dependency links
✔ Generating dependency tree
✔ Validating dependency tree

Instances to be Used:

  INSTANCE NAME               CELL IMAGE                  USED INSTANCE       SHARED  
 ---------------- ----------------------------------- ---------------------- -------- 
  checkout-cell    wso2cellery/checkout-cell:latest    Available in Runtime    -      
  products-cell    wso2cellery/products-cell:latest    Available in Runtime   Shared  
  ads-cell         wso2cellery/ads-cell:latest         Available in Runtime    -      
  cart-cell        wso2cellery/cart-cell:latest        Available in Runtime   Shared  
  front-end-cell   wso2cellery/front-end-cell:latest   To be Created           -      

Dependency Tree to be Used:

 front-end-cell
   ├── checkoutCellDep: checkout-cell
   ├── productsCellDep: products-cell
   ├── adsCellDep: ads-cell
   └── cartCellDep: cart-cell

? Do you wish to continue with starting above Cell instances (Y/n)? y

✔ Starting dependencies
✔ Starting main instance front-end-cell


✔ Successfully deployed cell image: wso2cellery/front-end-cell:latest

What's next?
--------------------------------------------------------
Execute the following command to list running cells:
  $ cellery list instances
--------------------------------------------------------

7. Viewing the cells

Now all the application cells are deployed. Run the following command to see the status of the deployed cells.

$ cellery list instances
 INSTANCE                 CELL IMAGE               STATUS               GATEWAY               COMPONENTS            AGE           
 ---------------- ----------------------------------- -------- --------------------------------- ------------ ----------------------- 
  ads-cell         wso2cellery/ads-cell:latest         Ready    ads-cell--gateway-service         1            52 minutes 22 seconds  
  cart-cell        wso2cellery/cart-cell:latest        Ready    cart-cell--gateway-service        2            18 minutes 30 seconds  
  checkout-cell    wso2cellery/checkout-cell:latest    Ready    checkout-cell--gateway-service    5            11 minutes 10 seconds  
  front-end-cell   wso2cellery/front-end-cell:latest   Ready    front-end-cell--gateway-service   1            3 minutes 19 seconds   
  products-cell    wso2cellery/products-cell:latest    Ready    products-cell--gateway-service    2            26 minutes 55 seconds 

Run cellery view command to see the components of your cell. This will open a HTML page in a browser and you can visualize the components and the dependent cells of the cell.

$ cellery view wso2cellery/ads-cell:latest

Cell architecture of Hipstershop services

$ cellery view wso2cellery/products-cell:latest

Cell architecture of Hipstershop services

$ cellery view wso2cellery/cart-cell:latest

Cell architecture of Hipstershop services

cellery view wso2cellery/checkout-cell:latest

Cell architecture of Hipstershop services

cellery view wso2cellery/front-end-cell:latest

Cell architecture of Hipstershop services

8. View the application

You would have already added the /etc/host entries during the cellery installation as mentioned in local, GCP and existing kubernetes cluster. You will also need to add the entry my-hipstershop.com to the /etc/host file as shown below.

192.168.56.10 wso2-apim cellery-dashboard wso2sp-observability-api wso2-apim-gateway cellery-k8s-metrics idp.cellery-system pet-store.com hello-world.com my-hello-world.com my-hipstershop.com

Access url http://my-hipstershop.com/ from a browser and you can now try out the Hipster Shop application.

Cell architecture of Hipstershop services

Cell architecture of Hipstershop services

Observability

The hipster shop cells and components can be observed in runtime, and it provides overview about the cells, components, metrics, and distributed tracing. Below are some of the screenshots of observability provided by http://cellery-dashboard. You can find more information about the observability here.


Cells overview.

Cell overview of Hipstershop services


Overview of the components in checkout-cell

Component overview of checkout-cell


Metrics for component checkout

Component overview of checkout-cell


List of cells in the runtime

List cells


List of components in checkout-cell.

List components