E-commerce platform that allows users to buy and sell products. This idea's implementation through distributed systems is suitable because it can be easily separated in distinct components that can be developed independently. Similar platforms that use microservices architecture are Amazon, eBay, AliExpress, etc.
More information about Docker.
To run the application type this command in the root folder.
$ docker compose up
You might have to run this command twice if it doesn't work the first time :)
More information about Kubernetes. Before running next commands move to k8s
directory.
$ cd ./k8s
First of all you need to start Redis cluster which will take some time.
$ kubectl apply -f ./redis-cluster.yaml
After that you can use these two commands to check if the cluster has been initialized correctly.
$ kubectl exec redis-cluster-0 -- redis-cli cluster nodes
$ kubectl exec redis-cluster-0 -- redis-cli --cluster check localhost 6379
To start Postgres cluster we'll be using Kubegres.
First we have to install Kubegres Custom Resource Definitions.
$ kubectl apply -f https://raw.githubusercontent.com/reactive-tech/kubegres/v1.17/kubegres.yaml
$ kubectl get all -n kubegres-system
Then we can start Postgres cluster which may take some time.
$ kubectl apply -f postgres-cluster.yaml
To run everything else type these commands one by one in this exact order.
$ kubectl apply -f ./rabbitmq.yaml
$ kubectl apply -f ./postgres.yaml
$ kubectl apply -f ./services.yaml
$ kubectl apply -f ./gateway.yaml
For performance monitoring we'll be using Prometheus Operator.
The first step is to install the operator's Custom Resource Definitions as well as the operator itself with the required RBAC resources.
LATEST=$(curl -s https://api.github.com/repos/prometheus-operator/prometheus-operator/releases/latest | jq -cr .tag_name)
curl -sL https://github.com/prometheus-operator/prometheus-operator/releases/download/${LATEST}/bundle.yaml | kubectl create -f -
To start Prometheus run the following command.
$ kubectl apply -f ./prometheus-operator.yaml
To delete created resources type these commands.
$ kubectl delete -f ./prometheus-operator.yaml
$ kubectl delete -f ./gateway.yaml
$ kubectl delete -f ./services.yaml
$ kubectl delete -f ./postgres.yaml
$ kubectl delete -f ./rabbitmq.yaml
$ kubectl delete -f ./redis-cluster.yaml
$ kubectl delete kubegres warehouse
To also delete Kubegres Custom Resource Definitions.
$ kubectl delete -f https://raw.githubusercontent.com/reactive-tech/kubegres/v1.17/kubegres.yaml
I don't know how to remove Prometheus Operator.
- Run the application as mentioned above.
- Access Swagger UI at localhost:3010/api.
- Register a user with the
POST /users/register
endpoint. - Login with the
POST /users/login
endpoint. (optional) - Copy the access token from the response body.
- Set the access token in the
Authorize
button from the top right corner of the Swagger UI. - Create a product with the
POST /products
endpoint. - Order a product with the
POST /orders/:productId
endpoint.
You can find the internal endpoints specification in /proto
folder.
- Access Prometheus at localhost:9090.
- Access Grafana at localhost:3000.
- Login using credentials:
admin
andpassword
. - Open the
Dashboards
tab from the left side menu. - Select
Microservices Metrics
dashboard.