# arhohuttunen/hexagonal-architecture-spring-boot architecture

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

- Interactive diagram: https://gitdiagram.com/arhohuttunen/hexagonal-architecture-spring-boot
- Repository: https://github.com/arhohuttunen/hexagonal-architecture-spring-boot
- Video tour (about a minute): https://gitdiagram.com/arhohuttunen/hexagonal-architecture-spring-boot/video

## Overview

This is a Spring Boot coffee-shop ordering application organized around hexagonal ports and adapters. A customer submits or changes an order through REST; the application use case validates domain transitions and uses order/payment ports. Payment, receipt lookup, and order taking are distinct operations, while coffee preparation is represented by separate application ports and order states. The sampled code confirms the REST-to-use-case and use-case-to-port calls; infrastructure persistence wiring and preparation dispatch are present in the tree but were not shown, so those links are marked unverified.

Main entry points: [`coffeeshop-application/src/main/java/com/arhohuttunen/coffeeshop/application/CoffeeShop.java`](https://github.com/arhohuttunen/hexagonal-architecture-spring-boot/blob/main/coffeeshop-application/src/main/java/com/arhohuttunen/coffeeshop/application/CoffeeShop.java) (Coffee Shop Use Case), [`coffeeshop-infrastructure/src/main/java/com/arhohuttunen/coffeeshop/adapter/in/rest/PaymentController.java`](https://github.com/arhohuttunen/hexagonal-architecture-spring-boot/blob/main/coffeeshop-infrastructure/src/main/java/com/arhohuttunen/coffeeshop/adapter/in/rest/PaymentController.java) (Payment Controller), [`coffeeshop-infrastructure/src/main/java/com/arhohuttunen/coffeeshop/adapter/in/rest/OrderController.java`](https://github.com/arhohuttunen/hexagonal-architecture-spring-boot/blob/main/coffeeshop-infrastructure/src/main/java/com/arhohuttunen/coffeeshop/adapter/in/rest/OrderController.java) (Order Controller), [`coffeeshop-application/src/main/java/com/arhohuttunen/coffeeshop/application/in/OrderingCoffee.java`](https://github.com/arhohuttunen/hexagonal-architecture-spring-boot/blob/main/coffeeshop-application/src/main/java/com/arhohuttunen/coffeeshop/application/in/OrderingCoffee.java) (Ordering Port)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["REST API"]
  node_orders_api["Order Controller"]
  node_payments_api["Payment Controller"]
  node_receipts_api["Receipt Controller"]
  node_order_payloads["Order Resources"]
  node_payment_payloads["Payment Resources"]
  node_receipt_payload["Receipt Response"]
end

subgraph group_application["Application Use Cases"]
  node_ordering_port["Ordering Port"]
  node_coffee_shop["Coffee Shop Use Case<br/>[CoffeeShop.java]"]
  node_preparing_port["Preparation Port"]
  node_orders_port["Orders Port<br/>[Orders.java]"]
  node_payments_port["Payments Port<br/>[Payments.java]"]
end

subgraph group_domain["Order And Payment Domain"]
  node_order_domain["Order Lifecycle<br/>[Order.java]"]
  node_line_items["Line Items<br/>[LineItem.java]"]
  node_payment_domain["Payment And Receipt<br/>[Payment.java]"]
  node_credit_card["Credit Card<br/>[CreditCard.java]"]
  node_receipt["Receipt<br/>[Receipt.java]"]
end

subgraph group_infrastructure["Persistence Adapters"]
  node_orders_adapter["Orders Persistence Adapter"]
  node_payments_adapter["Payments Persistence Adapter"]
  node_order_store[("Order Repository")]
  node_payment_store[("Payment Repository")]
  node_order_entity["Order Entity<br/>[OrderEntity.java]"]
  node_payment_entity["Payment Entity<br/>[PaymentEntity.java]"]
end

subgraph group_preparation["Coffee Preparation"]
  node_coffee_machine["Coffee Machine<br/>[CoffeeMachine.java]"]
end

node_customer(("Customer"))

node_customer -->|"submits order"| node_orders_api
node_customer -->|"pays order"| node_payments_api
node_orders_api -->|"invokes"| node_ordering_port
node_orders_api -->|"maps requests"| node_order_payloads
node_payments_api -->|"invokes payment"| node_ordering_port
node_payments_api -->|"maps requests"| node_payment_payloads
node_receipts_api -->|"requests receipt"| node_ordering_port
node_receipts_api -->|"returns response"| node_receipt_payload
node_coffee_shop -->|"reads and saves"| node_orders_port
node_coffee_shop -->|"reads and saves"| node_payments_port
node_coffee_shop -->|"creates and updates"| node_order_domain
node_coffee_shop -->|"creates payment"| node_payment_domain
node_coffee_shop -->|"builds receipt"| node_receipt
node_order_domain -->|"prices items"| node_line_items
node_payments_api -->|"constructs"| node_credit_card
node_coffee_shop -.->|"dispatches preparation"| node_preparing_port
node_preparing_port -.->|"uses machine"| node_coffee_machine
node_orders_port -.->|"implemented by"| node_orders_adapter
node_payments_port -.->|"implemented by"| node_payments_adapter
node_orders_adapter -.->|"persists through"| node_order_store
node_payments_adapter -.->|"persists through"| node_payment_store
node_payment_store -.->|"stores"| node_payment_entity

click node_orders_api "https://github.com/arhohuttunen/hexagonal-architecture-spring-boot/blob/main/coffeeshop-infrastructure/src/main/java/com/arhohuttunen/coffeeshop/adapter/in/rest/OrderController.java"
click node_payments_api "https://github.com/arhohuttunen/hexagonal-architecture-spring-boot/blob/main/coffeeshop-infrastructure/src/main/java/com/arhohuttunen/coffeeshop/adapter/in/rest/PaymentController.java"
click node_receipts_api "https://github.com/arhohuttunen/hexagonal-architecture-spring-boot/blob/main/coffeeshop-infrastructure/src/main/java/com/arhohuttunen/coffeeshop/adapter/in/rest/ReceiptController.java"
click node_order_payloads "https://github.com/arhohuttunen/hexagonal-architecture-spring-boot/tree/main/coffeeshop-infrastructure/src/main/java/com/arhohuttunen/coffeeshop/adapter/in/rest/resource"
click node_payment_payloads "https://github.com/arhohuttunen/hexagonal-architecture-spring-boot/tree/main/coffeeshop-infrastructure/src/main/java/com/arhohuttunen/coffeeshop/adapter/in/rest/resource"
click node_receipt_payload "https://github.com/arhohuttunen/hexagonal-architecture-spring-boot/blob/main/coffeeshop-infrastructure/src/main/java/com/arhohuttunen/coffeeshop/adapter/in/rest/resource/ReceiptResponse.java"
click node_ordering_port "https://github.com/arhohuttunen/hexagonal-architecture-spring-boot/blob/main/coffeeshop-application/src/main/java/com/arhohuttunen/coffeeshop/application/in/OrderingCoffee.java"
click node_coffee_shop "https://github.com/arhohuttunen/hexagonal-architecture-spring-boot/blob/main/coffeeshop-application/src/main/java/com/arhohuttunen/coffeeshop/application/CoffeeShop.java"
click node_preparing_port "https://github.com/arhohuttunen/hexagonal-architecture-spring-boot/blob/main/coffeeshop-application/src/main/java/com/arhohuttunen/coffeeshop/application/in/PreparingCoffee.java"
click node_coffee_machine "https://github.com/arhohuttunen/hexagonal-architecture-spring-boot/blob/main/coffeeshop-application/src/main/java/com/arhohuttunen/coffeeshop/application/CoffeeMachine.java"
click node_order_domain "https://github.com/arhohuttunen/hexagonal-architecture-spring-boot/blob/main/coffeeshop-application/src/main/java/com/arhohuttunen/coffeeshop/application/order/Order.java"
click node_line_items "https://github.com/arhohuttunen/hexagonal-architecture-spring-boot/blob/main/coffeeshop-application/src/main/java/com/arhohuttunen/coffeeshop/application/order/LineItem.java"
click node_payment_domain "https://github.com/arhohuttunen/hexagonal-architecture-spring-boot/blob/main/coffeeshop-application/src/main/java/com/arhohuttunen/coffeeshop/application/payment/Payment.java"
click node_credit_card "https://github.com/arhohuttunen/hexagonal-architecture-spring-boot/blob/main/coffeeshop-application/src/main/java/com/arhohuttunen/coffeeshop/application/payment/CreditCard.java"
click node_receipt "https://github.com/arhohuttunen/hexagonal-architecture-spring-boot/blob/main/coffeeshop-application/src/main/java/com/arhohuttunen/coffeeshop/application/payment/Receipt.java"
click node_orders_port "https://github.com/arhohuttunen/hexagonal-architecture-spring-boot/blob/main/coffeeshop-application/src/main/java/com/arhohuttunen/coffeeshop/application/out/Orders.java"
click node_payments_port "https://github.com/arhohuttunen/hexagonal-architecture-spring-boot/blob/main/coffeeshop-application/src/main/java/com/arhohuttunen/coffeeshop/application/out/Payments.java"
click node_orders_adapter "https://github.com/arhohuttunen/hexagonal-architecture-spring-boot/blob/main/coffeeshop-infrastructure/src/main/java/com/arhohuttunen/coffeeshop/adapter/out/persistence/OrdersJpaAdapter.java"
click node_payments_adapter "https://github.com/arhohuttunen/hexagonal-architecture-spring-boot/blob/main/coffeeshop-infrastructure/src/main/java/com/arhohuttunen/coffeeshop/adapter/out/persistence/PaymentsJpaAdapter.java"
click node_order_store "https://github.com/arhohuttunen/hexagonal-architecture-spring-boot/blob/main/coffeeshop-infrastructure/src/main/java/com/arhohuttunen/coffeeshop/adapter/out/persistence/OrderJpaRepository.java"
click node_payment_store "https://github.com/arhohuttunen/hexagonal-architecture-spring-boot/blob/main/coffeeshop-infrastructure/src/main/java/com/arhohuttunen/coffeeshop/adapter/out/persistence/PaymentJpaRepository.java"
click node_order_entity "https://github.com/arhohuttunen/hexagonal-architecture-spring-boot/blob/main/coffeeshop-infrastructure/src/main/java/com/arhohuttunen/coffeeshop/adapter/out/persistence/entity/OrderEntity.java"
click node_payment_entity "https://github.com/arhohuttunen/hexagonal-architecture-spring-boot/blob/main/coffeeshop-infrastructure/src/main/java/com/arhohuttunen/coffeeshop/adapter/out/persistence/entity/PaymentEntity.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_orders_api,node_payments_api,node_receipts_api,node_order_payloads,node_payment_payloads,node_receipt_payload toneBlue
class node_ordering_port,node_coffee_shop,node_preparing_port,node_orders_port,node_payments_port toneAmber
class node_order_domain,node_line_items,node_payment_domain,node_credit_card,node_receipt toneMint
class node_orders_adapter,node_payments_adapter,node_order_store,node_payment_store,node_order_entity,node_payment_entity toneRose
class node_coffee_machine,node_customer toneIndigo
```

## Components

### REST API

- [Order Controller](https://github.com/arhohuttunen/hexagonal-architecture-spring-boot/blob/main/coffeeshop-infrastructure/src/main/java/com/arhohuttunen/coffeeshop/adapter/in/rest/OrderController.java): `coffeeshop-infrastructure/src/main/java/com/arhohuttunen/coffeeshop/adapter/in/rest/OrderController.java`
- [Payment Controller](https://github.com/arhohuttunen/hexagonal-architecture-spring-boot/blob/main/coffeeshop-infrastructure/src/main/java/com/arhohuttunen/coffeeshop/adapter/in/rest/PaymentController.java): `coffeeshop-infrastructure/src/main/java/com/arhohuttunen/coffeeshop/adapter/in/rest/PaymentController.java`
- [Receipt Controller](https://github.com/arhohuttunen/hexagonal-architecture-spring-boot/blob/main/coffeeshop-infrastructure/src/main/java/com/arhohuttunen/coffeeshop/adapter/in/rest/ReceiptController.java): `coffeeshop-infrastructure/src/main/java/com/arhohuttunen/coffeeshop/adapter/in/rest/ReceiptController.java`
- [Order Resources](https://github.com/arhohuttunen/hexagonal-architecture-spring-boot/tree/main/coffeeshop-infrastructure/src/main/java/com/arhohuttunen/coffeeshop/adapter/in/rest/resource): `coffeeshop-infrastructure/src/main/java/com/arhohuttunen/coffeeshop/adapter/in/rest/resource`
- [Payment Resources](https://github.com/arhohuttunen/hexagonal-architecture-spring-boot/tree/main/coffeeshop-infrastructure/src/main/java/com/arhohuttunen/coffeeshop/adapter/in/rest/resource): `coffeeshop-infrastructure/src/main/java/com/arhohuttunen/coffeeshop/adapter/in/rest/resource`
- [Receipt Response](https://github.com/arhohuttunen/hexagonal-architecture-spring-boot/blob/main/coffeeshop-infrastructure/src/main/java/com/arhohuttunen/coffeeshop/adapter/in/rest/resource/ReceiptResponse.java): `coffeeshop-infrastructure/src/main/java/com/arhohuttunen/coffeeshop/adapter/in/rest/resource/ReceiptResponse.java`

### Application Use Cases

- [Ordering Port](https://github.com/arhohuttunen/hexagonal-architecture-spring-boot/blob/main/coffeeshop-application/src/main/java/com/arhohuttunen/coffeeshop/application/in/OrderingCoffee.java): `coffeeshop-application/src/main/java/com/arhohuttunen/coffeeshop/application/in/OrderingCoffee.java`
- [Coffee Shop Use Case](https://github.com/arhohuttunen/hexagonal-architecture-spring-boot/blob/main/coffeeshop-application/src/main/java/com/arhohuttunen/coffeeshop/application/CoffeeShop.java): `coffeeshop-application/src/main/java/com/arhohuttunen/coffeeshop/application/CoffeeShop.java`
- [Preparation Port](https://github.com/arhohuttunen/hexagonal-architecture-spring-boot/blob/main/coffeeshop-application/src/main/java/com/arhohuttunen/coffeeshop/application/in/PreparingCoffee.java): `coffeeshop-application/src/main/java/com/arhohuttunen/coffeeshop/application/in/PreparingCoffee.java`
- [Orders Port](https://github.com/arhohuttunen/hexagonal-architecture-spring-boot/blob/main/coffeeshop-application/src/main/java/com/arhohuttunen/coffeeshop/application/out/Orders.java): `coffeeshop-application/src/main/java/com/arhohuttunen/coffeeshop/application/out/Orders.java`
- [Payments Port](https://github.com/arhohuttunen/hexagonal-architecture-spring-boot/blob/main/coffeeshop-application/src/main/java/com/arhohuttunen/coffeeshop/application/out/Payments.java): `coffeeshop-application/src/main/java/com/arhohuttunen/coffeeshop/application/out/Payments.java`

### Order And Payment Domain

- [Order Lifecycle](https://github.com/arhohuttunen/hexagonal-architecture-spring-boot/blob/main/coffeeshop-application/src/main/java/com/arhohuttunen/coffeeshop/application/order/Order.java): `coffeeshop-application/src/main/java/com/arhohuttunen/coffeeshop/application/order/Order.java`
- [Line Items](https://github.com/arhohuttunen/hexagonal-architecture-spring-boot/blob/main/coffeeshop-application/src/main/java/com/arhohuttunen/coffeeshop/application/order/LineItem.java): `coffeeshop-application/src/main/java/com/arhohuttunen/coffeeshop/application/order/LineItem.java`
- [Payment And Receipt](https://github.com/arhohuttunen/hexagonal-architecture-spring-boot/blob/main/coffeeshop-application/src/main/java/com/arhohuttunen/coffeeshop/application/payment/Payment.java): `coffeeshop-application/src/main/java/com/arhohuttunen/coffeeshop/application/payment/Payment.java`
- [Credit Card](https://github.com/arhohuttunen/hexagonal-architecture-spring-boot/blob/main/coffeeshop-application/src/main/java/com/arhohuttunen/coffeeshop/application/payment/CreditCard.java): `coffeeshop-application/src/main/java/com/arhohuttunen/coffeeshop/application/payment/CreditCard.java`
- [Receipt](https://github.com/arhohuttunen/hexagonal-architecture-spring-boot/blob/main/coffeeshop-application/src/main/java/com/arhohuttunen/coffeeshop/application/payment/Receipt.java): `coffeeshop-application/src/main/java/com/arhohuttunen/coffeeshop/application/payment/Receipt.java`

### Persistence Adapters

- [Orders Persistence Adapter](https://github.com/arhohuttunen/hexagonal-architecture-spring-boot/blob/main/coffeeshop-infrastructure/src/main/java/com/arhohuttunen/coffeeshop/adapter/out/persistence/OrdersJpaAdapter.java): `coffeeshop-infrastructure/src/main/java/com/arhohuttunen/coffeeshop/adapter/out/persistence/OrdersJpaAdapter.java`
- [Payments Persistence Adapter](https://github.com/arhohuttunen/hexagonal-architecture-spring-boot/blob/main/coffeeshop-infrastructure/src/main/java/com/arhohuttunen/coffeeshop/adapter/out/persistence/PaymentsJpaAdapter.java): `coffeeshop-infrastructure/src/main/java/com/arhohuttunen/coffeeshop/adapter/out/persistence/PaymentsJpaAdapter.java`
- [Order Repository](https://github.com/arhohuttunen/hexagonal-architecture-spring-boot/blob/main/coffeeshop-infrastructure/src/main/java/com/arhohuttunen/coffeeshop/adapter/out/persistence/OrderJpaRepository.java): `coffeeshop-infrastructure/src/main/java/com/arhohuttunen/coffeeshop/adapter/out/persistence/OrderJpaRepository.java`
- [Payment Repository](https://github.com/arhohuttunen/hexagonal-architecture-spring-boot/blob/main/coffeeshop-infrastructure/src/main/java/com/arhohuttunen/coffeeshop/adapter/out/persistence/PaymentJpaRepository.java): `coffeeshop-infrastructure/src/main/java/com/arhohuttunen/coffeeshop/adapter/out/persistence/PaymentJpaRepository.java`
- [Order Entity](https://github.com/arhohuttunen/hexagonal-architecture-spring-boot/blob/main/coffeeshop-infrastructure/src/main/java/com/arhohuttunen/coffeeshop/adapter/out/persistence/entity/OrderEntity.java): `coffeeshop-infrastructure/src/main/java/com/arhohuttunen/coffeeshop/adapter/out/persistence/entity/OrderEntity.java`
- [Payment Entity](https://github.com/arhohuttunen/hexagonal-architecture-spring-boot/blob/main/coffeeshop-infrastructure/src/main/java/com/arhohuttunen/coffeeshop/adapter/out/persistence/entity/PaymentEntity.java): `coffeeshop-infrastructure/src/main/java/com/arhohuttunen/coffeeshop/adapter/out/persistence/entity/PaymentEntity.java`

### Coffee Preparation

- [Coffee Machine](https://github.com/arhohuttunen/hexagonal-architecture-spring-boot/blob/main/coffeeshop-application/src/main/java/com/arhohuttunen/coffeeshop/application/CoffeeMachine.java): `coffeeshop-application/src/main/java/com/arhohuttunen/coffeeshop/application/CoffeeMachine.java`

### Other components

- **Customer**

## Connections

- Customer → Order Controller: submits order (evidence: `coffeeshop-infrastructure/src/main/java/com/arhohuttunen/coffeeshop/adapter/in/rest/OrderController.java`)
- Customer → Payment Controller: pays order (evidence: `coffeeshop-infrastructure/src/main/java/com/arhohuttunen/coffeeshop/adapter/in/rest/PaymentController.java`)
- Order Controller → Ordering Port: invokes (evidence: `coffeeshop-infrastructure/src/main/java/com/arhohuttunen/coffeeshop/adapter/in/rest/OrderController.java`)
- Order Controller → Order Resources: maps requests (evidence: `coffeeshop-infrastructure/src/main/java/com/arhohuttunen/coffeeshop/adapter/in/rest/OrderController.java`)
- Payment Controller → Ordering Port: invokes payment (evidence: `coffeeshop-infrastructure/src/main/java/com/arhohuttunen/coffeeshop/adapter/in/rest/PaymentController.java`)
- Payment Controller → Payment Resources: maps requests (evidence: `coffeeshop-infrastructure/src/main/java/com/arhohuttunen/coffeeshop/adapter/in/rest/PaymentController.java`)
- Receipt Controller → Ordering Port: requests receipt (evidence: `coffeeshop-infrastructure/src/main/java/com/arhohuttunen/coffeeshop/adapter/in/rest/ReceiptController.java`)
- Receipt Controller → Receipt Response: returns response (evidence: `coffeeshop-infrastructure/src/main/java/com/arhohuttunen/coffeeshop/adapter/in/rest/ReceiptController.java`)
- Coffee Shop Use Case → Orders Port: reads and saves (evidence: `coffeeshop-application/src/main/java/com/arhohuttunen/coffeeshop/application/CoffeeShop.java`)
- Coffee Shop Use Case → Payments Port: reads and saves (evidence: `coffeeshop-application/src/main/java/com/arhohuttunen/coffeeshop/application/CoffeeShop.java`)
- Coffee Shop Use Case → Order Lifecycle: creates and updates (evidence: `coffeeshop-application/src/main/java/com/arhohuttunen/coffeeshop/application/CoffeeShop.java`)
- Coffee Shop Use Case → Payment And Receipt: creates payment (evidence: `coffeeshop-application/src/main/java/com/arhohuttunen/coffeeshop/application/CoffeeShop.java`)
- Coffee Shop Use Case → Receipt: builds receipt (evidence: `coffeeshop-application/src/main/java/com/arhohuttunen/coffeeshop/application/CoffeeShop.java`)
- Order Lifecycle → Line Items: prices items (evidence: `coffeeshop-application/src/main/java/com/arhohuttunen/coffeeshop/application/order/Order.java`)
- Payment Controller → Credit Card: constructs (evidence: `coffeeshop-infrastructure/src/main/java/com/arhohuttunen/coffeeshop/adapter/in/rest/PaymentController.java`)
- Coffee Shop Use Case → Preparation Port: dispatches preparation
- Preparation Port → Coffee Machine: uses machine (evidence: `coffeeshop-application/src/main/java/com/arhohuttunen/coffeeshop/application/CoffeeMachine.java`)
- Orders Port → Orders Persistence Adapter: implemented by
- Payments Port → Payments Persistence Adapter: implemented by
- Orders Persistence Adapter → Order Repository: persists through
- Payments Persistence Adapter → Payment Repository: persists through
- Payment Repository → Payment Entity: stores (evidence: `coffeeshop-infrastructure/src/main/java/com/arhohuttunen/coffeeshop/adapter/out/persistence/PaymentJpaRepository.java`)
