Skip to content

Implement inter-service communication using discovery server, implement service based routing through API Gateway, implement authorization and authentication using keycloak, implement circuit breaker, and using docker for containerization

License

Notifications You must be signed in to change notification settings

kmanoj07/eCommerce-microservices

Repository files navigation

e-Commerce Microservices Project

Project Overview

This e-Commerce Microservices project is built using Spring Boot, Spring Cloud, Circuit Breaker, Kafka, Distributed Tracing, and Prometheus. The system comprises six microservices, each with a specific role, including API Gateway, Product Service, Order Service, Notification Service, Inventory Service, and Discovery Service. The project incorporates modern microservices architecture principles and tools to provide a scalable, resilient, and secure e-commerce platform.

Technologies Used

  • Spring Boot: For building microservices.
  • Spring Cloud: For managing distributed systems.
  • Circuit Breaker: To handle faults and prevent cascading failures.
  • Kafka: For real-time event-driven communication.
  • Distributed Tracing: For monitoring and tracing requests across microservices.
  • Prometheus: For monitoring and alerting.
  • Keycloak: For securing microservices and handling authentication and authorization.
  • Eureka Server: For service discovery and registration.

Microservices Overview

1. API Gateway

The API Gateway acts as the entry point for client applications, routing requests to the appropriate microservice. It also handles security, authentication, and authorization using Keycloak.

2. Product Service

The Product Service manages product information, including creation, retrieval, and updates. It communicates with the Inventory Service to ensure product availability.

3. Order Service

The Order Service is responsible for managing customer orders, processing payments, and order status updates. It communicates with the Product Service and Inventory Service.

4. Notification Service

The Notification Service sends notifications to customers about order updates and promotions. It uses Kafka for real-time event-based communication.

5. Inventory Service

The Inventory Service tracks product availability and manages inventory levels. It communicates with the Product Service and Order Service.

6. Discovery Service

The Discovery Service registers all microservices with Eureka Server, allowing other microservices to discover and communicate with each other.

Implementation

Microservices Communication

  • Microservices communicate with each other using RESTful APIs.
  • Kafka is used for asynchronous communication, enabling real-time updates.
  • Circuit Breaker patterns are implemented to handle faults gracefully.

Security

  • Keycloak is integrated to provide authentication and authorization.
  • Access to microservices is secured using JWT tokens.

Monitoring and Tracing

  • Prometheus is used for monitoring system metrics and generating alerts.
  • Distributed tracing is implemented to trace and monitor requests across microservices.

Service Discovery

  • Eureka Server is used for service registration and discovery.

Usage

To run and use this e-Commerce Microservices project, follow these steps:

  1. Ensure you have the necessary dependencies and tools installed, including Java, Spring Boot, Spring Cloud, Kafka, Keycloak, Prometheus, and Eureka Server.
  2. Clone the project repository and set up each microservice.
  3. Configure the services, including database connections, Kafka topics, and Keycloak integration.
  4. Run each microservice using Spring Boot.
  5. Access the API Gateway to interact with the e-commerce platform.

Conclusion

This e-Commerce Microservices project demonstrates the power of microservices architecture in building a scalable and resilient e-commerce platform. It incorporates essential features such as security, communication, monitoring, and service discovery. The project's modular structure allows for easy maintenance and scalability, making it a robust foundation for an e-commerce application.

Code Examples

Here's an example of how you can define a simple Spring Boot REST endpoint in one of the microservices:

@RestController
@RequestMapping("/api/products")
public class ProductController {
    
    @Autowired
    private ProductService productService;

    @GetMapping("/{productId}")
    public ResponseEntity<Product> getProductById(@PathVariable Long productId) {
        Product product = productService.getProductById(productId);
        if (product != null) {
            return ResponseEntity.ok(product);
        } else {
            return ResponseEntity.notFound().build();
        }
    }
    
    // Other CRUD operations for products
}

About

Implement inter-service communication using discovery server, implement service based routing through API Gateway, implement authorization and authentication using keycloak, implement circuit breaker, and using docker for containerization

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages