Install Yugastore

Run the Yugastore sample application

After creating a local cluster, follow the instructions on this page to run the Yugastore application.

Yugastore-java 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.

Install Yugastore

  1. Clone the repository.

    $ git clone https://github.com/YugabyteDB-Samples/yugastore-java.git
    
    $ cd yugastore-java
    
  2. Create the app binaries.

    $ mvn -DskipTests package
    
  3. Create the app's schema in YugabyteDB.

    $ cd resources
    
    $ $YUGABYTE_HOME/bin/ysqlsh -f schema.sql
    
    $ $YUGABYTE_HOME/bin/ycqlsh -f schema.cql
    
  4. Load the initial data.

    $ ./dataload.sh
    
  1. Clone the repository.

    $ git clone https://github.com/YugabyteDB-Samples/yugastore-java.git
    
    $ cd yugastore-java
    
  2. Create the app binaries.

    $ mvn -DskipTests package
    
  3. Create the app's schema in YugabyteDB.

    $ cd resources
    
    $ $YUGABYTE_HOME/bin/ysqlsh -f schema.sql
    
    $ $YUGABYTE_HOME/bin/ycqlsh -f schema.cql
    
  4. Load the initial data.

    $ ./dataload.sh
    
  1. Run the following command:

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

    $ kubectl get deployments
    
    NAME        DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE
    yugastore   1         1         1            1           13m
    
  3. Check all the pods.

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

Run the following command:

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

Start the app

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

    $ cd eureka-server-local/ && mvn spring-boot:run
    
  2. Start the API gateway microservice.

    $ cd api-gateway-microservice/ && mvn spring-boot:run
    
  3. Start the products microservice.

    $ cd products-microservice/ && mvn spring-boot:run
    
  4. Start the checkout microservice.

    $ cd checkout-microservice/ && mvn spring-boot:run
    
  5. Start the UI service. After starting, browse the app at http://localhost:8080/.

    $ cd react-ui/ && mvn spring-boot:run
    
  1. Start the Eureka discovery service. After starting, verify that the service is running at http://localhost:8761/.

    $ cd eureka-server-local/ && mvn spring-boot:run
    
  2. Start the API gateway microservice.

    $ cd api-gateway-microservice/ && mvn spring-boot:run
    
  3. Start the products microservice.

    $ cd products-microservice/ && mvn spring-boot:run
    
  4. Start the checkout microservice.

    $ cd checkout-microservice/ && mvn spring-boot:run
    
  5. Start the UI service. After starting, browse the app at http://localhost:8080/.

    $ cd react-ui/ && mvn spring-boot:run
    
  1. Redirect the yugastore pod's port 3001 to the local host. The pod ID (yugastore-55d7...) is the last line of the output in the previous step.

    $ kubectl port-forward yugastore-55d7c6965-ql95t 3001
    
  2. Open the Yugastore app in your browser at http://localhost:3001.

    Yugastore app screenshot

The Yugastore app is already running. Open it in your browser at http://localhost:3001.

Yugastore app screenshot

Add items to the cart

  1. Add two items to the cart.

    yugastore-java checkout

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

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

Verify the completed order

  1. Complete the checkout and observe the order number generated.

    yugastore-java order confirmation

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

    $ ./bin/ycqlsh localhost
    
    ycqlsh> select * from cronos.orders;
    
     order_id                             | user_id | order_details                                                                                                                                                                           | order_time              | order_total
    --------------------------------------+---------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------------------------+-------------
     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
    
  3. Verify that there are no active shopping carts in YSQL at this point.

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

Next step

After running Yugastore, try the IoT Fleet Management application. IoT Fleet Management 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.