This project encompasses the source code for a sophisticated e-commerce application structured using a microservices architecture. It features an AI service that leverages the OpenAI API, similar to ChatGPT, to autonomously generate descriptions for newly added products. The system employs MongoDB for robust data management and RabbitMQ for efficient message queuing. The frontend component of the application operates as an independent microservice crafted with React, ensuring a dynamic and responsive user interface. Additionally, the backend microservices are developed using NodeJS and Python, offering a versatile and scalable server-side solution.
- Microsoft Azure account
- Azure cli
- terraform
- kubectl
- helm
-
-
Login into the Azure account using azure cli
az login
-
Create a new service principal
az ad sp create-for-rbac --skip-assignment
Copy and save the information returned after executing the command successfully. Information will look something like:
{ "appId": "<app_if>", "displayName": "<display_name>", "password": "<password>", "tenant": "<tenant>" }
-
From the project folder, go into the
terraform
foldercd terraform
-
Create a new file
terraform.tfvars
and provide the below details in that file.resource_group_name = "<resource_group_name_of_your_choice>" location = "<location_of_the_rg>" cluster_name = "<cluster_name>" kubernetes_version = "1.29" system_node_count = 3 appId = "<appId_from_step_2>" password = "<password_from_step_2>" dns_prefix = "<any_name_for_dns_prefix>"
-
Run the below commands
terraform init terraform fmt terraform plan ## If there are no errors then go ahead ## terraform apply -auto-approve
-
Once the provisioning is complete, run the below command to add K8S cluster credentials to your local
kubeconfig
file so that you can interact with AKS cluster usingkubectl
from your local system.az aks get-credentials --resource-group $(terraform output -raw resource_group_name) --name $(terraform output -raw kubernetes_cluster_name)
-
-
-
Open terminal into the project folder.
-
Install
MongoDB
helm install mongo --create-namespace -n mongo -f helm/mongo_values.yaml oci://registry-1.docker.io/bitnamicharts/mongodb
This chart will install
MongoDB
in themongo
namespace according to the setting mentioned in the values file from the./helm/mongo_values.yaml
file. -
Install
RabbitMQ
helm install rabbitmq --create-namespace -n rabbitmq -f helm/rabbitmq_values.yaml oci://registry-1.docker.io/bitnamicharts/rabbitmq
This chart will install
RabbitMQ
in therabbitmq
namespace according to the setting mentioned in the values file from the./helm/rabbitmq_values.yaml
file. -
Install
Traefik
ingress controllerhelm repo add traefik https://helm.traefik.io/traefik helm repo update kubectl create namespace traefik helm install traefik traefik/traefik -n traefik
-
-
-
Go to the
Kubernetes-manifests
folder. -
Check all the manifest files and fill the appropriate base64 encoded connection strings. Example connection strings(pre base64 encoded)
CONNECTION_STRING = mongodb://root:[email protected]:27017/auth-service?authSource=admin RABBITMQ_CONNECTION_STRING = amqp://user:[email protected]:5672
-
Run the below command to get Load Balance
External-IP
.kubectl get svc -n traefik
-
Input the above
External-IP
in the environment variableREACT_APP_INGRESS_PUBLIC_IP
inadmin-front-service-manifest.yaml
. -
Install Kubernetes manifests for all the microservices.
kubectl apply -f Kubernetes-manifests
-
-
- Ensure that all the services are up.
- Send a
POST
request to/auth/register
endpoint to create a new user. URL will behttp://<External-IP>/auth/register
.{ "name": "dba", "email": "[email protected]", "password": "12341234" }
- Access the application by going to the URL
http://<External-IP>
. - Login using the
email
andpassword
registered above.
-
- Use the application or
- Send a
POST
request to the/product/create
endpoint. URL will behttp://<External-IP>/product/create
{ "name": "PurrfectPan cat litter box", "tags": "cat, litter, clean, hygiene", "description": "<generate_using_ai_service>", "price": 3000, "created_by": "[email protected]", "img_url": "https://i.imgur.com/iBK83bn.png" }
-
- Send a
POST
request to the/product/buy
endpoint. URL will behttp://<External-IP>/product/buy
.{ "productsWithQuantity": [ { "id": "6646137ef04ba4cf8bb0547e", "quantity": 3 }, { "id": "6646137ef04ba4cf8bb0547e", "quantity": 2 } ], "userEmail": "[email protected]", "userAddress": "11/22, Address_test" }
- Send a
-
/generate/health
: ai service
/auth/health
: auth service
/order/health
: order service