arch-atlas

Backend Cart Model

models/cart.dart + cart_item.dart

domain

Overview

Mirrors the Medusa Cart entity returned by /store/carts/{id}: id, region, currency, line items, totals (total/subtotal/itemTotal/shipping/discount/tax), email, shipping & billing addresses.

User Flow

  1. Cart.fromJson maps the Medusa payload into a typed Cart.
  2. CartItem.fromJson maps a single line-item including thumbnail + variant info.
  3. CheckoutScreen consumes the Cart to render line items, totals and the address forms.

Cases & Edge Cases

  • currencyCode defaults to 'eur' when missing — Medusa always sends it, but the fallback protects against legacy fixtures.
  • shippingAddress / billingAddress are nullable until the user fills them in; CheckoutScreen treats null as 'collect address first'.
  • discountTotal and taxTotal are computed server-side; local recomputation drifts because of region-specific tax rules.

Code References

  • lib/src/features/shared/cart/models/cart.dart:4 // Cart
  • lib/src/features/shared/cart/models/cart_item.dart // CartItem
  • lib/src/features/shared/checkout/models/address.dart // Address

API Calls

Empty — fill this in later. Open the manifest and add content here.

Notes

The backend cart is the source of truth for prices — never trust the local cart's totalPrice when displaying anything monetary post-checkout-start.