The e-commerce application is divided into four distinct services:
- Nginx (API Gateway): This service acts as the central hub for processing incoming requests. It listens to various endpoints (“/”, “/api”, “/webapi”) and routes them accordingly.
- Angular Client: Responsible for rendering the front end of the website or user interface, accessible through the “/” endpoint.
- Node.js Backend (Emart API): Manages and takes charge of the business logic and interacts with a MongoDB database. Accessed through the “/api” endpoint.
- Java Backend (Books API): Another backend service handling book-related functionalities, backed by a MySQL database. Accessed through the “/webapi” endpoint.
The Need for Containerization
Containerization provides a standardized and portable environment for applications. It encapsulates each microservice along with its dependencies, ensuring consistency across different environments. Docker, a leading containerization platform, is the tool of choice for this project.
- Clone the repository.
$ git clone https://github.com/Amit-unchartered/E-MART_App.git
- Change directory to E-MART_App, then to vagrant
$ cd E-MART_App/vagrant
- Do vagrant up, it contains all the commands for docker installation and its dependencies.
$ vagrant up
$ vagrant ssh
- Switch to root user
$ sudo -i
- Clone the repository inside the VM.
# git clone https://github.com/Amit-unchartered/E-MART_App.git
- change directory into E-MART_App.
# cd E-MART_App
- Make sure there are no other containers present, if present then to stop and remove the container
# docker compose down
- Remove all the earlier containers and images before setting up this project.
# docker system prune -a
- Now, we will be orchestrating with docker compose.
# docker compose up -d
- The project is set up, if you want to access it from outside the VM, then we must know the VM's IP address
# ip addr show
Find for the class C ip address i.e 192.168.x.y, type this ip at top of your browser, it will route the request to port 80.