Explore sample apps

After creating a local cluster, follow the instructions below to run the Yugastore application.

After running Yugastore, we recommend running the IoT Fleet Management application. This app is built on top of YugabyteDB as the database (using the YCQL API), Confluent Kafka as the message broker, KSQL or Apache Spark Streaming for real-time analytics and Spring Boot as the application framework.

Yugastore-java app is an end-to-end ecommerce application built using a microservices design pattern. React UI, Spring Boot app framework and YugabyteDB (both YSQL and YCQL) are used as the underlying technology stack.

1. Create cluster

Create a cluster.

  1. $ ./bin/yb-ctl create

Clients can now connect to the YSQL API at localhost:5433 and YCQL API at localhost:9042.

2. Install Yugastore

Clone the repo.

  1. $ git clone https://github.com/yugabyte/yugastore-java.git
  1. $ cd yugastore-java

Create the app binaries.

  1. $ mvn -DskipTests package

Create the app’s schema in YugabyteDB.

  1. $ cd resources
  1. $ $YUGABYTE_HOME/bin/ysqlsh -f schema.sql
  1. $ $YUGABYTE_HOME/bin/cqlsh -f schema.cql

Load the initial data.

  1. $ ./dataload.sh

3. Start the app

Start the Eureka discovery service. After starting, verify that the service is running at http://localhost:8761/.

  1. $ cd eureka-server-local/ && mvn spring-boot:run

Start the API gateway microservice.

  1. $ cd api-gateway-microservice/ && mvn spring-boot:run

Start the products microservice.

  1. $ cd products-microservice/ && mvn spring-boot:run

Start the checkout microservice.

  1. $ cd checkout-microservice/ && mvn spring-boot:run

Start the UI service. After starting, browse the app at http://localhost:8080/.

  1. $ cd react-ui/ && mvn spring-boot:run

4. Add items to the cart

Add two items to the cart as shown below.

yugastore-java checkout

Verify that your cart is now stored inside the YSQL shopping_cart table. From your YugabyteDB local cluster home, run the following.

  1. $ ./bin/ysqlsh
  1. yugabyte=# select * from shopping_cart;
  1. cart_key | user_id | asin | time_added | quantity
  2. ------------------+---------+------------+-------------------------+----------
  3. u1001-0001048236 | u1001 | 0001048236 | 2019-05-29T13:46:54.046 | 1
  4. u1001-0001048775 | u1001 | 0001048775 | 2019-05-29T13:46:56.055 | 1
  5. (2 rows)

5. Verify the completed order

Now complete the checkout and observe the order number generated.

yugastore-java order confirmation

Verify that this order number is now in the YCQL orders table.

  1. $ ./bin/cqlsh localhost
  1. cqlsh> select * from cronos.orders;
  1. order_id | user_id | order_details | order_time | order_total
  2. --------------------------------------+---------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------------------------+-------------
  3. 119b96dc-7d1a-4f2f-a1dd-36def25348e0 | 1 | Customer bought these Items: Product: The Sherlock Holmes Audio Collection, Quantity: 1; Product: Measure for Measure: Complete & Unabridged, Quantity: 1; Order Total is : 741.95 | 2019-05-29T13:54:04.093 | 741.95

Verify that there are no active shopping carts in YSQL at this point.

  1. yugabyte=# select * from shopping_cart;
  1. cart_key | user_id | asin | time_added | quantity
  2. ----------+---------+------+------------+----------
  3. (0 rows)

6. Run IoT Fleet Management app

After running Yugastore, we recommend running the IoT Fleet Management app. This app is built on top of YugabyteDB as the database (using the YCQL API), Confluent Kafka as the message broker, KSQL or Apache Spark Streaming for real-time analytics and Spring Boot as the application framework.

Yugastore-java app is an end-to-end ecommerce application built using a microservices design pattern. React UI, Spring Boot app framework and YugabyteDB (both YSQL and YCQL) are used as the underlying technology stack.

1. Create cluster

Create a cluster.

  1. $ ./bin/yb-ctl create

Clients can now connect to the YSQL API at localhost:5433 and YCQL API at localhost:9042.

2. Install Yugastore

Clone the repo.

  1. $ git clone https://github.com/yugabyte/yugastore-java.git
  1. $ cd yugastore-java

Create the app binaries.

  1. $ mvn -DskipTests package

Create the app’s schema in YugabyteDB.

  1. $ cd resources
  1. $ $YUGABYTE_HOME/bin/ysqlsh -f schema.sql
  1. $ $YUGABYTE_HOME/bin/cqlsh -f schema.cql

Load the initial data.

  1. $ ./dataload.sh

3. Start the app

Start the Eureka discovery service. After starting, verify that the service is running at http://localhost:8761/.

  1. $ cd eureka-server-local/ && mvn spring-boot:run

Start the API gateway microservice.

  1. $ cd api-gateway-microservice/ && mvn spring-boot:run

Start the products microservice.

  1. $ cd products-microservice/ && mvn spring-boot:run

Start the checkout microservice.

  1. $ cd checkout-microservice/ && mvn spring-boot:run

Start the UI service. After starting, browse the app at http://localhost:8080/.

  1. $ cd react-ui/ && mvn spring-boot:run

4. Add items to the cart

Add two items to the cart as shown below.

yugastore-java checkout

Verify that your cart is now stored inside the YSQL shopping_cart table. From your YugabyteDB local cluster home, run the following.

  1. $ ./bin/ysqlsh
  1. yugabyte=# select * from shopping_cart;
  1. cart_key | user_id | asin | time_added | quantity
  2. ------------------+---------+------------+-------------------------+----------
  3. u1001-0001048236 | u1001 | 0001048236 | 2019-05-29T13:46:54.046 | 1
  4. u1001-0001048775 | u1001 | 0001048775 | 2019-05-29T13:46:56.055 | 1
  5. (2 rows)

5. Verify the completed order

Now complete the checkout and observe the order number generated.

yugastore-java order confirmation

Verify that this order number is now in the YCQL orders table.

  1. $ ./bin/cqlsh localhost
  1. cqlsh> select * from cronos.orders;
  1. order_id | user_id | order_details | order_time | order_total
  2. --------------------------------------+---------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------------------------+-------------
  3. 119b96dc-7d1a-4f2f-a1dd-36def25348e0 | 1 | Customer bought these Items: Product: The Sherlock Holmes Audio Collection, Quantity: 1; Product: Measure for Measure: Complete & Unabridged, Quantity: 1; Order Total is : 741.95 | 2019-05-29T13:54:04.093 | 741.95

Verify that there are no active shopping carts in YSQL at this point.

  1. yugabyte=# select * from shopping_cart;
  1. cart_key | user_id | asin | time_added | quantity
  2. ----------+---------+------+------------+----------
  3. (0 rows)

6. Run IoT Fleet Management app

After running Yugastore, we recommend running the IoT Fleet Management app. This app is built on top of YugabyteDB as the database (using the YCQL API), Confluent Kafka as the message broker, KSQL or Apache Spark Streaming for real-time analytics and Spring Boot as the application framework.

Yugastore app is a sample ecommerce application built using a microservices design pattern. React UI, Node.js Express app framework and YugabyteDB (YCQL and YEDIS) are used as the underlying technology stack.

1. Create a cluster

Create a cluster. The YEDIS API is initialized along with cluster creation so nothing additional needs to be done.

  1. $ ./yb-docker-ctl -rf 3 create

Clients can now connect to the YSQL API at localhost:5433, YCQL API at localhost:9042, and YEDIS API at localhost:6379.

2. Install Yugastore

  1. $ docker run -p 3001:3001 -d --network yb-net --name yugastore yugabytedb/yugastore

You can see the Yugastore app at http://localhost:3001.

Yugastore app screenshot

3. Run a load tester

  1. $ docker exec -it yugastore node /usr/local/yugastore/test/sample-user.js

4. Observe effects of load on YugabyteDB Admin UI

Now you can observe the effects of the read/write operations generated by the load tester by simply going to the YugabyteDB Admin UI at http://localhost:7000.

yugastore running

5. Review Yugastore architecture and code

Details of Yugastore architecture are documented here. Source code is available in the Yugastore GitHub repo.

6. Run IoT Fleet Management app

After running Yugastore, we recommend running the IoT Fleet Management app. This app is built on top of YugabyteDB as the database (using the YCQL API), Confluent Kafka as the message broker, KSQL or Apache Spark Streaming for real-time analytics and Spring Boot as the application framework.

Yugastore app is a sample ecommerce application built using a microservices design pattern. React UI, Node.js Express app framework and YugabyteDB (YCQL and YEDIS) are used as the underlying technology stack.

1. Create a cluster

Create a cluster.

  1. $ kubectl apply -f yugabyte-statefulset.yaml

Initialize the YEDIS API.

  1. $ kubectl exec -it yb-master-0 /home/yugabyte/bin/yb-admin -- --master_addresses yb-master-0.yb-masters.default.svc.cluster.local:7100,yb-master-1.yb-masters.default.svc.cluster.local:7100,yb-master-2.yb-masters.default.svc.cluster.local:7100 setup_redis_table

Clients can now connect to the YSQL, YCQL and YEDIS APIs of the cluster at 5433, 9042 and 6379 ports respectively.

2. Install Yugastore

  1. $ kubectl run yugastore --image=yugabytedb/yugastore:latest --port=3001 --command -- /usr/local/yugastore/bin/start-for-kubernetes.sh

Verify the deployment.

  1. $ kubectl get deployments
  1. NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE
  2. yugastore 1 1 1 1 13m

Check all the pods.

  1. $ kubectl get pods
  1. NAME READY STATUS RESTARTS AGE
  2. yb-master-0 1/1 Running 0 7h
  3. yb-master-1 1/1 Running 0 7h
  4. yb-master-2 1/1 Running 0 7h
  5. yb-tserver-0 1/1 Running 0 7h
  6. yb-tserver-1 1/1 Running 0 7h
  7. yb-tserver-2 1/1 Running 0 7h
  8. yugastore-55d7c6965-ql95t 1/1 Running 0 13m

Note the yugastore pod ID above so that you can redirect its 3001 port to the localhost’s 3001.

  1. $ kubectl port-forward yugastore-55d7c6965-ql95t 3001

Now you can see the Yugastore app at http://localhost:3001.

Yugastore app screenshot

3. Run a load tester

You can do this as shown below.

  1. $ kubectl exec -it yugastore-55d7c6965-ql95t node /usr/local/yugastore/test/sample-user.js

4. Observe effects of load on YugabyteDB Admin UI

Now you can observe the effects of the read/write operations generated by the load tester by simply going to the YugabyteDB Admin UI. First we have to find the Admin UI URL using the command below.

  1. $ minikube service yb-master-ui --url
  1. http://192.168.99.100:31283

The above output is the Admin UI URL and visiting the Tablet Servers page there will show you the current state of the cluster.

yugastore running

5. Review Yugastore architecture and code

Details of Yugastore architecture are documented here. Source code is available in the Yugastore GitHub repo.

6. Run IoT Fleet Management app

After running Yugastore, we recommend running the IoT Fleet Management app. This app is built on top of YugabyteDB as the database (using the YCQL API), Confluent Kafka as the message broker, KSQL or Apache Spark Streaming for real-time analytics and Spring Boot as the application framework.