Skip to main content

Data Model

This document describes the key entities in Switchyard and how they relate to each other.

Entity Relationship Diagram

Core Entities

Customer

Represents a user of the Goods mobile app.
FieldTypeDescription
idstringUnique identifier
emailstringEmail address
first_namestringFirst name
last_namestringLast name
phonestringPhone number
addressesAddress[]Delivery/billing addresses
Relationships:
  • Has many Orders
  • Managed via Supabase Auth

Order

A customer’s purchase request.
FieldTypeDescription
idstringUnique identifier
customer_idstringReference to Customer
statusenumOrder status (see Order Flow)
itemsLineItem[]Products ordered
created_atdatetimeWhen order was placed
fulfillment_typeenumrfc_only, sweep_only, hybrid
Statuses: pendingprocessingsweep_in_progressintakepickingstageddeliveringdelivered

LineItem

Individual product in an order.
FieldTypeDescription
idstringUnique identifier
order_idstringReference to Order
variant_idstringReference to ProductVariant
quantitynumberQuantity ordered
unit_pricenumberPrice per unit
sourceenumrfc, retailer
retailerstringWhich retailer (if sourced externally)

Product

A purchasable item in the catalog.
FieldTypeDescription
idstringUnique identifier
titlestringProduct name
descriptionstringProduct description
handlestringURL-friendly slug
categoriesCategory[]Product categories
variantsProductVariant[]Size/flavor variations
imagesImage[]Product images
metadataobjectExtended attributes
Metadata includes:
  • Retailer-specific IDs
  • Scraping source information
  • Nutritional data

ProductVariant

A specific variation of a product (size, flavor, etc.).
FieldTypeDescription
idstringUnique identifier
product_idstringReference to Product
skustringStock keeping unit
barcodestringUPC/EAN barcode
titlestringVariant name
pricesPrice[]Prices at different retailers

Price

Price information for a variant.
FieldTypeDescription
idstringUnique identifier
variant_idstringReference to ProductVariant
amountnumberPrice in cents
price_list_idstringWhich price list (retailer)
Price Lists:
  • selling - Our price to customers
  • heb - Cost at HEB
  • target - Cost at Target
  • walmart - Cost at Walmart
  • etc.

Inventory Entities

StockLocation

A place where inventory is stored.
FieldTypeDescription
idstringUnique identifier
namestringLocation name
addressobjectPhysical address
metadataobjectExtended attributes
Types:
  • RFC (our warehouse)
  • Retailer locations (for availability tracking)

InventoryItem

Tracks stock of a variant at a location.
FieldTypeDescription
idstringUnique identifier
skustringSKU reference
location_idstringReference to StockLocation
stocked_quantitynumberTotal quantity
reserved_quantitynumberReserved for orders

InventoryGroup

Hierarchical warehouse organization (custom module).
FieldTypeDescription
idstringUnique identifier
namestringGroup name
codestringLocation code (e.g., A1-2-3-1)
typeenumzone, aisle, bay, shelf, slot
parent_idstringParent group reference
stock_location_idstringReference to StockLocation
Hierarchy: Zone → Aisle → Bay → Shelf → Slot Example: A1-2-3-1 = Zone A, Aisle 1, Bay 2, Shelf 3, Slot 1

Operations Entities

Driver

Person who performs sweeps and deliveries.
FieldTypeDescription
idstringUnique identifier
first_namestringFirst name
last_namestringLast name
phonestringPhone number
emailstringEmail (optional)
license_numberstringDriver’s license
vehicle_infostringVehicle description
is_activebooleanCurrently active
customer_idstringOptional link to Customer

Sweep

Daily shopping trip to a retailer.
FieldTypeDescription
idstringUnique identifier
store_idstringReference to StockLocation (retailer)
sweep_datedateDate of sweep
scheduled_start_timedatetimeWhen sweep should begin
actual_start_timedatetimeWhen driver started
actual_end_timedatetimeWhen driver returned
driver_idstringReference to Driver
statusenumscheduled, in_progress, completed, cancelled
total_itemsnumberTotal items on manifest
Schedule:
  • One sweep per retailer per day (default)
  • Additional sweeps can be added manually

SweepItem

Item on a sweep manifest.
FieldTypeDescription
idstringUnique identifier
sweep_idstringReference to Sweep
variant_idstringReference to ProductVariant
quantitynumberQuantity to pick
picked_quantitynumberQuantity actually picked
statusenumpending, picked, substituted, unavailable
substitute_variant_idstringIf substituted, the replacement

PickList

Assignment of picking work to a warehouse picker.
FieldTypeDescription
idstringUnique identifier
order_idstringReference to Order
picker_idstringReference to Driver (who picks)
statusenumpending, in_progress, completed
started_atdatetimeWhen picking started
completed_atdatetimeWhen picking finished

PickListItem

Individual item to pick from warehouse.
FieldTypeDescription
idstringUnique identifier
pick_list_idstringReference to PickList
order_item_idstringReference to LineItem
product_idstringReference to Product
location_idstringReference to InventoryGroup (slot)
quantitynumberQuantity to pick
picked_quantitynumberQuantity picked
statusenumpending, picked, unavailable
sequencenumberOrder in pick path

User Entities

User

Admin/staff user of Switchyard.
FieldTypeDescription
idstringUnique identifier
emailstringEmail address
first_namestringFirst name
last_namestringLast name
roleenumadmin, manager, picker, driver
Roles:
  • admin - Full access
  • manager - Operations management
  • picker - Warehouse picking
  • driver - Sweep operations

Tote (Future)

Container for staged orders.
FieldTypeDescription
idstringUnique identifier
qr_codestringQR code on tote
order_idstringReference to Order
statusenumempty, staged, delivering, returned
Note: Robot-tote interface is out of Switchyard scope.