Skip to content

Entity: Cart

Represents a visitor's shopping cart, identified by a client-generated UUID session ID. No authentication required.

Fields

FieldTypeNullableDefaultDescription
idserialnoautoPrimary key
session_idvarchar(36)noClient-generated UUID identifying the browser session
statusenum(open, closed)noopenCart status — closed after checkout
closed_attimestamp with time zoneyesnullMoment the cart was checked out

Standard columns (created_at, updated_at, deleted_at) are inherited per ADR-007 and should not be listed here.

Relations

RelationTypeTarget entityFKOn delete
itemsone-to-manyCartItemcart_item.cart_idcascade

Business rules

  • Each session_id can have at most one cart with status open at a time.
  • A new cart is created automatically when the first item is added for a given session_id.
  • Checkout transitions the cart status from open to closed and sets closed_at to the current timestamp.

Notes

  • The session_id is a UUID generated and persisted by the client (e.g. in localStorage). The API never generates it.
  • Closed carts are kept for history; they are never deleted.