Sequence Diagrams
Derived from network/model/model.yaml. This context's service is built; the model carries its as-built contracts, and identifiers (Err... names, routes, CloudEvents types) are the names the service uses.
One UML sequence diagram per command use case on Use Cases. Participant names are the proposed packages and ports from the Class Diagram:
httpandkafkaare the inbound adapters.- The use case is in
internal/application/usecases. Postgresstands for the repository, the outbox, the inbox and the idempotency store. They share one transaction throughUnitOfWork.Relay / Kafkais the outbox relay. It reads committedoutbox_eventsrows and publishes them toretailnetwork.customer-ordering.events.
Every save is conditional on the loaded version (optimistic concurrency).
Full CloudEvents types are on Domain Events.
1. PlaceOrder (REST POST /checkout)
Derived from: model.yaml → contexts[customer-ordering].aggregates[CustomerOrder]
(PlaceOrder, invariants), .sync_calls, .policies[CheckoutPromising],
.publishes[CustomerOrderPlaced]; conventions.integration_rules.
Omitted: ErrGroupSpansNodes (422) and a delivery-promise timeout (503),
both handled like the 409 branch. Promises made before a failing group are
not released by this context; delivery-promise releases them at
holdExpiresAt. There is no version conflict on an insert. A second
insert with the same orderId cannot happen, because the id is minted here.
2. CancelOrder (REST POST /orders/orderId/cancellations)
Derived from: model.yaml → contexts[customer-ordering].aggregates[CustomerOrder]
(CancelOrder, ErrCancelAfterLock, ErrStatusRegression),
.policies[CancelIsARequest], .publishes[CustomerOrderCancelled].
Omitted: the relay marking the row published (as in diagram 1). The request
does not cancel anything by itself: order-sourcing answers with
FulfillmentCancelled (the group becomes CANCELLED) or
FulfillmentCancelRefused (the group returns to LOCKED). A lock
order-sourcing made but this context has not consumed yet is not visible
here (race, see Use Cases).
3. CancelUnkeepableGroup by policy CancelOnUnfulfillable (Kafka PromiseUnkeepable)
Derived from: model.yaml → contexts[customer-ordering].policies[CancelOnUnfulfillable],
.consumes (PromiseUnkeepable), .publishes[CustomerOrderCancelled].
Omitted: the version-conflict retry (as in diagram 2). FulfillmentUnsourceable
does not reach this use case: the consumer only records its reason on the
tracking view.
4. RegisterShopper (REST POST /shoppers)
Derived from: model.yaml → contexts[customer-ordering].aggregates[Shopper].
Omitted: nothing else. The model gives Shopper no events.
5. MarkInFulfillment (Kafka FulfillmentLocked)
Derived from: model.yaml → contexts[customer-ordering].aggregates[CustomerOrder]
(MarkInFulfillment, ErrStatusRegression), .consumes
(FulfillmentLocked), .read_models.
Omitted: the tracking projector, which here runs in the same transaction. It can also run as its own consumer.
6. MarkGroupShipped (Kafka FulfillmentShipped)
Derived from: model.yaml → contexts[customer-ordering].aggregates[CustomerOrder]
(MarkGroupShipped, transitions), .policies[ShipmentWinsOverUnlockedAndCancelRequested],
.consumes (FulfillmentShipped).
Omitted: the not-found branch (as in diagram 5) and the tracking projection.
7. MarkGroupDelivered (Kafka PackageDelivered)
Derived from: model.yaml → contexts[customer-ordering].aggregates[CustomerOrder]
(MarkGroupDelivered, transitions), .consumes (PackageDelivered).
Omitted: the not-found branch and the tracking projection. The order
status is re-derived from the group states (PARTIALLY_DELIVERED while another
group is open), so a delivery on a PARTIALLY_SHIPPED order changes it.
8. UpdateGroupPromise (Kafka PromiseRevised)
Derived from: model.yaml → contexts[customer-ordering].aggregates[CustomerOrder]
(UpdateGroupPromise), .consumes (PromiseRevised);
contexts[delivery-promise].publishes[PromiseRevised].data.
Omitted: telling the shopper about the new window, which belongs to the
future customer-notification context.