Microservices Architecture for E-commerce Application

Sep 23, 2024

Microservices Architecture Lecture Notes

Introduction

  • Discussion with the development team about architecture and technologies.
  • Chosen technology stack: Microservices architecture, Spring Boot 3, Spring Cloud.

Application Overview

  • Microservices will handle different functionalities of the e-commerce application.
  • Mention of a mail confirmation feature.

Implementation Steps

  1. Business Requirements

    • Client operates without a digital solution.
    • Requirements include managing products, customer interactions, and payment processing.
  2. Application Design

    • Identified domains: Customer, Product, Order, Payment, Notification.
    • Each domain corresponds to a microservice.
  3. Microservices Communication

    • Synchronous communication via REST and OpenFeign.
    • Asynchronous communication via Kafka.
    • Configuration management using a config server.
    • Service discovery through Eureka.
  4. Email Notification Service

    • Implemented to handle notification emails.
    • Uses Kafka to send and receive messages.
  5. Order Microservice

    • Handles order processing, interacts with Product and Payment microservices.
    • Implements order confirmation notifications.
    • Uses Spring Data JPA for database interaction.
  6. Payment Microservice

    • Manages payment processing.
    • Interacts with Kafka for sending payment notifications.
    • Utilizes similar structure and design patterns as other microservices.
  7. Notification Microservice

    • Handles sending emails based on order and payment confirmations.
    • Utilizes Spring Boot Mail and Kafka for message processing.
  8. API Gateway

    • Acts as a single entry point for all microservices.
    • Implemented using Spring Cloud Gateway.
    • Configured to route requests to the appropriate microservice based on URL patterns.
  9. Security Integration

    • Integrated Keycloak for authentication and authorization.
    • Configured API Gateway to validate tokens using Keycloak.
  10. Distributed Tracing

    • Set up Zipkin to monitor and trace requests across microservices.
    • Implemented tracing for better debugging and performance monitoring.

Environment Setup

  • Used Docker for container orchestration.
  • Each microservice runs in its own container.
  • Config server and Eureka service run in separate containers.

Testing the Application

  • Utilized Postman to test API endpoints for customer creation, order processing, and payment handling.
  • Verified email notifications and successful order processing.

Summary

  • Successfully built and tested an e-commerce application using microservices architecture.
  • Demonstrated key principles of microservices, including communication patterns, service discovery, and API management.