Skip to content

This repo demonstrates the use of microservices architecture in an e-commerce application.

Notifications You must be signed in to change notification settings

emreaknci/eShopping

Repository files navigation

eShopping

This project shows how to use microservices in e-commerce. Microservices split big systems into small pieces, making them flexible. Things like Event Driven help services talk to each other, cutting down on how much they rely on each other. This new way of doing things is important for online stores.

Run Locally

Before running the application, you need to copy the project to your desired directory using the following command:

   git clone https://github.com/emreaknci/eShopping.git

The project is dockerized. You can launch the application by running the following command in the project's root directory.

   docker-compose -p eshopping up -d

If you wish, you can change the database usernames and passwords to your preferences in the docker-compose.override.yml file.

After all containers are running, you can access the web application at http://localhost:5173/.

You can sign in as an admin using the email "admin@admin.com" and the password "123456".

Tech Stack

System Diagram

  • Identity Service: This service is developed to manage users. It handles basic functions such as registration, authentication, and token generation.

  • Catalog Service: This service manages and presents the project's products. It allows users to search, filter, and access detailed information about the products. Additionally, admin users can add, update, and delete products through this service.

  • Basket Service: This service manages the shopping cart functionality of the project. It enables authenticated users to add products to the cart, update product quantities, and remove products from the cart.

  • Comment Service: This service is responsible for product reviews. Users can post comments on products and view existing comments.

  • Notification Service: This service handles notifications. Currently, it can send notifications via email and console output. It listens for events published by the PaymentService and sends notifications based on these events. Currently, only email notifications are supported.

  • Payment Service: This service is responsible for payment processing. Since there is no integration with a real payment system, payments are accepted using standard-compliant card information. Based on the payment status, events are published through the EventBus to notify other services.

  • Order Service: This service is responsible for order management. It stands out from other services by using methods such as the CQRS Pattern and Onion Architecture.

  • Ocelot API Gateway: It acts as a single entry point for clients to access microservices, handling tasks like routing, security, and monitoring.

  • Consul: Consul is a service mesh solution providing features like service discovery and health checking, enabling dynamic and resilient communication between microservices.

Event Driven Architecture

The main purpose of the project can be perceived as developing a microservices project, but actually, the primary goal is to facilitate communication between these microservices. For this, we need an event-driven architecture, which is named Event Bus. The workflow consists of the following steps:

1. User Checkout Request: The user enters the information to purchase items in their cart and sends a request to the Basket Service.

2. Order Creation: When the Basket Service receives the Checkout request, it sends a request to the Order Service to create an order.

3. Payment and Stock Update: While creating the order, the Order Service sends a payment request to the Payment Service and updates the stock from the Catalog Service.

4. Processing Based on Payment Result: If the payment is successful, a notification is sent to the user, and the cart is emptied. If it fails, the order is canceled, and the stocks are updated.