# tobyspringboot/hellospring architecture

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

- Interactive diagram: https://gitdiagram.com/tobyspringboot/hellospring
- Repository: https://github.com/tobyspringboot/hellospring

## Overview

This repository contains examples for Toby’s Spring 6 course, rather than a single deployed product. Its main workflows demonstrate creating and saving orders, and preparing a payment by obtaining an exchange rate and calculating a time-limited converted amount. A separate API-template path demonstrates fetching and extracting an exchange rate. The README identifies the project as course example code; the source index and excerpts support the shown calls. Other provider and persistence variants are included, but their runtime selection is not fully established by the excerpts.

Main entry points: [`src/main/java/tobyspring/hellospring/api/ApiTemplate.java`](https://github.com/tobyspringboot/hellospring/blob/main/src/main/java/tobyspring/hellospring/api/ApiTemplate.java) (API template), [`src/main/java/tobyspring/hellospring/order/OrderServiceImpl.java`](https://github.com/tobyspringboot/hellospring/blob/main/src/main/java/tobyspring/hellospring/order/OrderServiceImpl.java) (Order service), [`src/main/java/tobyspring/hellospring/payment/ExRateProvider.java`](https://github.com/tobyspringboot/hellospring/blob/main/src/main/java/tobyspring/hellospring/payment/ExRateProvider.java) (Rate provider contract), [`src/main/java/tobyspring/hellospring/payment/PaymentService.java`](https://github.com/tobyspringboot/hellospring/blob/main/src/main/java/tobyspring/hellospring/payment/PaymentService.java) (Payment service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_order["Order management"]
  node_order_client["Order client<br/>[OrderClient.java]"]
  node_order_service["Order service"]
  node_order_model["Order model<br/>[Order.java]"]
  node_order_request["Order request<br/>[OrderReq.java]"]
  node_order_repository["Order repository"]
  node_order_contract["Repository contract"]
end

subgraph group_payment["Payment preparation"]
  node_payment_client["Payment client<br/>[Client.java]"]
  node_payment_service["Payment service"]
  node_payment_model["Payment model<br/>[Payment.java]"]
end

subgraph group_fx["Exchange rates"]
  node_rate_contract["Rate provider contract"]
  node_rest_rate["REST rate provider"]
  node_cached_rate["Cached rate provider"]
  node_simple_rate["Simple rate provider"]
  node_web_rate["Web API rate provider"]
  node_api_template["API template<br/>[ApiTemplate.java]"]
  node_api_executor["API executor<br/>[ApiExecutor.java]"]
  node_http_executor["HTTP executor"]
  node_rate_extractor["Rate extractor"]
  node_er_extractor["ER API extractor"]
  node_rate_data["Rate data<br/>[ExRateData.java]"]
end

subgraph group_infra["Wiring and persistence"]
  node_database[("SQL database")]
  node_order_config["Order configuration<br/>[OrderConfig.java]"]
  node_data_config["Data configuration<br/>[DataConfig.java]"]
  node_rate_config["Payment configuration<br/>[PaymentConfig.java]"]
end

node_order_client -->|"calls"| node_order_service
node_order_service -->|"creates"| node_order_model
node_order_service -->|"maps requests"| node_order_request
node_order_service -->|"saves via"| node_order_contract
node_order_config -->|"constructs"| node_order_service
node_order_config -->|"constructs"| node_order_repository
node_order_config -->|"imports"| node_data_config
node_order_repository -->|"persists"| node_order_model
node_order_repository -->|"writes rows"| node_database
node_payment_client -->|"calls"| node_payment_service
node_rate_config -->|"constructs"| node_payment_service
node_rate_config -->|"selects provider"| node_rest_rate
node_payment_service -->|"gets rate"| node_rate_contract
node_payment_service -->|"prepares"| node_payment_model
node_rest_rate -->|"implements"| node_rate_contract
node_cached_rate -->|"implements"| node_rate_contract
node_simple_rate -->|"implements"| node_rate_contract
node_web_rate -->|"implements"| node_rate_contract
node_web_rate -->|"uses"| node_api_template
node_api_template -->|"executes through"| node_api_executor
node_api_template -->|"extracts with"| node_rate_extractor
node_api_template -->|"defaults to"| node_http_executor
node_api_template -->|"defaults to"| node_er_extractor
node_http_executor -->|"implements"| node_api_executor
node_er_extractor -->|"implements"| node_rate_extractor
node_er_extractor -->|"parses into"| node_rate_data

click node_order_client "https://github.com/tobyspringboot/hellospring/blob/main/src/main/java/tobyspring/hellospring/OrderClient.java"
click node_order_service "https://github.com/tobyspringboot/hellospring/blob/main/src/main/java/tobyspring/hellospring/order/OrderServiceImpl.java"
click node_order_model "https://github.com/tobyspringboot/hellospring/blob/main/src/main/java/tobyspring/hellospring/order/Order.java"
click node_order_request "https://github.com/tobyspringboot/hellospring/blob/main/src/main/java/tobyspring/hellospring/order/OrderReq.java"
click node_order_repository "https://github.com/tobyspringboot/hellospring/blob/main/src/main/java/tobyspring/hellospring/data/JdbcOrderRepository.java"
click node_order_contract "https://github.com/tobyspringboot/hellospring/blob/main/src/main/java/tobyspring/hellospring/order/OrderRepository.java"
click node_order_config "https://github.com/tobyspringboot/hellospring/blob/main/src/main/java/tobyspring/hellospring/OrderConfig.java"
click node_data_config "https://github.com/tobyspringboot/hellospring/blob/main/src/main/java/tobyspring/hellospring/DataConfig.java"
click node_payment_client "https://github.com/tobyspringboot/hellospring/blob/main/src/main/java/tobyspring/hellospring/Client.java"
click node_payment_service "https://github.com/tobyspringboot/hellospring/blob/main/src/main/java/tobyspring/hellospring/payment/PaymentService.java"
click node_payment_model "https://github.com/tobyspringboot/hellospring/blob/main/src/main/java/tobyspring/hellospring/payment/Payment.java"
click node_rate_contract "https://github.com/tobyspringboot/hellospring/blob/main/src/main/java/tobyspring/hellospring/payment/ExRateProvider.java"
click node_rate_config "https://github.com/tobyspringboot/hellospring/blob/main/src/main/java/tobyspring/hellospring/PaymentConfig.java"
click node_rest_rate "https://github.com/tobyspringboot/hellospring/blob/main/src/main/java/tobyspring/hellospring/exrate/RestTemplateExRateProvider.java"
click node_cached_rate "https://github.com/tobyspringboot/hellospring/blob/main/src/main/java/tobyspring/hellospring/exrate/CachedExRateProvider.java"
click node_simple_rate "https://github.com/tobyspringboot/hellospring/blob/main/src/main/java/tobyspring/hellospring/exrate/SimpleExRateProvider.java"
click node_web_rate "https://github.com/tobyspringboot/hellospring/blob/main/src/main/java/tobyspring/hellospring/exrate/WebApiExRateProvider.java"
click node_api_template "https://github.com/tobyspringboot/hellospring/blob/main/src/main/java/tobyspring/hellospring/api/ApiTemplate.java"
click node_api_executor "https://github.com/tobyspringboot/hellospring/blob/main/src/main/java/tobyspring/hellospring/api/ApiExecutor.java"
click node_http_executor "https://github.com/tobyspringboot/hellospring/blob/main/src/main/java/tobyspring/hellospring/api/HttpClientApiExecutor.java"
click node_rate_extractor "https://github.com/tobyspringboot/hellospring/blob/main/src/main/java/tobyspring/hellospring/api/ExRateExtractor.java"
click node_er_extractor "https://github.com/tobyspringboot/hellospring/blob/main/src/main/java/tobyspring/hellospring/api/ErApiExtractor.java"
click node_rate_data "https://github.com/tobyspringboot/hellospring/blob/main/src/main/java/tobyspring/hellospring/exrate/ExRateData.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_order_client,node_order_service,node_order_model,node_order_request,node_order_repository,node_order_contract toneBlue
class node_payment_client,node_payment_service,node_payment_model toneAmber
class node_rate_contract,node_rest_rate,node_cached_rate,node_simple_rate,node_web_rate,node_api_template,node_api_executor,node_http_executor,node_rate_extractor,node_er_extractor,node_rate_data toneMint
class node_database,node_order_config,node_data_config,node_rate_config toneRose
```

## Components

### Order management

- [Order client](https://github.com/tobyspringboot/hellospring/blob/main/src/main/java/tobyspring/hellospring/OrderClient.java): `src/main/java/tobyspring/hellospring/OrderClient.java`
- [Order service](https://github.com/tobyspringboot/hellospring/blob/main/src/main/java/tobyspring/hellospring/order/OrderServiceImpl.java): `src/main/java/tobyspring/hellospring/order/OrderServiceImpl.java`
- [Order model](https://github.com/tobyspringboot/hellospring/blob/main/src/main/java/tobyspring/hellospring/order/Order.java): `src/main/java/tobyspring/hellospring/order/Order.java`
- [Order request](https://github.com/tobyspringboot/hellospring/blob/main/src/main/java/tobyspring/hellospring/order/OrderReq.java): `src/main/java/tobyspring/hellospring/order/OrderReq.java`
- [Order repository](https://github.com/tobyspringboot/hellospring/blob/main/src/main/java/tobyspring/hellospring/data/JdbcOrderRepository.java): `src/main/java/tobyspring/hellospring/data/JdbcOrderRepository.java`
- [Repository contract](https://github.com/tobyspringboot/hellospring/blob/main/src/main/java/tobyspring/hellospring/order/OrderRepository.java): `src/main/java/tobyspring/hellospring/order/OrderRepository.java`

### Payment preparation

- [Payment client](https://github.com/tobyspringboot/hellospring/blob/main/src/main/java/tobyspring/hellospring/Client.java): `src/main/java/tobyspring/hellospring/Client.java`
- [Payment service](https://github.com/tobyspringboot/hellospring/blob/main/src/main/java/tobyspring/hellospring/payment/PaymentService.java): `src/main/java/tobyspring/hellospring/payment/PaymentService.java`
- [Payment model](https://github.com/tobyspringboot/hellospring/blob/main/src/main/java/tobyspring/hellospring/payment/Payment.java): `src/main/java/tobyspring/hellospring/payment/Payment.java`

### Exchange rates

- [Rate provider contract](https://github.com/tobyspringboot/hellospring/blob/main/src/main/java/tobyspring/hellospring/payment/ExRateProvider.java): `src/main/java/tobyspring/hellospring/payment/ExRateProvider.java`
- [REST rate provider](https://github.com/tobyspringboot/hellospring/blob/main/src/main/java/tobyspring/hellospring/exrate/RestTemplateExRateProvider.java): `src/main/java/tobyspring/hellospring/exrate/RestTemplateExRateProvider.java`
- [Cached rate provider](https://github.com/tobyspringboot/hellospring/blob/main/src/main/java/tobyspring/hellospring/exrate/CachedExRateProvider.java): `src/main/java/tobyspring/hellospring/exrate/CachedExRateProvider.java`
- [Simple rate provider](https://github.com/tobyspringboot/hellospring/blob/main/src/main/java/tobyspring/hellospring/exrate/SimpleExRateProvider.java): `src/main/java/tobyspring/hellospring/exrate/SimpleExRateProvider.java`
- [Web API rate provider](https://github.com/tobyspringboot/hellospring/blob/main/src/main/java/tobyspring/hellospring/exrate/WebApiExRateProvider.java): `src/main/java/tobyspring/hellospring/exrate/WebApiExRateProvider.java`
- [API template](https://github.com/tobyspringboot/hellospring/blob/main/src/main/java/tobyspring/hellospring/api/ApiTemplate.java): `src/main/java/tobyspring/hellospring/api/ApiTemplate.java`
- [API executor](https://github.com/tobyspringboot/hellospring/blob/main/src/main/java/tobyspring/hellospring/api/ApiExecutor.java): `src/main/java/tobyspring/hellospring/api/ApiExecutor.java`
- [HTTP executor](https://github.com/tobyspringboot/hellospring/blob/main/src/main/java/tobyspring/hellospring/api/HttpClientApiExecutor.java): `src/main/java/tobyspring/hellospring/api/HttpClientApiExecutor.java`
- [Rate extractor](https://github.com/tobyspringboot/hellospring/blob/main/src/main/java/tobyspring/hellospring/api/ExRateExtractor.java): `src/main/java/tobyspring/hellospring/api/ExRateExtractor.java`
- [ER API extractor](https://github.com/tobyspringboot/hellospring/blob/main/src/main/java/tobyspring/hellospring/api/ErApiExtractor.java): `src/main/java/tobyspring/hellospring/api/ErApiExtractor.java`
- [Rate data](https://github.com/tobyspringboot/hellospring/blob/main/src/main/java/tobyspring/hellospring/exrate/ExRateData.java): `src/main/java/tobyspring/hellospring/exrate/ExRateData.java`

### Wiring and persistence

- **SQL database**
- [Order configuration](https://github.com/tobyspringboot/hellospring/blob/main/src/main/java/tobyspring/hellospring/OrderConfig.java): `src/main/java/tobyspring/hellospring/OrderConfig.java`
- [Data configuration](https://github.com/tobyspringboot/hellospring/blob/main/src/main/java/tobyspring/hellospring/DataConfig.java): `src/main/java/tobyspring/hellospring/DataConfig.java`
- [Payment configuration](https://github.com/tobyspringboot/hellospring/blob/main/src/main/java/tobyspring/hellospring/PaymentConfig.java): `src/main/java/tobyspring/hellospring/PaymentConfig.java`

## Connections

- Order client → Order service: calls (evidence: `src/main/java/tobyspring/hellospring/OrderClient.java`)
- Order service → Order model: creates (evidence: `src/main/java/tobyspring/hellospring/order/OrderServiceImpl.java`)
- Order service → Order request: maps requests (evidence: `src/main/java/tobyspring/hellospring/order/OrderServiceImpl.java`)
- Order service → Repository contract: saves via (evidence: `src/main/java/tobyspring/hellospring/order/OrderServiceImpl.java`)
- Order configuration → Order service: constructs (evidence: `src/main/java/tobyspring/hellospring/OrderConfig.java`)
- Order configuration → Order repository: constructs (evidence: `src/main/java/tobyspring/hellospring/OrderConfig.java`)
- Order configuration → Data configuration: imports (evidence: `src/main/java/tobyspring/hellospring/OrderConfig.java`)
- Order repository → Order model: persists (evidence: `src/main/java/tobyspring/hellospring/data/JdbcOrderRepository.java`)
- Order repository → SQL database: writes rows (evidence: `src/main/java/tobyspring/hellospring/data/JdbcOrderRepository.java`)
- Payment client → Payment service: calls (evidence: `src/main/java/tobyspring/hellospring/Client.java`)
- Payment configuration → Payment service: constructs (evidence: `src/main/java/tobyspring/hellospring/PaymentConfig.java`)
- Payment configuration → REST rate provider: selects provider (evidence: `src/main/java/tobyspring/hellospring/PaymentConfig.java`)
- Payment service → Rate provider contract: gets rate (evidence: `src/main/java/tobyspring/hellospring/payment/PaymentService.java`)
- Payment service → Payment model: prepares (evidence: `src/main/java/tobyspring/hellospring/payment/PaymentService.java`)
- REST rate provider → Rate provider contract: implements (evidence: `src/main/java/tobyspring/hellospring/exrate/RestTemplateExRateProvider.java`)
- Cached rate provider → Rate provider contract: implements (evidence: `src/main/java/tobyspring/hellospring/exrate/CachedExRateProvider.java`)
- Simple rate provider → Rate provider contract: implements (evidence: `src/main/java/tobyspring/hellospring/exrate/SimpleExRateProvider.java`)
- Web API rate provider → Rate provider contract: implements (evidence: `src/main/java/tobyspring/hellospring/exrate/WebApiExRateProvider.java`)
- Web API rate provider → API template: uses (evidence: `src/main/java/tobyspring/hellospring/exrate/WebApiExRateProvider.java`)
- API template → API executor: executes through (evidence: `src/main/java/tobyspring/hellospring/api/ApiTemplate.java`)
- API template → Rate extractor: extracts with (evidence: `src/main/java/tobyspring/hellospring/api/ApiTemplate.java`)
- API template → HTTP executor: defaults to (evidence: `src/main/java/tobyspring/hellospring/api/ApiTemplate.java`)
- API template → ER API extractor: defaults to (evidence: `src/main/java/tobyspring/hellospring/api/ApiTemplate.java`)
- HTTP executor → API executor: implements (evidence: `src/main/java/tobyspring/hellospring/api/HttpClientApiExecutor.java`)
- ER API extractor → Rate extractor: implements (evidence: `src/main/java/tobyspring/hellospring/api/ErApiExtractor.java`)
- ER API extractor → Rate data: parses into (evidence: `src/main/java/tobyspring/hellospring/api/ErApiExtractor.java`)
