Skip to main content

Class Diagram

Released at v0.1.4, applied to the k3s cluster

Derived from model/model.yaml. The customer-payments service is built on develop (IQVO/customer-payments at 054b3de, checked 2026-12-02), released at v0.1.4 and applied to the k3s cluster: the api and the A2A agent are deployed, the MCP server is registered in warehouse-infra and switched off. Every Err... name, REST route and CloudEvents type of this context named on this page exists in the service; where the built service differs from the model's design, the page says so (As built) or the context's Service and operations section lists it.

UML class diagrams of the internal/domain/** packages as the model designs them, plus the hexagonal ports and adapters. Type names come from the model's code identifiers (paymentauthorization.PaymentAuthorization, paymentauthorization.Allocation, refund.Refund) and value objects. Fields are unexported in Go and shown with -; methods are shown with +.

As built (IQVO/customer-payments develop 054b3de): the domain packages are internal/domain/paymentauthorization, internal/domain/refund. Exported types per package: paymentauthorization: Outcome, AllocationAmount, PaymentAuthorized, PaymentCaptured, PaymentReleased, PaymentAuthorizationExpired, PaymentDeclined, PaymentReauthorized, ID, State, AllocState, Allocation, AllocationInput, Draft, PaymentAuthorization, Snapshot; refund: RefundIssued, RefundFailed, ID, State, Reason, Request, Limits, Refund, Snapshot. Application packages: internal/application/idempotency, internal/application/outbox, internal/application/pagination, internal/application/parked, internal/application/ports, internal/application/provider, internal/application/usecases, internal/application/views; adapters: internal/adapters/inbound/a2a, internal/adapters/inbound/http, internal/adapters/inbound/kafka, internal/adapters/inbound/mcp, internal/adapters/inbound/requestlog, internal/adapters/outbound/clock, internal/adapters/outbound/ids, internal/adapters/outbound/kafka, internal/adapters/outbound/memory, internal/adapters/outbound/outbox, internal/adapters/outbound/paymentprovider, internal/adapters/outbound/postgres, internal/adapters/outbound/repocontract, internal/adapters/outbound/telemetry. Where a type name below differs (the UML keeps the design names), the Ubiquitous Language page carries the built identifier.

1. The PaymentAuthorization aggregate and its allocations​

Derived from: model.yaml → contexts[customer-payments].aggregates[PaymentAuthorization] (description, states, transitions, value_objects, commands, invariants, notes).

Omitted: the Err... variables (ErrDuplicateAuthorization, ErrAllocationMismatch, ErrOverCapture, ErrCaptureAfterExpiry, ErrUnknownGroup; listed on the Aggregate Design Canvas) and the tracking numbers the model says CaptureOnShipment stores against the group, which have no field in the model's value objects (hotspot H6). ErrDuplicateAuthorization is enforced by a unique index on checkoutSessionId in the repository, not by a method of the aggregate; it reaches a caller (409 duplicate-authorization) only on the concurrent-insert race, because a sequential second authorize is answered with the existing live authorization (200). The PSP token is an argument of the provider port; no field of the aggregate holds card data.

2. The Refund aggregate​

Derived from: model.yaml → contexts[customer-payments].aggregates[Refund] (description, states, transitions, value_objects, commands, invariants).

Omitted: ErrOverRefund, enforced against the order's captured total, which spans the authorization's allocations and the order's earlier refunds; the model does not say which aggregate or domain service holds that sum (hotspot H12).

3. Read model, events and policies​

Derived from: model.yaml → contexts[customer-payments].read_models, .publishes, .policies, .ul.

Omitted: the CloudEvents envelope (built in the Kafka adapter); the RefundFailed, PaymentAuthorized, PaymentDeclined and PaymentAuthorizationExpired links, which come from commands rather than policies; and the two policies that end in a command without an event (BindOrderOnCheckoutCompleted, ReauthorizeBeforeExpiry, VoidUnboundAuthorizations, hotspot H1). The fact shape inside ParkedFulfillmentFacts is the consumed event's fields.

4. Hexagonal ports and adapters​

Derived from: model.yaml → contexts[customer-payments].aggregates, .inbound, .sync_calls, .read_models, .policies; conventions.integration_rules (outbox, inbox, Idempotency-Key); the fleet's Go hexagonal layout. sync_calls holds exactly one row, so the only outbound client is the paymentprovider adapter behind the PaymentProvider port.

The Anti-Corruption Layer. The PaymentProvider port is the five verbs of the model: Authorize, Capture, Void, Refund, Reauthorize. It speaks the domain's language (a PSP token, an Allocation, an amount in minor units, a key deterministic per (operation, authorizationId, groupNo)) and returns domain results (an approval with a ProviderRef and expiresAt, a decline reason, a failure code). Everything the provider names differently stays in the adapter; the payment-provider simulator is its stand-in, and a real provider replaces only this package. The port never receives a card number.

Omitted: the composition root (cmd/customer-payments), metrics and tracing. The scheduler is an inbound adapter: time triggers ReauthorizePayment and VoidAuthorization. The read routes (GetAuthorization, ListAuthorizations, ListRefunds) read the repositories through their ports without a use case.

As built (054b3de), the four reads (GetAuthorization, ListAuthorizations, GetRefund, ListRefunds) are use cases in internal/application/usecases, and two more inbound adapters, which the model does not name, serve them and nothing else: mcp (cmd/mcp, the complete MCP surface of service ADR 0007) with four L1 tools (get_payment_authorization, list_payment_authorizations, get_refund, list_refunds), and a2a (cmd/a2a, service ADR 0005) with two L1 skills (get_payment_status, get_refund_status). Neither holds a write use case, a unit of work, the outbox or the payment provider, so neither can authorize, void, capture, release or refund, and neither exposes a PSP token. Both are separate deployables: cmd/mcp on :8090 (route /api/mcp/customer-payments through the Agent Router, switched off in warehouse-infra), cmd/a2a on :8093 (route /api/a2a/customer-payments, deployed). There is no auth on REST, MCP or A2A; the in-cluster boundary is the access control. See Service and operations.