0012. Adopt the fleet's micro-frontend console architecture
Status
Accepted.
Context
warehouse-ops-agent's
ADR-0002
is the fleet-wide decision: one Module Federation micro-frontend remote per
bounded context, composed at runtime by a separate warehouse-console shell,
with the one genuinely cross-cutting screen (Order Lifecycle) backed by a thin
BFF hosted in warehouse-ops-agent rather than as a new bounded context. That
record is not this repo's to own or restate — it is owned by
warehouse-ops-agent, the fleet's cross-context correlation surface. This ADR
exists only to record this service's own side of adopting it: what
inventory-storage had to add, and why each piece is additive rather than a
change to this service's existing domain, application, or REST contract.
Three things followed directly from that fleet decision landing:
- A remote of our own. Per ADR-0002's "one remote per bounded context, in
that context's own repo" rule, this service — not
warehouse-console— owns the screen that shows its own data.web/(theinventory-mfepackage) already exists in this repo for exactly that reason. - The join-key gap ADR-0002 identified for this service specifically.
ADR-0002's Context section names
inventory-storage'sReservationas one of three aggregates that "already carry the join key in their own domain (DemandRef) ... but none exposed a GET endpoint to look up 'everything with this key'."GET /reservations?demandRef=closes that gap for this service (getReservationsByDemandRefinapis/openapi.yaml,ports.ReservationRepo.FindByDemandRefin the application layer) — it is the console's read side for "what did inventory-storage do for order X, line N," consumed both by the BFF's Order Lifecycle fan-out and directly byinventory-mfe's ownInventoryScreen. - CORS as new, permanent surface. ADR-0002's Decision section requires
each of the four services touched by the console to add
go-chi/corsglobal middleware, scoped toCORS_ALLOWED_ORIGINS(defaulthttp://localhost:5173,http://localhost:5182— the shell and this service's own remote's dev port). This service had never needed a browser client before; every prior consumer was a server-to-server caller (wes-work-planning's Kafka consumer,facility-layout's synchronous read). Seeinternal/adapters/inbound/http/server.go'sNewRouterandcorsAllowedOrigins.
Decision
We adopt ADR-0002 as-is: this service ships inventory-mfe as its Module
Federation remote, exposes GET /reservations?demandRef= as the additive
read the fleet decision required of it, and adds CORS middleware scoped to
the console's known origins — with no change to this service's existing
domain model, aggregates, or any pre-existing endpoint's contract.
Concretely, what already exists in this repo because of that adoption:
web/— theinventory-mferemote. A Vite + React Module Federation remote (vite --port 5182in dev), consuming@warehouse/ui-kitviafile:../../warehouse-ui-kitforCard,StatusPill,DataTable, anduseFetch— the same shared components every sibling remote uses, so aReservation.statusorStockUnit.statepill renders identically here and inorder-mgmt-mfe. It talks only to this service's ownSERVICE_API_BASE(INVENTORY_API_BASEinweb/src/config.ts) — no new backend surface, no call to any other service's API from the browser.InventoryScreen.tsx— this service's own operator screen, per ADR-0002's "decisions about what that screen shows belong to that context's own team/PR": two independent lookups, both scoped to what this service's REST API already exposes — SKU → usable inventory (GET /inventory/{sku}/usable) and demandRef → reservations (GET /reservations?demandRef=) — deliberately not a list-all/browse table, because no such endpoint exists here.GET /reservations?demandRef=(getReservationsByDemandRef) — returns everyReservationever raised against ademandRef, array-shaped because a demandRef can have multiple reservations across its lifetime (revoked, then retried). An unknowndemandRefreturns200with an empty array, not404, matching this endpoint's read-model semantics. Side-effect-free; no existing use case, aggregate, or endpoint was modified to add it.- CORS middleware in
NewRouter,AllowedOriginsdriven byCORS_ALLOWED_ORIGINS(comma-separated), defaulting to the shell's dev origin and this remote's own dev port,AllowCredentials: false(this service is unauthenticated by decision — ADR-0015 — and uses no cookies, so no credentialed cross-origin request is needed).Idempotency-Keyis in the allowed request headers (ADR-0018) for any future MFE write.
What we deliberately did not do, consistent with ADR-0002's own scope boundaries:
- No client-side fan-out to another service from this service's own code —
inventory-mfenever callsorder-management,wes-work-planning, orfulfillment-executiondirectly. The Order Lifecycle correlation stays inwarehouse-ops-agent's BFF, per ADR-0002's Decision.warehouse-ops-agent's BFF is the only caller ofGET /reservations?demandRef=from outside this remote. - No change to
StockUnit,Bin/Location, orReservation's domain invariants, nor to any pre-existing endpoint's request/response shape or status codes (seeREST_AUDIT.mdfor the full pre-existing contract, unchanged by this adoption). - No shared read model or database access granted to
warehouse-consoleor any sibling remote —inventory-mfeis the only code that reads this service's REST API on the browser's behalf.
Consequences
Easier
- This service's operator screen ships and evolves inside this repo. A
change to
Reservation's shape and the screen that renders it land in the same PR, same review, same ≥90% coverage bar as everything else here — exactly the ownership alignment ADR-0002 was written to preserve. - The join-key gap the fleet decision found is now closed for this service specifically, and closed the same way every other endpoint in this repo is built: port → use case → adapter → handler → OpenAPI → tests. No mock, no bypass.
- Visual consistency with the rest of the console is a compile-time
consumption choice, not a convention to remember —
@warehouse/ui-kit'sStatusPillis what renders this service's ownReservation/StockUnitstates, the same package every sibling remote imports.
Harder
- CORS is now permanent surface this service must keep current. A
forgotten
CORS_ALLOWED_ORIGINSupdate when a new remote dev port or a real deployed console origin is added is a silent browser-side "Failed to fetch," not a loud backend error — the same risk ADR-0002 named for all four touched services, now concretely true here too.TestCORS_Preflight_RejectsUnknownOriginguards the current default set, but a new origin still requires a deliberate change todefaultCORSAllowedOriginsor the env var in every deployment.TestCORS_Preflight_AllowsDefaultOriginandTestCORS_Preflight_AllowsSecondDefaultOrigincover the two defaults. GET /reservations?demandRef=is now a contract two external callers depend on (inventory-mfedirectly, andwarehouse-ops-agent's BFF transitively) rather than an internal-only read — a breaking change to its response shape now has consequences outside this repo that did not exist before this adoption.inventory-mfe'sfile:../../warehouse-ui-kitdependency means this remote's own build now requireswarehouse-ui-kitchecked out as a sibling directory and built first, the same pre-1.0 coupling ADR-0002 accepted fleet-wide and explicitly deferred past the first release.