Skip to main content

Storefront BFF

storefront-bff is the only storefront edge of the warehouse-systems fleet. The browser (storefront-web) talks to this one service under /api/storefront; the BFF turns each screen or click into calls to the six REST services behind it (product-discovery, delivery-promise, pricing, shopping-cart, checkout, customer-ordering), relays their answers, and keeps the one thing a stateless edge needs: a small state cookie. It has no database, no Kafka and no domain model. It is classified Generic (Storefront area): replaceable plumbing that must be correct and boring, not a source of competitive advantage (Subdomain classification).

:::info What runs on develop One binary, cmd/api (Go, chi): the REST adapter with problem+json errors, the closed upstream allowlist, per-route time budgets, minted Idempotency-Keys, the sf_state cookie and the body-free request log; an outbound HTTP client with trace propagation; OpenTelemetry traces, one request-duration histogram and Go runtime metrics; a Helm chart charts/storefront-bff and a Dockerfile.

Not built, by design: authentication (REST is unauthenticated fleet-wide), an MCP or A2A server, any Kafka producer or consumer (the kafka and cloudevents packages are scaffold leftovers cmd/api never wires), any persistence. :::

What the context owns​

ConceptWhere it livesRule in one line
Upstream allowlistinternal/domain/composition/allowlist.goA closed list of 25 METHOD /path templates over the six services. Anything else (ship-to, POST /promises, promise confirm and cancel, inventory feeds, policy routes) is refused before a request is built.
Time budgetscomposition/budget.go2 s for queries, 5 s for commands, 15 s for checkout confirm, applied to the whole composition; expiry is a 504 and nothing is retried.
Idempotency-Key mintingcomposition/idempotency.gosf- plus 40 hex chars, deterministic for route, subject and the page's required Idempotency-Key (one per user submit).
Shopper statecomposition/state.goThe sf_state cookie carries opaque ids: cart c, shopper s, last checkout k. State, never authentication.
Card-data guardcomposition/card.goRaw card fields and card-shaped tokens never leave the process; only a PSP payment-method token is accepted on confirm.
Composition use casesinternal/application/usecasesOne method per route: validate ids, build the allowlisted calls, join optional legs, classify failures.
Problem mappinginternal/adapters/inbound/http/problems.goRFC 9457 application/problem+json under /problems/; upstream answers pass through untouched.

What it does not own​

  • No business data. Carts, checkout sessions, orders, shoppers, prices and catalogue belong to the six upstream services; the BFF forwards bodies byte for byte and does not store or log them (saved addresses included).
  • No authentication. "Login" is a lookup of a shopper by e-mail (POST /sessions); the cookie is state, nothing trusts it for access.
  • No events. It publishes and consumes nothing; there is no AsyncAPI document (Integration).
  • No restricted network routes. It reaches only the network's Open Host Service routes that customer-ordering and delivery-promise expose to shoppers, and an architecture test fails the build otherwise.
  • No presentation logic. Turning instants into local dates is the page's job (ADR 0005).

Classification and area​

  • Generic subdomain, Storefront area. The BFF carries no domain model: the rules it enforces (allowlist, budgets, keys, cookie, card guard) are edge hygiene that any competent BFF has. ADR 0001 records it as a bounded context of the storefront domain; the aggregator's strategic design treats the experience layer as outside the six bounded contexts. Either way it has no aggregates (Aggregate design canvas).
  • No CloudEvents namespace is used because nothing is emitted (ADR 0001 reserves com.retailnetwork.storefront.storefront-bff.<entity>.<Event>).

Main capabilities​

  1. Browse: GET /products, GET /products/{id} and GET /categories, relayed from product-discovery with only the documented search filters forwarded.
  2. Delivery dates on a product page: POST /products/{id}/delivery-date-quotes quotes one unit for a postal prefix and joins each tier's delivery charge from pricing; a failing charge schedule only drops the charge.
  3. Cart: create, read, list, add a line, change a quantity, remove a line, set a destination, quote and select delivery, each mapped to the cart's custom verbs (ADR 0002).
  4. Checkout: open a session from the cookie's cart and shopper, poll it, and confirm with a PSP token under the 15 s budget.
  5. Orders: list, cancel, and read an order joined with its tracking and, when the cookie's last checkout placed it, the checkout totals.
  6. Shopper: register, "log in" by e-mail, read /me, save an address.
  7. Operate: /healthz and /readyz (static 200), JSON logs correlated with traces, and boot-time validation of every upstream URL.

Where to go next​

You want toRead
See the layers, the binary and the rules that police themArchitecture
Run it and make the first callsQuickstart
Know every settingConfiguration
Deploy and operate itRunbook, Observability, Before first release
Fix something that brokeTroubleshooting
Know what tests and CI gates existTesting
See who talks to whomIntegration
See every use case and its invariantsUse cases
Read the design in ddd-crew artifactsDDD artifacts, Ubiquitous language
Read the contractAPI overview
Read the decisionsADR index

Published at https://iqvo.github.io/storefront-bff/.

Disclaimer

This project is a domain-driven design study. It is not associated with, endorsed by or affiliated with any company, and it uses no company's code, data, logos or trademarks. All names, figures and examples are illustrative or synthetic.