# dt-jerald/microservice architecture

> Architecture diagram of the GitHub repository dt-jerald/microservice, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-19). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/dt-jerald/microservice
- Repository: https://github.com/dt-jerald/microservice

## Overview

#### 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: [`cart-service/src/main/java/com/example/cart_service/service/CartService.java`](https://github.com/dt-jerald/microservice/blob/main/cart-service/src/main/java/com/example/cart_service/service/CartService.java) (Cart Service), [`inventory-service/src/main/java/com/example/inventory_service/service/InventoryService.java`](https://github.com/dt-jerald/microservice/blob/main/inventory-service/src/main/java/com/example/inventory_service/service/InventoryService.java) (Inventory Service), [`discovery-server/src/main/java/com/discovery_server/DiscoveryServerApplication.java`](https://github.com/dt-jerald/microservice/blob/main/discovery-server/src/main/java/com/discovery_server/DiscoveryServerApplication.java) (Discovery Server), [`product-service/src/main/java/com/example/product_service/service/ProductService.java`](https://github.com/dt-jerald/microservice/blob/main/product-service/src/main/java/com/example/product_service/service/ProductService.java) (Product Service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_platform["Platform"]
  node_discovery{{"Discovery Server<br/>Spring service discovery"}}
  node_discovery_config["Discovery Runtime Config<br/>application config<br/>[application.yaml]"]
end

subgraph group_catalog["Catalog &amp; Stock"]
  node_category["Category Service<br/>catalog service"]
  node_product["Product Service<br/>catalog service"]
  node_inventory["Inventory Service<br/>stock service"]
  node_product_errors["Product Error Handler<br/>API error boundary"]
end

subgraph group_commerce["Cart &amp; Orders"]
  node_cart_controller["Cart Controller<br/>HTTP controller"]
  node_cart["Cart Service<br/>cart domain service<br/>[CartService.java]"]
  node_cart_items[("Cart Items<br/>local cart entity<br/>[CartItem.java]")]
  node_order["Order Service<br/>order orchestrator<br/>[OrderService.java]"]
  node_order_cart_client["Cart Client<br/>Feign client"]
  node_order_notification_client["Notification Client<br/>Feign client"]
end

subgraph group_support["Supporting Services"]
  node_payment["Payment Service"]
  node_payment_details[("Payment Details<br/>local payment entity")]
  node_notification["Notification Service"]
  node_user_controller["User Controller<br/>HTTP controller"]
  node_user["User Service<br/>identity service<br/>[UserService.java]"]
end

node_discovery_config -->|"configures"| node_discovery
node_category -.->|"registers / discovers"| node_discovery
node_product -.->|"registers / discovers"| node_discovery
node_inventory -.->|"registers / discovers"| node_discovery
node_cart -.->|"registers / discovers"| node_discovery
node_order -.->|"registers / discovers"| node_discovery
node_cart_controller -->|"HTTP request"| node_cart
node_cart -->|"persists"| node_cart_items
node_cart -.->|"product lookup"| node_product
node_cart -.->|"stock validation"| node_inventory
node_product -.->|"category lookup"| node_category
node_product -.->|"inventory lookup"| node_inventory
node_product_errors -->|"handles failures from"| node_product
node_order -->|"uses"| node_order_cart_client
node_order_cart_client -.->|"cart interaction"| node_cart
node_order -.->|"stock interaction"| node_inventory
node_order -->|"uses"| node_order_notification_client
node_order_notification_client -.->|"invoke notification"| node_notification
node_payment -->|"persists"| node_payment_details
node_payment -.->|"category lookup"| node_category
node_payment -.->|"inventory lookup"| node_inventory
node_notification -.->|"category lookup"| node_category
node_notification -.->|"inventory lookup"| node_inventory
node_user_controller -->|"HTTP request"| node_user

click node_discovery "https://github.com/dt-jerald/microservice/blob/main/discovery-server/src/main/java/com/discovery_server/DiscoveryServerApplication.java"
click node_discovery_config "https://github.com/dt-jerald/microservice/blob/main/discovery-server/src/main/resources/application.yaml"
click node_category "https://github.com/dt-jerald/microservice/blob/main/category-service/src/main/java/com/example/category_service/service/CategoryService.java"
click node_product "https://github.com/dt-jerald/microservice/blob/main/product-service/src/main/java/com/example/product_service/service/ProductService.java"
click node_inventory "https://github.com/dt-jerald/microservice/blob/main/inventory-service/src/main/java/com/example/inventory_service/service/InventoryService.java"
click node_product_errors "https://github.com/dt-jerald/microservice/blob/main/product-service/src/main/java/com/example/product_service/exception/GlobalExceptionHandler.java"
click node_cart_controller "https://github.com/dt-jerald/microservice/blob/main/cart-service/src/main/java/com/example/cart_service/controller/CartController.java"
click node_cart "https://github.com/dt-jerald/microservice/blob/main/cart-service/src/main/java/com/example/cart_service/service/CartService.java"
click node_cart_items "https://github.com/dt-jerald/microservice/blob/main/cart-service/src/main/java/com/example/cart_service/model/CartItem.java"
click node_order "https://github.com/dt-jerald/microservice/blob/main/order-service/src/main/java/com/example/order_service/service/OrderService.java"
click node_order_cart_client "https://github.com/dt-jerald/microservice/blob/main/order-service/src/main/java/com/example/order_service/client/CartServiceClient.java"
click node_order_notification_client "https://github.com/dt-jerald/microservice/blob/main/order-service/src/main/java/com/example/order_service/client/NotificationServiceClient.java"
click node_payment "https://github.com/dt-jerald/microservice/blob/main/payment-service/src/main/java/com/example/payment_service/service/PaymentService.java"
click node_payment_details "https://github.com/dt-jerald/microservice/blob/main/payment-service/src/main/java/com/example/payment_service/model/PaymentDetails.java"
click node_notification "https://github.com/dt-jerald/microservice/blob/main/notification-service/src/main/java/com/example/notification_service/service/NotificationService.java"
click node_user_controller "https://github.com/dt-jerald/microservice/blob/main/user-service/src/main/java/com/example/user_service/controller/UserController.java"
click node_user "https://github.com/dt-jerald/microservice/blob/main/user-service/src/main/java/com/example/user_service/service/UserService.java"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_discovery,node_discovery_config toneBlue
class node_category,node_product,node_inventory,node_product_errors toneAmber
class node_cart_controller,node_cart,node_cart_items,node_order,node_order_cart_client,node_order_notification_client toneMint
class node_payment,node_payment_details,node_notification,node_user_controller,node_user toneRose
```

## Components

### Platform

- [Discovery Server](https://github.com/dt-jerald/microservice/blob/main/discovery-server/src/main/java/com/discovery_server/DiscoveryServerApplication.java): Spring service discovery · Registers and resolves service instances. · `discovery-server/src/main/java/com/discovery_server/DiscoveryServerApplication.java`
- [Discovery Runtime Config](https://github.com/dt-jerald/microservice/blob/main/discovery-server/src/main/resources/application.yaml): application config · `discovery-server/src/main/resources/application.yaml`

### Catalog & Stock

- [Category Service](https://github.com/dt-jerald/microservice/blob/main/category-service/src/main/java/com/example/category_service/service/CategoryService.java): catalog service · Owns category records. · `category-service/src/main/java/com/example/category_service/service/CategoryService.java`
- [Product Service](https://github.com/dt-jerald/microservice/blob/main/product-service/src/main/java/com/example/product_service/service/ProductService.java): catalog 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](https://github.com/dt-jerald/microservice/blob/main/inventory-service/src/main/java/com/example/inventory_service/service/InventoryService.java): stock service · Owns stock records and stock-status semantics. · `inventory-service/src/main/java/com/example/inventory_service/service/InventoryService.java`
- [Product Error Handler](https://github.com/dt-jerald/microservice/blob/main/product-service/src/main/java/com/example/product_service/exception/GlobalExceptionHandler.java): API error boundary · Maps domain and remote failures to API responses. · `product-service/src/main/java/com/example/product_service/exception/GlobalExceptionHandler.java`

### Cart & Orders

- [Cart Controller](https://github.com/dt-jerald/microservice/blob/main/cart-service/src/main/java/com/example/cart_service/controller/CartController.java): HTTP controller · `cart-service/src/main/java/com/example/cart_service/controller/CartController.java`
- [Cart Service](https://github.com/dt-jerald/microservice/blob/main/cart-service/src/main/java/com/example/cart_service/service/CartService.java): cart domain service · Coordinates cart state with product and inventory validation. · `cart-service/src/main/java/com/example/cart_service/service/CartService.java`
- [Cart Items](https://github.com/dt-jerald/microservice/blob/main/cart-service/src/main/java/com/example/cart_service/model/CartItem.java): local cart entity · Service-owned persisted cart item state. · `cart-service/src/main/java/com/example/cart_service/model/CartItem.java`
- [Order Service](https://github.com/dt-jerald/microservice/blob/main/order-service/src/main/java/com/example/order_service/service/OrderService.java): order orchestrator · Creates orders and coordinates cart, stock, and notifications. · `order-service/src/main/java/com/example/order_service/service/OrderService.java`
- [Cart Client](https://github.com/dt-jerald/microservice/blob/main/order-service/src/main/java/com/example/order_service/client/CartServiceClient.java): Feign client · `order-service/src/main/java/com/example/order_service/client/CartServiceClient.java`
- [Notification Client](https://github.com/dt-jerald/microservice/blob/main/order-service/src/main/java/com/example/order_service/client/NotificationServiceClient.java): Feign client · `order-service/src/main/java/com/example/order_service/client/NotificationServiceClient.java`

### Supporting Services

- [Payment Service](https://github.com/dt-jerald/microservice/blob/main/payment-service/src/main/java/com/example/payment_service/service/PaymentService.java): payment service · Owns payment and payment-detail persistence. · `payment-service/src/main/java/com/example/payment_service/service/PaymentService.java`
- [Payment Details](https://github.com/dt-jerald/microservice/blob/main/payment-service/src/main/java/com/example/payment_service/model/PaymentDetails.java): local payment entity · `payment-service/src/main/java/com/example/payment_service/model/PaymentDetails.java`
- [Notification Service](https://github.com/dt-jerald/microservice/blob/main/notification-service/src/main/java/com/example/notification_service/service/NotificationService.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](https://github.com/dt-jerald/microservice/blob/main/user-service/src/main/java/com/example/user_service/controller/UserController.java): HTTP controller · `user-service/src/main/java/com/example/user_service/controller/UserController.java`
- [User Service](https://github.com/dt-jerald/microservice/blob/main/user-service/src/main/java/com/example/user_service/service/UserService.java): identity service · Owns user lifecycle and address contracts. · `user-service/src/main/java/com/example/user_service/service/UserService.java`

## Connections

- 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
