Skip to content

tiagoSapo/A-Representative-Low-Cost-and-Easy-to-Deploy-Microservices-Application-for-Research-Purposes

Repository files navigation

Publicitaki-Store-Bank Systems

Summary:

This project consists of three interconnected applications that simulate real-life websites communicating with each other. They can be run on the Cloud (Amazon AWS) ☁️ using the Terraform IaC or Locally via Docker 🐋.

The project is structured around three subsystems:

  • 📈 Publicitaki, a price tracker website;
  • 🛍️ Store, an online platform for selling various types of products;
  • 🏦 Bank, a system that manages transactions made on both Publicitaki and Store.


Communication:

  • REST
  • gRPC
  • Publish/Subscribe pattern (banking transactions)


Database management systems used:

  • PostgreSQL
  • MySQL


Programming languages/frameworks used:

  • Java (Spring Boot and Quarkus)
  • C# (ASP.NET Core)
  • Python (Django)
  • JavaScript (NodeJS, React with Vite)

Environment Setup and Installation - LOCAL (Docker) 🐋

  • Step 1: Download the source code from Github;
  • Step 2: Download and install Docker and Docker-Compose from the official website https://www.docker.com/get-started/;
  • Step 3: Run docker-build.sh to build the containers;
  • Step 4: Run docker-run.sh to run the containers;
  • Step 5: (Optional) You can use the scripts in the "docker-scripts-for-data-insertion" folder to insert data samples.
  • Step 6: Access the frontend container on: http://localhost:6003 for the Bank 🏦, http://localhost:5006 for the Store 🛍️, and http://localhost:7007 for Publicitaki 📈;

Environment Setup and Installation - CLOUD (Amazon AWS) ☁️

Note: Windows 10 and Windows 11 🪟 users should use Windows Subsystem for Linux (WSL) and follow the Linux commands.

  • Step 1: Create a AWS account: (https://console.aws.amazon.com/console/home?nc2=h_ct&src=header-signin)
  • Step 2: Create a IAM account with the permissions "AdministratorAccess" and "AmazonS3FullAccess"
  • Step 3: Then in the IAM account select the "Security Credentials" tab and in "Access keys" select "Create access key"
  • Step 4: After the key's creation you should will have the aws credentials. IMPORTANT: do not forget to save the credentials because after you close the dialog you won't be able to see them again (if you forget them you can always delete them and create a new one)
  • Step 5 Install software:
    • macOS : Install Homebrew running the following command:
      /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
    • Linux 🐧: Update apt and install curl:
      sudo apt update && sudo apt install -y curl
  • Step 6: Install the AWS CLI:
    • macOS : Install it on macOS, running the following command:
      brew install awscli
    • Linux 🐧: Install it on linux, running the following command:
      sudo apt install -y awscli
  • Step 7: Verify that the AWS CLI is installed by running the following command:
    aws --version
  • Step 8: Run the following command with the credentials given by AWS in step 4:
    aws configure
  • Step 9: Install Terraform:
    • macOS : Install it on macOS, running the following command:
      brew install terraform
    • Linux 🐧: Install it on linux, running the following command:
      sudo apt install -y terraform
  • Step 10: To verify that Terraform is installed run the following command:
    terraform --version
  • Step 11: (Optional) Compile each microservice for each system and put them in the corresponding directories:
//Make sure that you create the EXECUTABLES FOLDERS

/terraform-scripts/bank/executables
/terraform-scripts/publicitaki/executables
/terraform-scripts/store/executables
  • Step 12: Go to the terraform-scripts folder and run the deploy script:
cd terraform-scripts
./deploy_to_aws.sh


After 10 to 20 minutes, the deployment should be complete.

  • Step 13: After the deployment is complete, go to Elastic Beanstalk Environments and select the environment Store-Users and select Configuration on the left pane. Then in Instance traffic and scaling select Edit and add a new LISTENER on port 5000 (TCP). Click APPLY.
    After that, you should have a listener for both ports 80 and 5000.
  • After Step 13 the application is ready to be used. To UNDEPLOY run the following script:
    ./undeploy_from_aws.sh

Deploy and Undeploy commands:

  • To Deploy(⬆️) run the following commands:
cd terraform-scripts
./deploy_to_aws.sh
  • To Undeploy(⬇️) run the following commands:
cd terraform-scripts
./undeploy_from_aws.sh

Notes

Register PRODUCTS on Store and Publicitaki

(Optional) To add new products on the Store, you should go to the Store-Products microservice and do the following:

  • Add a category, for example, "Playstation", on this URL: <aws-endpoint-for-store-products>/categories;
  • Add a brand, for example, "SONY", on this URL: <aws-endpoint-for-store-products>/brands;
  • Add a product, for example, "Resident Evil 4 Remake", on this URL: <aws-endpoint-for-store-products>/products.

(Optional) To add new products on Publicitaki, you should go to the frontend of the website Publicitaki Pub-Frontend and do the following:

  • Login as an Admin;
  • Go to Account and select the option to add a new product;

Application Architecture diagrams

The application C4 diagrams are in the "extras/application-c4-diagrams" folder.


Locust and Amazon AWS (CPU / Network-out) charts

The application's Locust and Amazon AWS charts are in the "extras/charts" folder.