Git Product home page Git Product logo

yugastore's Introduction

Yugastore

This is a sample, end-to-end functional bookstore (or more generally, an e-commerce app) built using YugabyteDB. This app shows how YugabyteDB makes this development very simple through its multiple distributed SQL APIs.

The app is continuously being improved. It currently features:

  • products catalog listing
  • product details page
  • static product grouping (such as "business books", "mystery books", etc)
  • dynamic product grouping (such as "most reviewed", "highest rated", etc)
  • tracking for pageviews (both counts and referral for firther analysis)
  • Coming soon: a shopping cart, online checkout, order history tracking.

YugaStore

This app is built using the following stack:

  • Frontend: ReactJS
  • Backend: Express and NodeJS
  • Database: YugabyteDB

Understanding the app

Review the design of the app in YugabyteDB Docs.

Running the sample app

Run using docker

You can see the app at http://localhost:3001 after doing the following:

  1. Install YugabyteDB in docker on your localhost.

  2. Run the Yugastore app using the followign command:

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

Run locally

  1. Install YugabyteDB.

  2. Run the following to initialize. Tweak the config.json file if needed.

$ cd yugastore
$ npm install # First time only
  1. Run the following to populate data:
node models/yugabyte/db_init.js
  1. Start the REST API server using:
$ npm start
  1. Start the webserver using - this is optional:
$ cd yugastore/ui
$ npm install # First time only
$ npm start

Run using kubernetes

  1. Install YugabyteDB in kubernetes. Do not forget to initialize the YEDIS API using the following command after bringing up a local cluster:
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
  1. Bring up the ExpressJS + NodeJS + React app in a Kubernetes pod using the following command:
kubectl run yugastore --image=yugabytedb/yugastore:latest --port=3001 --command -- /usr/local/yugastore/bin/start-for-kubernetes.sh

You can verify this deployment is running using the following:

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

You can check all the running pods by doing:

$ 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
  1. Viewing the UI
  • On localhost (minikube) cluster On localhost minikube, do the following and see ui at http://localhost:3001:
kubectl port-forward yugastore-55d7c6965-ql95t 3001

Remember to substitute the pod name yugastore-55d7c6965-ql95t based on the output of kubectl get pods above.

  • On a managed Kubernetes cluster (GKE, AKS, EKS) These have integrated load-balancers. You can expose the app by performing the following:
$ kubectl expose deployment yugastore --type=LoadBalancer
service "yugastore" exposed

You can view the services with

$ kubectl get services
NAME          TYPE           CLUSTER-IP   EXTERNAL-IP   PORT(S)                               AGE
kubernetes    ClusterIP      10.0.0.1     <none>        443/TCP                               109d
yb-masters    ClusterIP      None         <none>        7000/TCP,7100/TCP                     7m
yb-tservers   ClusterIP      None         <none>        9000/TCP,9100/TCP,9042/TCP,6379/TCP   7m
yugastore     LoadBalancer   10.0.0.154   <pending>     3001:31141/TCP                        42s

You can open the UI using:

minikube service yugastore

Run a load tester

The app comes with a load tester which mimics the behavior of an end user at a very high rate. You can run this as follows:

  • Docker
docker exec -it yugastore node /usr/local/yugastore/test/sample-user.js
  • Binary
node test/sample-user.js
  • Kubernetes
kubectl exec -it yugastore-84d7479766-xwxml node /usr/local/yugastore/test/sample-user.js

You should be able to see the IOPS on the YugaByte DB UI. If you have installed it on your localhost, with default settings, you can see this on the /tablet-servers page. It should look something as follows.

YugaByte DB load from Yugastore and load tester

Development against the app

To build a new docker image:

  1. Rebuild the ui if something has changed.
cd ui && rm -rf build/ && npm run build
  1. Rebuild the docker image:
docker build -t yugastore .

yugastore's People

Contributors

rkarthik007 avatar schoudhury avatar hasheddan avatar proy24 avatar

Stargazers

Yosra Moumtaz avatar Azones avatar Sundaram Kumar Jha avatar Monica Murray avatar Tuan Nguyen avatar Giovanni avatar  avatar Sheikh23 avatar  avatar Herve avatar Shivani R avatar Thanaphoom Babparn avatar Sardi Irfansyah avatar Lee avatar Eric Jou avatar CODER avatar  avatar Moch. Ainun Najib avatar tristan avatar Eingress Ltd avatar  avatar Blackbird38 avatar Fari avatar William Akomaning avatar  avatar Rodrigo Viola avatar CSpornov avatar 牛强 avatar IamRicoh avatar waskito shidiq avatar David J. Kordsmeier avatar  avatar David A avatar  avatar gnois avatar Abhishek Kumar avatar Namratha Mandya Subramanya avatar Okan Kaya avatar rong fengliang avatar Deus chami avatar Ajeeta Asthana avatar Vlad Trukhin avatar ∆D avatar Armen avatar Fabio Covolo Mazzo avatar Amey Banarse avatar Akshay Mishra avatar Rajan P. avatar  avatar  avatar

Watchers

Mikhail Bautin avatar James Cloos avatar Naresh Kancharla avatar  avatar Ram Vaidyanathan avatar  avatar Kannan Muthukkaruppan avatar neryajanel avatar Anif avatar  avatar

yugastore's Issues

Wait for successful connection to cluster before attempting to seed DB

Currently, db_init.js attempts to connect to the database and if it fails, that startup script will continue. When running YugabyteDB in a k8s cluster, this means that cluster must be fully provisioned before deploying the Yugastore app. It would be nice to be able to deploy the app before or at the same time as the yugabyte cluster, then have it poll the database until it is able to connect.

I am happy to make this update :)

/cc @kmuthukk @rkarthik007

Can't connect to my yugabyte cloud db

am trying to configure the yugastore to connect to my cloud db but it's not connecting, each time i tried that, it's giving me connection error, any possible solution to that??

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.