Skip to main content

Integration

Shopping Cart integrates through exactly three channels: one synchronous REST call out (delivery-promise), Kafka events in (offer-availability, pricing, checkout) and out (analytics), and the REST and A2A reads others make of it. It never calls a sibling's restricted route, never imports another context's Go packages (it restates the contracts it needs; the strings are identical on both sides) and never touches a warehouse.* topic. The context map is on Context map; the classification of each neighbour is on Subdomain classification.

Edge summary​

NeighbourDirectionProtocolContractFailure behaviour
delivery-promise (network, Core)cart calls itREST POST /delivery-quotesthe network's Open Host Service route; the cart restates the one route and its DTOs in internal/adapters/outbound/deliverypromisetimeout, transport error, 5xx or undecodable answer: 503 delivery-promise-unavailable; 4xx: reported the same way (a contract bug); nothing is stored, retry with the same Idempotency-Key
offer-availability (network, Supporting)it publishes, cart consumesKafka retailnetwork.offer-availability.eventsCatalogItemCreated, CatalogItemDiscontinuedretry, then dead letter; a conformist consumer
pricing (Core)it publishes, cart consumesKafka retailnetwork.pricing.eventsItemPriceChanged, ItemPriceWithdrawn, DeliveryChargeScheduleChanged, TaxTableChangedretry, then dead letter; version-guarded, stale events ignored
checkout (Supporting)it publishes, cart consumesKafka retailnetwork.checkout.eventsCheckoutCompletedretry, then dead letter; an unknown or closed cart is acknowledged and logged
checkoutit calls the cartREST GET /carts/{cartId}the cart view with checkoutReadiness404 for an unknown cart
storefront-bff (Experience)it calls the cartREST under /api/shopping-cart via Kongevery route of apis/openapi.yamlRFC 9457 problems; 409/503 are retryable with the same Idempotency-Key
agentsthey call the cartA2A JSON-RPC 2.0 on cmd/a2a / and /a2a, card at /.well-known/agent-card.jsonskills get_cart, list_shopper_cartsin-band problem answers
analytics consumerscart publishesKafka retailnetwork.shopping-cart.analyticsCartLineAdded, CartDeliveryQuoted, CartAbandoned, CartCheckedOutat-least-once through the outbox; consumers dedupe on the CloudEvents id

REST and A2A are unauthenticated fleet-wide; the Agent Card declares no security scheme. Every Kafka message is CloudEvents 1.0 in structured mode (application/cloudevents+json), dispatched on the full type string (internal/adapters/kafka/cloudevents).

Outbound: delivery-promise​

  • When: only in QuoteDelivery. Every other use case works with nothing listening there.
  • Call: POST {DELIVERY_PROMISE_URL}/delivery-quotes with {"destinationPostalPrefix": "...", "lines": [{"catalogItemId", "quantity"}]}, Content-Type: application/json, and the Idempotency-Key of the cart request forwarded, so a repeat inside the offers' TTL returns the same offers. The deployment value is http://delivery-promise.warehouse-systems.svc.cluster.local:80 in the kind cluster.
  • Timeout: DELIVERY_PROMISE_TIMEOUT, default 5s; the answer is read up to 1 MiB.
  • Mapping: only offers whose state is QUOTED (or empty) are kept; groups are named by the offers' groupNo; each offer's window.earliest and window.latest become the calendar dates deliverByEarliest and deliverByLatest in the destination's local calendar using the offer's window.timeZone (IANA zone of the serving delivery station), falling back to UTC with a WARN when the zone is absent, Local or unknown (ADR 0007); expiresAt is stored in UTC; unavailable tiers keep their constraint and group; a group's line numbers are the cart lines whose item the group's offers carry. An offer's optional capacityBand (delivery-promise ADR 0023) is kept when it is AMPLE, TIGHT or SCARCE (an unknown value is dropped, it is a signal only) and consolidationEligible (ADR 0024) is kept for the tier CONSOLIDATED only. The cart's own request never asks for CONSOLIDATED: it quotes the four classic tiers, and a CONSOLIDATED offer reaches the cart through POST /carts/{cartId}/delivery-requote-acceptances (ADR 0010).
  • Failure: ports.ErrDeliveryPromiseUnavailable (transport, timeout, 5xx, undecodable) and ports.ErrQuoteRejected (4xx) both answer 503 delivery-promise-unavailable. The call runs outside any transaction, so the cart is unchanged by a failure and /readyz does not depend on delivery-promise.
  • Contract guard: internal/adapters/outbound/deliverypromise/spec_test.go checks the restated shapes against a vendored copy of delivery-promise's spec (testdata/delivery-promise.openapi.yaml).

Inbound: Kafka​

Three consumers always run in cmd/api, one per topic, each with its own stable group id from OFFER_AVAILABILITY_CONSUMER_GROUP, PRICING_CONSUMER_GROUP and CHECKOUT_CONSUMER_GROUP. The cart is a Conformist to offer-availability and Customer of pricing and checkout.

TopicTypes handled (full type in Events)Effect
retailnetwork.offer-availability.eventsCatalogItemCreated, CatalogItemDiscontinuedrm_items catalogued / discontinued
retailnetwork.pricing.eventsItemPriceChanged, ItemPriceWithdrawn, DeliveryChargeScheduleChanged, TaxTableChangeditem price, current schedule, current tax table
retailnetwork.checkout.eventsCheckoutCompletedthe cart named by cartId becomes CHECKED_OUT

Failure behaviour, identical for the three: one message at a time, offset committed only after success; transient errors retry five times with a 200 ms to 5 s backoff and then the message goes to <topic>.dlq; a payload that can never be applied is dead-lettered at once; a message that is not a CloudEvent, or whose type is not handled, is skipped. A lost broker connection is retried up to ten times and then the process exits so the orchestrator restarts it. The operational detail is on Runbook.

The cart only reads the fields it needs (catalogItemId; currency, effectivePriceMinor, version; version and tiers or bands; cartId, sessionId) and ignores unknown fields, so a producer may add fields without breaking it. The producers' own AsyncAPI files are authoritative; this service restates the shapes in apis/asyncapi.yaml.

Outbound: Kafka​

One topic, retailnetwork.shopping-cart.analytics, key = the cart id. The four events are written to outbox_events in the same transaction as the cart change and published by the always-on relay (at-least-once, acks from all replicas, the CloudEvents id minted once and persisted, so a retry republishes the same id). No sibling consumes a cart event: all four are analytics-only, so a stalled relay never blocks a shopper.

Inbound: REST​

Callers reach the service through Kong at /api/shopping-cart (the prefix is stripped) or directly on :8080. Writes require an Idempotency-Key; the first answer below 500 is stored 24 hours and replayed. Checkout reads GET /carts/{cartId} when a session opens and relies on checkoutReadiness (every group selected, no offer expired); the shopper's calls come through storefront-bff. The route list is on API reference.

POST /carts/{cartId}/delivery-requote-acceptances is the route checkout is meant to use when its own requote replaces the offers. No caller of it was found in the local checkouts of checkout and storefront-bff, so today it is served and tested but unused by a sibling.

Inbound: A2A​

cmd/a2a serves two read-only skills over the same use cases as the REST GETs. It calls no other context and contains no outbound A2A client; facts between contexts still travel only as CloudEvents on Kafka. In the kind cluster it is reached at /api/a2a/shopping-cart (the gateway rewrites the prefix to /).

Absent edges​

Stated so nobody looks for them:

Not presentWhy
Calls to pricingthe cart follows pricing's events and never reads prices synchronously
Calls to customer-ordering, customer-payments, product-content, product-discoveryreaching the order record is checkout's job; the cart consumes no content events and keeps its own purchasability view
Any warehouse.* topicthe cart is a retail-network storefront context, not part of the warehouse
A consumer of the analytics topicno context consumes cart events yet
MCPread-only only: cmd/mcp serves get_cart and list_shopper_carts (ADR 0009); no write tool
Authenticationremoved fleet-wide; none exists here
A cart-owned webhook, push or websocketnone; callers poll the REST reads