This is an e-commerce application built using the MERN (MongoDB, Express.js, React.js, Node.js) stack. The application is designed as a microservices architecture and deployed on Kubernetes, taking advantage of its container orchestration capabilities.
The application uses the following technologies:
- Node.js
- Express.js
- MongoDB (for user and product data)
- MySQL (for order and payment data)
- Kafka (as the distributed messaging system)
- Docker (for containerization)
- Kubernetes (for deployment and orchestration)
The e-commerce application is designed as a set of loosely coupled microservices, each responsible for specific functionalities. The microservices communicate with each other through Kafka, a distributed streaming platform. The following are the key microservices:
-
Authentication Service: Responsible for user registration, login, and authentication. It utilizes MongoDB to store user data and JWT tokens for secure authentication.
-
User Service: Manages user-related operations such as profile management, address details, and preferences. It communicates with the Authentication Service for user authentication.
-
Product Service: Handles product-related operations, such as adding new products, updating product details, and managing inventory. It stores product information in MongoDB.
-
Order Service: Deals with order processing, including creating, updating, and tracking orders. It communicates with the Product Service to check product availability.
-
Payment Service: Integrates with external payment gateways to process payments for orders. It ensures secure and reliable payment processing.
The entire application is deployed on Kubernetes to take advantage of its container orchestration features. The Kubernetes cluster consists of multiple nodes, including a master node that controls the cluster and worker nodes that run the microservice containers.
Each microservice is containerized using Docker, allowing easy and consistent deployment across different environments. Docker images for the microservices are pushed to a container registry for access within the Kubernetes cluster.
The application is divided into several microservices, each responsible for specific functionalities. Below are the details of the events used in each microservice:
- Event Name: USER_REGISTERED
- Description: This event is triggered when a new user registers on the platform. It contains the user details, such as username, email, and registration timestamp.
- Event Name: USER_UPDATED
- Description: This event is triggered when a user updates their profile information. It carries the updated user data.
- Event Name: USER_DELETED
- Description: This event is generated when a user account is deleted. It typically contains the user ID or other relevant details.
- Event Name: PRODUCT_ADDED
- Description: This event is triggered when a new product is added to the inventory. It includes product details such as name, description, price, and stock quantity.
- Event Name: PRODUCT_UPDATED
- Description: This event is triggered when product information is updated. It can carry the updated fields of the product.
- Event Name: PRODUCT_DELETED
- Description: This event is generated when a product is removed from the inventory. It may contain the product ID or relevant identifiers.
- Event Name: ORDER_PLACED
- Description: This event is triggered when a customer places a new order. It includes details such as the customer ID, order ID, product IDs, quantities, and total price.
- Event Name: ORDER_CANCELLED
- Description: This event is generated when an order is canceled. It can contain the order ID and any relevant cancellation details.
- Event Name: ORDER_COMPLETED
- Description: This event is triggered when an order is successfully delivered and marked as complete.
- Event Name: PAYMENT_ADDED
- Description: This event is triggered when a new payment is processed for an order. It includes payment details like transaction ID, amount, payment method, and order ID.
- Event Name: PAYMENT_SUCCESS
- Description: This event is generated when a payment is successfully processed and confirmed.
- Event Name: PAYMENT_FAILURE
- Description: This event is triggered if a payment fails due to some error or insufficient funds.
- Event Name: DELIVERY_STARTED
- Description: This event is triggered when the delivery of an order begins. It includes the order ID, delivery address, and delivery partner details.
- Event Name: DELIVERY_COURIERED_PARTNER
- Description: This event is generated when the delivery is handed over to a delivery partner for completion.
- Event Name: DELIVERY_COMPLETED
- Description: This event is triggered when the delivery is successfully completed, and the order reaches the customer.
- Clone the repository.
- Set up and configure MongoDB for user and product data storage.
- Set up and configure MySQL for order and payment data storage.
- Build Docker images for each microservice using the provided Dockerfiles or pull them from Docker Hub.
- Auth Service:
docker pull kunalznk/auth-service:latest
- User Service:
docker pull kunalznk/user-service:latest
- Product Service:
docker pull kunalznk/product-service:latest
- Order Service:
docker pull kunalznk/order-service:latest
- Payment Service:
docker pull kunalznk/payment-service:latest
- MongoDB:
docker pull mongo:latest
- MySQL:
docker pull mysql:latest
- Kafka:
docker pull doughgle/kafka-kraft:latest
- Auth Service:
- Deploy the Kubernetes cluster with the necessary configurations for each microservice, Kafka, and other components.
- Create an Ingress resource to expose the application to the outside world.
- Scale the microservices and configure load balancing based on the expected traffic and resource requirements.
- Monitor the application's performance and health using Kubernetes monitoring tools and logging systems.
Please note that the Kubernetes configurations (Ingress, Deployments, StatefulSet, and Services) provided in are essential for deploying the microservices, Kafka, and other components on a Kubernetes cluster. Make sure to apply those configurations using Kubectl or other Kubernetes management tools.
The above steps provide an overview of the installation and setup process, including setting up databases, containerizing microservices, deploying them on Kubernetes, and ensuring the application's scalability and monitoring.
Remember to customize the installation instructions based on your specific environment and requirements. Additionally, ensure that you have a Kubernetes cluster set up and properly configured before proceeding with the Kubernetes-related steps.
Please note that the Docker images for the microservices and other components are available on Docker Hub (kunalznk
represents your Docker Hub username). You can use docker pull
commands to fetch the latest images from Docker Hub
Feel free to contribute to this project by opening issues or submitting pull requests.