SR-013 — Shopping Cart Management: System Requirements
By Engineering Team•October 3, 2026•5 min read
| Metadata | Details |
|---|---|
| System Name | shop-service — Shopping Cart Management |
| Document ID | SR-2026-CART-001 |
| Author | Engineering Team |
| Status | Approved |
Traces back to BRD-012 — Shopping Cart Management.
Functional Requirements
Cart Persistence
- FR-01 (Single Persisted Cart Document):
shop-serviceMUST persist a customer’s cart as one Mongocartsdocument per(tenant_id, user_id), written by the add-to-cart call and read back by the cart’s own load path, so cart contents survive independently of the current app session or device. - FR-02 (Add Increments an Existing Line): adding a SKU already present in the cart MUST increment that line’s quantity rather than creating a duplicate line or returning an error.
- FR-03 (Stale-Line Tolerance on Load): a cart line whose SKU no longer resolves via
inventory-service(deleted or otherwise stale) MUST be silently skipped when the cart is loaded, rather than failing the entire cart load.
Cart Editing
- FR-04 (Absolute Quantity Update With Live Stock Re-Validation): the quantity-update call MUST set a line to the exact quantity supplied (not a delta), MUST reject a quantity below 1, and MUST reject a quantity above the SKU’s currently available stock, re-checked live against
inventory-serviceat edit time — never against a previously cached stock figure. - FR-05 (Idempotent Removal): removing a line MUST succeed whether or not that SKU is still present in the cart — a removal of an already-removed line is not an error condition.
- FR-06 (Optimistic Update With Revert on Failure): a quantity change, removal, or wishlist toggle MUST be reflected in the displayed cart immediately, before the server confirms it, and MUST be reverted to its prior state with a visible error if the underlying call fails — the customer-visible cart state MUST NOT silently diverge from what the server actually persisted.
- FR-07 (Edits Go Through Cart-Specific Endpoints Only): quantity and removal edits MUST be made through the cart’s own update/remove capability — never by re-deriving a new cart state through a fresh add-to-cart call.
Save for Later
- FR-08 (Wishlist Toggle Without Leaving the Cart): a cart line MUST expose a save/wishlist toggle that calls the existing SKU-level wishlist capability directly, without navigating the customer away from the cart screen to complete the action.
Discovery Continuity
- FR-09 (Recommendation Sections Always Rendered): the cart screen’s configured recommendation/browsing sections MUST render below the cart’s line items regardless of whether the cart currently has any items, so an empty cart is never a blank screen.
- FR-10 (Cart Section Always First When Non-Empty): when a customer’s cart has contents, the cart’s own line-item section MUST appear first on the screen, ahead of any tenant-configured recommendation-section ordering — this placement MUST be enforced independently of the tenant’s configured section order, not as a configurable position within it.
Pricing Consistency (owned by BRD-011/SR-012 — referenced, not restated)
- FR-11 (Cart Reuses the Shared Pricing/Stock Resolution): a cart line’s displayed price, discount, and savings figures MUST be produced by the same resolution path used elsewhere in the shopping journey, per SR-012’s FR-01 and FR-06 — the cart MUST NOT maintain an independent pricing calculation of its own.
Non-Functional Requirements
Multi-Tenancy & Ownership
- NFR-01 (Auth-Sourced Identity Only): every cart read or write MUST be scoped by
(tenant_id, user_id)sourced from the authenticated request’sAuthClaims, never from the request body, per the platform’s layered architecture standard.
Reliability & Performance
- NFR-02 (Batched Hydration, Not Per-Item Calls): resolving a cart’s line items against current variant and product data MUST batch every line’s lookups into one call per dependency (
inventory-service,product-catalog), not one call per cart line, so cart-load cost does not scale linearly with the number of items in the cart. - NFR-03 (Server-Side Stock Enforcement Is Authoritative): the upper bound on a cart quantity edit MUST be enforced server-side against live inventory data at the time of the edit; a client-side input ceiling, if present, MUST NOT be treated as a substitute for that server-side check.
Composition & Reuse
- NFR-04 (DTO-Based Entry Points): every cart service-layer method MUST take a single input DTO rather than positional parameters, per the platform’s coding standards.
Related Documents
- BRD-012 — Shopping Cart Management
- BRD-011 — Reusable Product-to-Order Journey With Trustworthy Totals
- SR-012 — Reusable Checkout Orchestration: System Requirements — shared pricing/stock resolution this cart reuses (FR-11)
- Microservices: shop-service, inventory-service, product-catalog
- Flutter walkthrough: Cart