# wenqiglantz/spring-boot-aws-eventbridge architecture

> Architecture diagram of the GitHub repository wenqiglantz/spring-boot-aws-eventbridge, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-10). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/wenqiglantz/spring-boot-aws-eventbridge
- Repository: https://github.com/wenqiglantz/spring-boot-aws-eventbridge

## Overview

1. This repo contains two independent Spring Boot microservices: `customer-service` and `order-service`. They are built and deployed separately, each with its own `pom.xml`, Dockerfile, application config, database changelog, and source tree.

2. The main architectural style is event-driven pub/sub using AWS EventBridge. `customer-service` is the event publisher, and `order-service` is a subscriber/consumer. The README states that `CustomerCreatedEvent` is published to EventBridge, which then fans out to multiple targets.

3. The primary synchronous flow in `customer-service` is a standard layered REST app: `CustomerController` receives HTTP requests, delegates to `CustomerService`, which uses `CustomerRepository` and the JPA entity model under `persistence/entity`. That service also produces domain events from the customer lifecycle.

4. `customer-service` is organized around a customer domain with supporting DTOs and event payloads in `data/`. It has explicit event classes for create/update/delete, error models, and a `NotFoundException` for missing resources. This keeps API, persistence, and integration-event representations separate.

5. `order-service` has the same layered structure, but with an additional inbound integration boundary. Besides `OrderController`, it includes `SubscriberController`, which is the endpoint meant to receive EventBridge-delivered events, likely through API Gateway as described in the README.

6. On the subscriber side, `order-service` defines a richer event model: a common `Event` type plus `CustomerCreatedEvent`, `CustomerUpdatedEvent`, and `CustomerDeletedEvent`. This suggests the service can react to multiple customer-domain changes, not just creation events, and maintain a local projection or related state.

7. Both services persist data locally using Spring Data JPA with a `Customer` entity and `CustomerRepository`. Each service has Liquibase changelogs under `src/main/resources/changelog`, so schema evolution is versioned and applied at startup or deployment time.

8. There is explicit datasource truststore configuration in both services (`DataSourceConfiguration` and `DataSourceTruststoreProperties`), plus a `postgre.jks` file in each module. That indicates the database connection is configured with TLS/SSL trust material, which is an important infrastructure boundary in the deployment.

9. Error handling is centralized in each service with `GeneralExceptionControllerAdvice`, `ErrorResponse`, and `ErrorType`. This gives both the REST APIs and the subscriber endpoint consistent failure responses.

10. Each service exposes Swagger/OpenAPI configuration through `SwaggerConfiguration`, so the HTTP boundary is intended to be documented and inspectable. That matters for the REST-facing parts of both services, especially the consumer endpoint in `order-service`.

11. The repository is clearly designed for containerized deployment. Both modules have Dockerfiles and ignore files, and `order-service` also includes the Maven wrapper, suggesting independent build and runtime packaging for each microservice.

12. From an architecture-diagram perspective, the key data flow is: client requests enter `customer-service`, customer state is stored in its database, a customer event is emitted to EventBridge, EventBridge routes it to `order-service` via API Gateway, and `order-service` persists or updates its own local state in response. The Lambda mentioned in the README is an external demonstration target, not part of the code tree, but it reinforces the fan-out nature of the event bus.

Main entry points: [`order-service/src/main/java/com/github/wenqiglantz/service/eventbridge/orderservice/service/impl/OrderServiceImpl.java`](https://github.com/wenqiglantz/spring-boot-aws-eventbridge/blob/main/order-service/src/main/java/com/github/wenqiglantz/service/eventbridge/orderservice/service/impl/OrderServiceImpl.java) (Order service impl), [`customer-service/src/main/java/com/github/wenqiglantz/service/eventbridge/customerservice/service/impl/CustomerServiceImpl.java`](https://github.com/wenqiglantz/spring-boot-aws-eventbridge/blob/main/customer-service/src/main/java/com/github/wenqiglantz/service/eventbridge/customerservice/service/impl/CustomerServiceImpl.java) (Customer service impl), [`order-service/src/main/java/com/github/wenqiglantz/service/eventbridge/orderservice/OrderServiceApplication.java`](https://github.com/wenqiglantz/spring-boot-aws-eventbridge/blob/main/order-service/src/main/java/com/github/wenqiglantz/service/eventbridge/orderservice/OrderServiceApplication.java) (Order service), [`order-service/src/main/java/com/github/wenqiglantz/service/eventbridge/orderservice/restcontroller/SubscriberController.java`](https://github.com/wenqiglantz/spring-boot-aws-eventbridge/blob/main/order-service/src/main/java/com/github/wenqiglantz/service/eventbridge/orderservice/restcontroller/SubscriberController.java) (Subscriber API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_repo["Repository"]
  node_repo_root["spring-boot-aws-eventbridge<br/>monorepo"]
end

subgraph group_customer["customer-service"]
  node_customer_app(("Customer service<br/>spring boot app"))
  node_customer_controller["Customer API<br/>REST controller"]
  node_customer_service["Customer service impl<br/>service layer"]
  node_customer_repo["Customer repo<br/>JPA repository"]
  node_customer_model["Customer model<br/>entity model<br/>[Customer.java]"]
  node_customer_events["Customer events<br/>domain events"]
  node_customer_config["DB config<br/>datasource config"]
  node_customer_migrations["Liquibase<br/>db changelog"]
end

subgraph group_order["order-service"]
  node_order_app(("Order service<br/>spring boot app"))
  node_order_controller["Order API<br/>REST controller"]
  node_subscriber_controller["Subscriber API<br/>event ingress"]
  node_order_service["Order service impl<br/>service layer"]
  node_order_repo["Order repo<br/>JPA repository"]
  node_order_model["Order model<br/>entity model<br/>[Customer.java]"]
  node_order_events["Event model<br/>integration events<br/>[Event.java]"]
  node_order_config["DB config<br/>datasource config"]
  node_order_migrations["Liquibase<br/>db changelog"]
end

subgraph group_infra["External infra"]
  node_eventbridge{{"EventBridge<br/>pub/sub bus"}}
  node_apigw{{"API Gateway<br/>ingress gateway"}}
  node_customer_db[("Customer DB<br/>postgres database")]
  node_order_db[("Order DB<br/>postgres database")]
end

node_repo_root -->|"contains"| node_customer_app
node_repo_root -->|"contains"| node_order_app
node_customer_app -->|"exposes"| node_customer_controller
node_customer_controller -->|"delegates"| node_customer_service
node_customer_service -->|"persists via"| node_customer_repo
node_customer_repo -->|"maps"| node_customer_model
node_customer_service -->|"publishes"| node_customer_events
node_customer_service -->|"uses"| node_customer_config
node_customer_config -->|"connects to"| node_customer_db
node_customer_migrations -->|"migrates"| node_customer_db
node_customer_events -->|"publishes to"| node_eventbridge
node_eventbridge -->|"routes to"| node_apigw
node_apigw -->|"invokes"| node_subscriber_controller
node_order_app -->|"exposes"| node_order_controller
node_order_app -->|"exposes"| node_subscriber_controller
node_subscriber_controller -->|"delegates"| node_order_service
node_order_controller -->|"delegates"| node_order_service
node_order_service -->|"persists via"| node_order_repo
node_order_repo -->|"maps"| node_order_model
node_order_service -->|"consumes"| node_order_events
node_order_service -->|"uses"| node_order_config
node_order_config -->|"connects to"| node_order_db
node_order_migrations -->|"migrates"| node_order_db

click node_customer_app "https://github.com/wenqiglantz/spring-boot-aws-eventbridge/blob/main/customer-service/src/main/java/com/github/wenqiglantz/service/eventbridge/customerservice/CustomerServiceApplication.java"
click node_customer_controller "https://github.com/wenqiglantz/spring-boot-aws-eventbridge/blob/main/customer-service/src/main/java/com/github/wenqiglantz/service/eventbridge/customerservice/restcontroller/CustomerController.java"
click node_customer_service "https://github.com/wenqiglantz/spring-boot-aws-eventbridge/blob/main/customer-service/src/main/java/com/github/wenqiglantz/service/eventbridge/customerservice/service/impl/CustomerServiceImpl.java"
click node_customer_repo "https://github.com/wenqiglantz/spring-boot-aws-eventbridge/blob/main/customer-service/src/main/java/com/github/wenqiglantz/service/eventbridge/customerservice/persistence/repository/CustomerRepository.java"
click node_customer_model "https://github.com/wenqiglantz/spring-boot-aws-eventbridge/blob/main/customer-service/src/main/java/com/github/wenqiglantz/service/eventbridge/customerservice/persistence/entity/Customer.java"
click node_customer_events "https://github.com/wenqiglantz/spring-boot-aws-eventbridge/tree/main/customer-service/src/main/java/com/github/wenqiglantz/service/eventbridge/customerservice/data/event"
click node_customer_config "https://github.com/wenqiglantz/spring-boot-aws-eventbridge/blob/main/customer-service/src/main/java/com/github/wenqiglantz/service/eventbridge/customerservice/config/DataSourceConfiguration.java"
click node_customer_migrations "https://github.com/wenqiglantz/spring-boot-aws-eventbridge/blob/main/customer-service/src/main/resources/changelog/db.changelog-master.xml"
click node_order_app "https://github.com/wenqiglantz/spring-boot-aws-eventbridge/blob/main/order-service/src/main/java/com/github/wenqiglantz/service/eventbridge/orderservice/OrderServiceApplication.java"
click node_order_controller "https://github.com/wenqiglantz/spring-boot-aws-eventbridge/blob/main/order-service/src/main/java/com/github/wenqiglantz/service/eventbridge/orderservice/restcontroller/OrderController.java"
click node_subscriber_controller "https://github.com/wenqiglantz/spring-boot-aws-eventbridge/blob/main/order-service/src/main/java/com/github/wenqiglantz/service/eventbridge/orderservice/restcontroller/SubscriberController.java"
click node_order_service "https://github.com/wenqiglantz/spring-boot-aws-eventbridge/blob/main/order-service/src/main/java/com/github/wenqiglantz/service/eventbridge/orderservice/service/impl/OrderServiceImpl.java"
click node_order_repo "https://github.com/wenqiglantz/spring-boot-aws-eventbridge/blob/main/order-service/src/main/java/com/github/wenqiglantz/service/eventbridge/orderservice/persistence/repository/CustomerRepository.java"
click node_order_model "https://github.com/wenqiglantz/spring-boot-aws-eventbridge/blob/main/order-service/src/main/java/com/github/wenqiglantz/service/eventbridge/orderservice/persistence/entity/Customer.java"
click node_order_events "https://github.com/wenqiglantz/spring-boot-aws-eventbridge/blob/main/order-service/src/main/java/com/github/wenqiglantz/service/eventbridge/orderservice/data/event/Event.java"
click node_order_config "https://github.com/wenqiglantz/spring-boot-aws-eventbridge/blob/main/order-service/src/main/java/com/github/wenqiglantz/service/eventbridge/orderservice/config/DataSourceConfiguration.java"
click node_order_migrations "https://github.com/wenqiglantz/spring-boot-aws-eventbridge/blob/main/order-service/src/main/resources/changelog/db.changelog-master.xml"

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_repo_root toneBlue
class node_customer_app,node_customer_controller,node_customer_service,node_customer_repo,node_customer_model,node_customer_events,node_customer_config,node_customer_migrations toneAmber
class node_order_app,node_order_controller,node_subscriber_controller,node_order_service,node_order_repo,node_order_model,node_order_events,node_order_config,node_order_migrations toneMint
class node_eventbridge,node_apigw,node_customer_db,node_order_db toneRose
```

## Components

### Repository

Top-level Spring Boot microservices with shared event-driven deployment model.

- **spring-boot-aws-eventbridge**: monorepo · Repository containing two independently built Spring Boot microservices.

### customer-service

Publisher microservice for customer CRUD and customer-domain events.

- [Customer service](https://github.com/wenqiglantz/spring-boot-aws-eventbridge/blob/main/customer-service/src/main/java/com/github/wenqiglantz/service/eventbridge/customerservice/CustomerServiceApplication.java): spring boot app · Publisher service for customer lifecycle and REST API. · `customer-service/src/main/java/com/github/wenqiglantz/service/eventbridge/customerservice/CustomerServiceApplication.java`
- [Customer API](https://github.com/wenqiglantz/spring-boot-aws-eventbridge/blob/main/customer-service/src/main/java/com/github/wenqiglantz/service/eventbridge/customerservice/restcontroller/CustomerController.java): REST controller · HTTP boundary for customer CRUD operations. · `customer-service/src/main/java/com/github/wenqiglantz/service/eventbridge/customerservice/restcontroller/CustomerController.java`
- [Customer service impl](https://github.com/wenqiglantz/spring-boot-aws-eventbridge/blob/main/customer-service/src/main/java/com/github/wenqiglantz/service/eventbridge/customerservice/service/impl/CustomerServiceImpl.java): service layer · Coordinates customer use cases and event emission. · `customer-service/src/main/java/com/github/wenqiglantz/service/eventbridge/customerservice/service/impl/CustomerServiceImpl.java`
- [Customer repo](https://github.com/wenqiglantz/spring-boot-aws-eventbridge/blob/main/customer-service/src/main/java/com/github/wenqiglantz/service/eventbridge/customerservice/persistence/repository/CustomerRepository.java): JPA repository · Persistence access for customer aggregates. · `customer-service/src/main/java/com/github/wenqiglantz/service/eventbridge/customerservice/persistence/repository/CustomerRepository.java`
- [Customer model](https://github.com/wenqiglantz/spring-boot-aws-eventbridge/blob/main/customer-service/src/main/java/com/github/wenqiglantz/service/eventbridge/customerservice/persistence/entity/Customer.java): entity model · Local customer entity and persistence schema. · `customer-service/src/main/java/com/github/wenqiglantz/service/eventbridge/customerservice/persistence/entity/Customer.java`
- [Customer events](https://github.com/wenqiglantz/spring-boot-aws-eventbridge/tree/main/customer-service/src/main/java/com/github/wenqiglantz/service/eventbridge/customerservice/data/event): domain events · Customer-created, updated, and deleted event payloads plus DTOs. · `customer-service/src/main/java/com/github/wenqiglantz/service/eventbridge/customerservice/data/event`
- [DB config](https://github.com/wenqiglantz/spring-boot-aws-eventbridge/blob/main/customer-service/src/main/java/com/github/wenqiglantz/service/eventbridge/customerservice/config/DataSourceConfiguration.java): datasource config · JPA datasource and truststore wiring for secure database access. · `customer-service/src/main/java/com/github/wenqiglantz/service/eventbridge/customerservice/config/DataSourceConfiguration.java`
- [Liquibase](https://github.com/wenqiglantz/spring-boot-aws-eventbridge/blob/main/customer-service/src/main/resources/changelog/db.changelog-master.xml): db changelog · Versioned schema migrations for the customer database. · `customer-service/src/main/resources/changelog/db.changelog-master.xml`

### order-service

Consumer microservice for orders plus customer event subscription.

- [Order service](https://github.com/wenqiglantz/spring-boot-aws-eventbridge/blob/main/order-service/src/main/java/com/github/wenqiglantz/service/eventbridge/orderservice/OrderServiceApplication.java): spring boot app · Consumer service for order APIs and customer-event projections. · `order-service/src/main/java/com/github/wenqiglantz/service/eventbridge/orderservice/OrderServiceApplication.java`
- [Order API](https://github.com/wenqiglantz/spring-boot-aws-eventbridge/blob/main/order-service/src/main/java/com/github/wenqiglantz/service/eventbridge/orderservice/restcontroller/OrderController.java): REST controller · HTTP boundary for order-related operations. · `order-service/src/main/java/com/github/wenqiglantz/service/eventbridge/orderservice/restcontroller/OrderController.java`
- [Subscriber API](https://github.com/wenqiglantz/spring-boot-aws-eventbridge/blob/main/order-service/src/main/java/com/github/wenqiglantz/service/eventbridge/orderservice/restcontroller/SubscriberController.java): event ingress · Inbound endpoint for EventBridge-delivered customer events. · `order-service/src/main/java/com/github/wenqiglantz/service/eventbridge/orderservice/restcontroller/SubscriberController.java`
- [Order service impl](https://github.com/wenqiglantz/spring-boot-aws-eventbridge/blob/main/order-service/src/main/java/com/github/wenqiglantz/service/eventbridge/orderservice/service/impl/OrderServiceImpl.java): service layer · Coordinates order use cases and local state updates from events. · `order-service/src/main/java/com/github/wenqiglantz/service/eventbridge/orderservice/service/impl/OrderServiceImpl.java`
- [Order repo](https://github.com/wenqiglantz/spring-boot-aws-eventbridge/blob/main/order-service/src/main/java/com/github/wenqiglantz/service/eventbridge/orderservice/persistence/repository/CustomerRepository.java): JPA repository · Persistence access for the order-service local model. · `order-service/src/main/java/com/github/wenqiglantz/service/eventbridge/orderservice/persistence/repository/CustomerRepository.java`
- [Order model](https://github.com/wenqiglantz/spring-boot-aws-eventbridge/blob/main/order-service/src/main/java/com/github/wenqiglantz/service/eventbridge/orderservice/persistence/entity/Customer.java): entity model · Local entity model persisted by the order service. · `order-service/src/main/java/com/github/wenqiglantz/service/eventbridge/orderservice/persistence/entity/Customer.java`
- [Event model](https://github.com/wenqiglantz/spring-boot-aws-eventbridge/blob/main/order-service/src/main/java/com/github/wenqiglantz/service/eventbridge/orderservice/data/event/Event.java): integration events · Shared event envelope plus customer-created, updated, and deleted payloads. · `order-service/src/main/java/com/github/wenqiglantz/service/eventbridge/orderservice/data/event/Event.java`
- [DB config](https://github.com/wenqiglantz/spring-boot-aws-eventbridge/blob/main/order-service/src/main/java/com/github/wenqiglantz/service/eventbridge/orderservice/config/DataSourceConfiguration.java): datasource config · JPA datasource and truststore wiring for secure database access. · `order-service/src/main/java/com/github/wenqiglantz/service/eventbridge/orderservice/config/DataSourceConfiguration.java`
- [Liquibase](https://github.com/wenqiglantz/spring-boot-aws-eventbridge/blob/main/order-service/src/main/resources/changelog/db.changelog-master.xml): db changelog · Versioned schema migrations for the order database. · `order-service/src/main/resources/changelog/db.changelog-master.xml`

### External infra

Messaging, API ingress, and database infrastructure boundaries.

- **EventBridge**: pub/sub bus · Fan-out event bus for customer-domain integration events.
- **API Gateway**: ingress gateway · Delivery boundary used to invoke the subscriber endpoint.
- **Customer DB**: postgres database · Local persistent store for customer-service.
- **Order DB**: postgres database · Local persistent store for order-service.

## Connections

- spring-boot-aws-eventbridge → Customer service: contains · Repository includes the customer microservice module.
- spring-boot-aws-eventbridge → Order service: contains · Repository includes the order microservice module.
- Customer service → Customer API: exposes · Application serves customer REST endpoints.
- Customer API → Customer service impl: delegates · Controller forwards CRUD requests to the service layer.
- Customer service impl → Customer repo: persists via · Customer use cases read and write through the repository.
- Customer repo → Customer model: maps · Repository operates on the customer entity model.
- Customer service impl → Customer events: publishes · Customer lifecycle changes are emitted as events.
- Customer service impl → DB config: uses · Service runtime relies on datasource and truststore configuration.
- DB config → Customer DB: connects to · Datasource configuration targets the local customer database.
- Liquibase → Customer DB: migrates · Liquibase updates the customer schema.
- Customer events → EventBridge: publishes to · CustomerCreatedEvent and related events are sent to EventBridge.
- EventBridge → API Gateway: routes to · EventBridge fans out to the subscriber ingress path.
- API Gateway → Subscriber API: invokes · API Gateway delivers events to the order-service subscriber endpoint.
- Order service → Order API: exposes · Application serves order REST endpoints.
- Order service → Subscriber API: exposes · Application also exposes the event subscriber boundary.
- Subscriber API → Order service impl: delegates · Inbound events are handled by the order service layer.
- Order API → Order service impl: delegates · Order API requests flow into the service layer.
- Order service impl → Order repo: persists via · Order use cases read and write through the repository.
- Order repo → Order model: maps · Repository operates on the local entity model.
- Order service impl → Event model: consumes · Subscriber logic interprets customer-domain events.
- Order service impl → DB config: uses · Service runtime relies on datasource and truststore configuration.
- DB config → Order DB: connects to · Datasource configuration targets the local order database.
- Liquibase → Order DB: migrates · Liquibase updates the order schema.
