How dt-jerald/microservice works
Purpose and topology
This is a Maven multi-service e-commerce backend. Each top-level service is independently bootstrapped as a Spring application and exposes an HTTP controller/service/repository stack. No API gateway or frontend is present. Service discovery is a separate runtime.
• discovery-server/src/main/java/com/discovery_server/DiscoveryServerApplication.java
• cart-service/src/main/java/com/example/cart_service/CartServiceApplication.java
• order-service/src/main/java/com/example/order_service/OrderServiceApplication.java
Service discovery and inter-service boundary
discovery-server is the registration/discovery infrastructure. Cross-service dependencies are represented by named client interfaces and Feign configuration, rather than direct repository access. Each service has its own application.yaml, which is the central runtime configuration boundary.
• discovery-server/src/main/resources/application.yaml
• cart-service/src/main/java/com/example/cart_service/client/ProductServiceClient.java
• order-service/src/main/java/com/example/order_service/config/AppConfig.java
Catalog and inventory domains
Category and product services own catalog records; inventory owns stock records and stock-status semantics. Product, payment, and notification services each declare clients for category and inventory, meaning their workflows depend on remote catalog/stock lookups rather than shared models.
• category-service/src/main/java/com/example/category_service/service/CategoryService.java
• product-service/src/main/java/com/example/product_service/service/ProductService.java
• inventory-service/src/main/java/com/example/inventory_service/service/InventoryService.java
Cart workflow
Cart service persists carts and cart items locally, while validating/enriching cart operations through product and inventory clients. Its controller is the cart HTTP entry point; the service coordinates local state and remote dependencies.
• cart-service/src/main/java/com/example/cart_service/controller/CartController.java
• cart-service/src/main/java/com/example/cart_service/service/CartService.java
• cart-service/src/main/java/com/example/cart_service/model/CartItem.java
Order orchestration
Order service is the primary transaction-like coordinator. It owns orders/order items and has outbound dependencies on cart, inventory, and notification services. The expected control path is request → order validation/creation → cart and stock interactions → notification invocation, with remote failures surfaced as service-communication or stock exceptions.
• order-service/src/main/java/com/example/order_service/service/OrderService.java
• order-service/src/main/java/com/example/order_service/client/CartServiceClient.java
• order-service/src/main/java/com/example/order_service/client/NotificationServiceClient.java
Payment and notifications
Payment owns payment and payment-detail persistence, with payment method/status/currency domain enums. Notification owns notification persistence and remotely references category and inventory. Neither directory shows a direct client connection to order service; they are independently callable services, with order explicitly calling notification.
• payment-service/src/main/java/com/example/payment_service/service/PaymentService.java
• payment-service/src/main/java/com/example/payment_service/model/PaymentDetails.java
• notification-service/src/main/java/com/example/notification_service/service/NotificationService.java
Identity, persistence, and error contracts
User service independently owns user lifecycle and address-related request/response contracts. Across services, controllers accept dedicated DTOs, services map to local JPA-style entities/repositories, and global handlers translate domain and remote-call failures into shared API-response shapes. Data is service-owned: there are no shared repository modules.
• user-service/src/main/java/com/example/user_service/controller/UserController.java
• user-service/src/main/java/com/example/user_service/service/UserService.java
• product-service/src/main/java/com/example/product_service/exception/GlobalExceptionHandler.java
Main entry points: CartService.java Cart Service · InventoryService.java Inventory Service · DiscoveryServerApplication.java Discovery Server · ProductService.java Product Service
Components 17
Platform
- Discovery Server · Registers and resolves service instances.
discovery-server/src/main/java/com/discovery_server/DiscoveryServerApplication.java - Discovery Runtime Config
discovery-server/src/main/resources/application.yaml
Catalog & Stock
- Category Service · Owns category records.
category-service/src/main/java/com/example/category_service/service/CategoryService.java - Product Service · Owns product records and uses remote category and inventory lookups.
product-service/src/main/java/com/example/product_service/service/ProductService.java - Inventory Service · Owns stock records and stock-status semantics.
inventory-service/src/main/java/com/example/inventory_service/service/InventoryService.java - Product Error Handler · Maps domain and remote failures to API responses.
product-service/src/main/java/com/example/product_service/exception/GlobalExceptionHandler.java
Cart & Orders
- Cart Controller
cart-service/src/main/java/com/example/cart_service/controller/CartController.java - Cart Service · Coordinates cart state with product and inventory validation.
cart-service/src/main/java/com/example/cart_service/service/CartService.java - Cart Items · Service-owned persisted cart item state.
cart-service/src/main/java/com/example/cart_service/model/CartItem.java - Order Service · Creates orders and coordinates cart, stock, and notifications.
order-service/src/main/java/com/example/order_service/service/OrderService.java - Cart Client
order-service/src/main/java/com/example/order_service/client/CartServiceClient.java - Notification Client
order-service/src/main/java/com/example/order_service/client/NotificationServiceClient.java
Supporting Services
- Payment Service · Owns payment and payment-detail persistence.
payment-service/src/main/java/com/example/payment_service/service/PaymentService.java - Payment Details
payment-service/src/main/java/com/example/payment_service/model/PaymentDetails.java - Notification Service · Owns notifications and uses remote category and inventory references.
notification-service/src/main/java/com/example/notification_service/service/NotificationService.java - User Controller
user-service/src/main/java/com/example/user_service/controller/UserController.java - User Service · Owns user lifecycle and address contracts.
user-service/src/main/java/com/example/user_service/service/UserService.java
Connections 24
- Discovery Runtime Config → Discovery Server: configures
- Category Service → Discovery Server: registers / discovers
- Product Service → Discovery Server: registers / discovers
- Inventory Service → Discovery Server: registers / discovers
- Cart Service → Discovery Server: registers / discovers
- Order Service → Discovery Server: registers / discovers
- Cart Controller → Cart Service: HTTP request
- Cart Service → Cart Items: persists
- Cart Service → Product Service: product lookup
- Cart Service → Inventory Service: stock validation
- Product Service → Category Service: category lookup
- Product Service → Inventory Service: inventory lookup
- Product Error Handler → Product Service: handles failures from
- Order Service → Cart Client: uses
- Cart Client → Cart Service: cart interaction
- Order Service → Inventory Service: stock interaction
- Order Service → Notification Client: uses
- Notification Client → Notification Service: invoke notification
- Payment Service → Payment Details: persists
- Payment Service → Category Service: category lookup
- Payment Service → Inventory Service: inventory lookup
- Notification Service → Category Service: category lookup
- Notification Service → Inventory Service: inventory lookup
- User Controller → User Service: HTTP request