This project demonstrates a microservices-based architecture built with Spring Boot, Spring Cloud, and Spring Data JPA. It manages customers, products, and billing services, and uses Spring Cloud Gateway for routing and Eureka Discovery Server for service registration and discovery.
The system is based on a set of microservices that communicate with each other to manage customer data, product inventories, and bills. These microservices are registered with Eureka Discovery Server and accessed through Spring Cloud Gateway.
=======
This project consists of the following services:
- discovery-service: Eureka Discovery Server
- gateway: Spring Cloud Gateway
- customer-service: Manages customer data
- inventory-service: Manages product inventory
- billing-service: Handles billing operations
.
├── billing-service (Java)
├── customer-service (Java)
├── discovery-service (Java)
├── inventory-service (Java)
├── gateway (Java)
└── frontend-service (Angular)
- This service is responsible for managing customer data. It provides endpoints to create, retrieve, update, and delete customers.
- Port:
8081
Screenshot of Customer API Response:
- The Inventory Service handles all product-related operations. It provides endpoints to manage the inventory of products including creating, updating, and retrieving product information.
- Port:
8082
Screenshot of Inventory API Response:
- The Billing Service manages billing operations, which include generating bills for customers based on the products they purchase. It integrates with the Customer Service and Inventory Service using Feign Clients for retrieving customer and product data.
- Port:
8083
- Technology: Spring Boot, Feign Clients, Spring Data JPA
- The Spring Cloud Gateway acts as the unified entry point for client requests. It routes requests to the appropriate services (Customer, Inventory, Billing) based on the service discovery information from Eureka.
- Port:
8888
- Technology: Spring Cloud Gateway
Example of a request through the gateway:
http://localhost:8888/CUSTOMER-SERVICE/customers
http://localhost:8888/INVENTORY-SERVICE/products
- The Eureka Discovery Server registers all the services, making it easier for them to discover and communicate with each other.
- Port:
8761
- Technology: Spring Cloud Eureka
Screenshot of Eureka Dashboard:
<<<<<<< HEAD
This project consists of the following services:
- discovery-service: Eureka Discovery Server
- gateway: Spring Cloud Gateway
- customer-service: Manages customer data
- inventory-service: Manages product inventory
- billing-service: Handles billing operations
Here is a list of key dependencies used in each service:
- Spring Boot (v3.3.4)
- Spring Data JPA
- H2 Database (In-memory database for development)
- Lombok (for reducing boilerplate code)
- Spring Boot DevTools (for live reload during development)
- Spring Boot Starter Web: For building web and RESTful services.
- Spring Data REST: For easy exposure of repositories as RESTful endpoints.
- Spring Data JPA: For data persistence and interaction with the H2 database.
- OpenFeign: Declarative REST client used for inter-service communication.
- Feign Clients: To communicate with Customer and Inventory services.
- Spring Cloud Gateway: For routing requests to the relevant microservices.
- Spring Cloud Netflix Eureka: For service discovery and registration.
- Spring Boot Actuator: Provides endpoints to monitor and manage your application.
- Spring HATEOAS: To include hypermedia links in the response data.
-
Start the Eureka Discovery Service:
Run thediscovery-service
. -
Start the Gateway Service:
Run thegateway
service. -
Start the Customer, Inventory, and Billing Services:
Runcustomer-service
,inventory-service
, andbilling-service
. -
Access Services via Gateway:
- Customer Service:
http://localhost:8888/CUSTOMER-SERVICE/customers
- Inventory Service:
http://localhost:8888/INVENTORY-SERVICE/products
- Billing Service:
http://localhost:8888/BILLING-SERVICE/bills
- Access Eureka Dashboard:
- Eureka dashboard will be available at
http://localhost:8761/
- Eureka dashboard will be available at
http://localhost:8761/
- Eureka dashboard will be available at