Proshop is an e-commerce app where users can view a listing of Proshop inventory and purchase products from that inventory. Proshop uses an event driven microservices architecture and makes use of messaging queues to ensure communication between services.
- Register a new user.
- Admins can add, edit, and delete products
- Customers can buy products securely through stripe checkout process.
- Customers can rate a product.
Proshop is powered by several services running in a Kubernetes cluster. All backend services are built with NodeJS Express and sits behind an Nginx reverse proxy service in order to route requests to the appropriate backend service (API). The reverse proxy makes use of the Kubernetes Ingress Controller. See the config file for the reverse proxy at infra/k8s/ingress-srv.yaml for more details.
- Catalog service front end app to display products, and allows users to buy products.
- Admin service CMS for admin users.
- Auth service manages users resources.
- Products service manages product resources.
- Orders service manages orders resources.
- Payments service handles and processes payments resources.
- Auth database with 1 collection for Users.
- Products database with 2 collections for Products and Reviews.
- Orders database with 2 collections for Orders and Products.
- Payments database with 2 collections for Orders and Payments.
- RabbitMQ message broker (CloudAMQP and amqlib) enables communication between services.
Backend services were built using:
- To create the server and the Api for each service.
- To generate JWT token for authentication purposes.
- To handle input validation coming from the front end.
- Object data model (ODM) to manipulate data from the MongoDB database.
- To ensure communication between backend services, using the
Pub/Subapproach.
- To handle secure payments from customers after an order is placed and received through the payments service.
In order to run the app locally, perform the following steps.
-
Either fork or download the app and open the folder in the terminal.
-
Install all dependencies for each service by going into each service's folder using the
yarn installcommand.
For the app to run correctly, a few things are needed: Docker, a Kubernetes cluster, and Kubernetes secrets.
Installing Docker and creating a Kubernetes cluster is simple since Docker Desktop comes with everything right out of the box.
-
Download and Install Docker Desktop and enable Kubernetes in the preference panel.
-
Install Ingress-nginx by running the command below.
$ kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v0.47.0/deploy/static/provider/cloud/deploy.yaml- Open and edit your machine's host file by running the command below:
- On Mac
<!-- If you use VS code -->
$ code /etc/hosts
<!-- Otherwise -->
$ cd /etc/hosts
- On Windows
<!-- If you use VS code -->
$ code C:\Windows\System32\Drivers\etc\hosts
<!-- Otherwise -->
$ cd C:\Windows\System32\Drivers\etc\hostsThen, paste the following at the bottom of the file: 127.0.0.1 proshop.dev
-
Download and install Skaffold by following the instructions at:
skaffold.dev/docs/install/ -
Once Skaffold is installed in the proshop-microservices root folder, run the command
skaffold devin the command line. -
Open your browser to https://proshop.dev:3000 and type
thisisunsafeanywhere on your screen to bypass your browser ssl protection on the page. You should now see the Proshop client service up and running.
Kubernetes secrets (like Stripe api_key, CloudAMQP url, etc...) must be provided to the Kubernetes cluster to avoid runtime errors. Run the commands below and replace <SECRET> with your own values coming from your own stripe account or CloudAMQP account, etc...
<!-- Long string used to validate token from the jsonwebtoken library. You can use a password generator like lastPass to generate this string -->
$ kubectl create secret generic jwt-secret --from-literal JWT_KEY=<SECRET>
<!-- RabbitMQ url provided by creating an account in CloudAMQP -->
$ kubectl create secret generic rabbitmq-url --from-literal RABBITMQ_URL=<SECRET>
<!-- Stripe api key provided by Stripe.com -->
$ kubectl create secret generic stripe-key --from-literal STRIPE_KEY=<SECRET>
Other environment variables needed, like the MongoDB url, are provided in the deployments files found in the ./infra/k8s directory.
