Storefront has been decoupled into micro-frontends with a dedicated commerce app and shared shell.

Read the architecture guide →

ADR-003: Replace the basket item collection on update

Basket updates replace the complete item collection, with validation enforcing non-empty baskets and positive quantities.

October 21, 2026AcceptedData

1. Context & Problem

When customers edit their BasketEntityv1.0.0BasketCustomer-scoped, mutable pre-order collection of requested books and quantities managed prior to checkout.Ownercommerce-fulfillment-teamOpen docs on the storefront, they expect the saved cart to match the exact selection shown on their screen. If updates only merged individual item changes, removing an item would be implicit and easy to miss, potentially leaving stale items behind when a customer submits an updated view of their cart.

2. Business Value

  • Predictable cart state: Ensures what the customer sees on screen matches what is stored, reducing “ghost item” bugs.
  • Simpler validation: Every update is checked as a complete set, guaranteeing that carts always contain valid books and positive quantities.
  • Cleaner removal semantics: Removing an item is unambiguous—it is simply omitted from the submitted selection rather than tracked through special zero-quantity flags.

3. How It Works

Every basket update replaces the entire item list in the customer’s BasketEntityv1.0.0BasketCustomer-scoped, mutable pre-order collection of requested books and quantities managed prior to checkout.Ownercommerce-fulfillment-teamOpen docs with the full collection submitted by the storefront. When a customer adds a BookEntityv1.0.0BookCanonical sellable title in the product catalog, encapsulating descriptive metadata, pricing, stock availability, taxono...Ownercatalog-experience-teamOpen docs, changes a quantity, or removes an item, the storefront sends the complete desired list rather than a partial edit.

Before saving, the system checks that the submitted basket is not empty, that every item references a valid book, and that every quantity is greater than zero. Removing an item is expressed by leaving it out of the submitted list, not by setting its quantity to zero. Creating a new basket also requires at least one valid item, and attempting to update a basket that does not exist or submitting invalid details is rejected.

4. Trade-offs & Lessons Learned

  • Full list required on every edit: Storefront clients must always send the complete item collection rather than lightweight single-item patches.
  • Last-write-wins behavior: Because this design does not include version checks for simultaneous edits, a customer editing an outdated view—or a delayed retry of an older update—can overwrite a newer cart change.
  • Reconciliation responsibility: Clients need to refresh the basket state when reconciling concurrent changes across multiple tabs or devices; adding conflict detection later would require an explicit contract change.

5. Technical Reference

  • Command: Update basketCommandv1.0.0Update basketReplaces a basket's item collection with the supplied items.Ownercommerce-fulfillment-teamSchemaDiagramOpen docs
  • HTTP contract: PUT /api/v1/baskets accepts the full desired item collection (no per-item patch operation is provided).
    • Returns 204 No Content when replacement succeeds.
    • Returns 400 on invalid input (missing BookEntityv1.0.0BookCanonical sellable title in the product catalog, encapsulating descriptive metadata, pricing, stock availability, taxono...Ownercatalog-experience-teamOpen docs identifiers, non-positive quantities, or an empty collection on creation or update).
    • Returns 404 when updating a missing BasketEntityv1.0.0BasketCustomer-scoped, mutable pre-order collection of requested books and quantities managed prior to checkout.Ownercommerce-fulfillment-teamOpen docs.
  • Concurrency note: Optimistic concurrency / version checks are not part of this decision and would require an explicit contract update.