Skip to content

Latest commit

 

History

History
 
 

pet-store

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

Pet Store

Pet Store is a web portal which can be used by the customers for ordering accessories for their Pets.

This sample is a simple webapp which consists of 5 Docker images (4 microservices and a container to serve the web portal).

  • Catalog (Catalog of the accessories available in the pet store)
  • Customers (Existing customers of the Pet Store)
  • Orders (Orders placed at the Pet Store by Customers)
  • Controller (Controller service which fetches data from the above 3 microservices and processes them to provide useful functionality)
  • Portal (A simple Node JS container serving a React App with Server Side Rendering)

All 4 micro services are implemented in node.js and portal web application is a React application.

This sample is structured into two Cells.

Pet Store Cell Architecture Diagram

This contains the four components which involves with working with the Petstore data and business logic Only catalog micro service exposed via cell pet-fe gateway which is used by pet-fe cell. Catalog, customer, and order micro services are not exposed outside the pet-be cell.

This contains a single component portal, and it is exposed through a web cell which is able to provide SSO and web content delivery features.

This Pet store sample includes,

  1. Quick run
  2. View application
  3. Build the cells by your own
  4. Test cell
  5. Observability
  6. Update cell
  7. Scale cell

Quick run

  1. Pet store application can be started by executing the single command as shown below.
 $ cellery run wso2cellery/pet-fe-cell:latest -n pet-fe -l petStoreBackend:pet-be -d -y
  1. Executed cellery list instances and make sure pet-be and pet-fe cells are Ready as shown below.
  $ cellery list instances
  
  INSTANCE             CELL IMAGE             STATUS           GATEWAY           COMPONENTS           AGE
 ---------- -------------------------------- -------- ------------------------- ------------ ---------------------
  pet-be     wso2cellery/pet-be-cell:latest   Ready    pet-be--gateway-service   4            2 hours 47 minutes
  pet-fe     wso2cellery/pet-fe-cell:latest   Ready    pet-fe--gateway-service   1            3 hours 16 minutes
  1. Now view the application by following the instructions.

View application

  1. Access the petstore add via accessing http://pet-store.com/. You will be landed in the home page of cellery. As / is configured to be as unsecured context as described here, you can see the content of home page without logging in.

  2. Click on sign in, and you will be directed to the default IDP installed within cellery runtime. You can sign in as user alice (Username: alice, Password: alice123), and fill the customer information form. This operation will invoke the controller and customer micro-services from the pet store portal web application.

customer info

pet preference info

  1. Once you logged in to the portal application, you can add items to the cart. And then click on the cart to checkout the items. This operation will invoke controller and catalog micro-services.

add to cart

checkout

  1. Return to the home page and click on the orders button which will show the orders placed by that user.

orders

  1. You can logout from pet-store as alice user, and you can login as different user admin (Username: admin, Password:admin), and check for orders, which will return a empty orders as admin user hasn't placed any order. Therefore, you can realize the pet-store application user specific information.

If you are interested getting in working more with Cellery, you can build and run the sample in your own. You can also make the changes to the cell files, or actual source of this sample and try out. Please follow the instructions provided here to build and run the pet store application.

Checkout the application source of the pet-fe and pet-be, and feel free to play around the source code. Follow the instructions provided here to build from source.

You can test the cell endpoints by running cell integration tests. Try running the first test case to validate the orders endpoint of the Petstore backend by following the instructions given here.

You can observe the pet-store application in runtime, and view cell overeview, request traces, metrics, dependency diagram and much more. Cellery observability mainly supported by Cellery Dashboard. Please follow the instructions provided here to use observability with pet-store.

In this section, we focus on how the cells can be updated in the runtime without having a considerable downtime. Cellery supports rolling updates, and advanced deployments such as blue-green and canary updates. In this sample, we provide step-by-step details on how to update the pet-be cell with the new version by rolling update, blue-green and canary update. Please follow the instructions provided here to update the pet-be cell.

In this section, we focus on attaching autoscaling policy and zero scaling policy to pet-be cell. We also use a load-gen cell to generate the load and test the functionality. Please follow the instructions here to get more detailed steps.

Did you try?

  1. Hello world
  2. Hello world Api

What's Next?