Skip to main content

Data Model

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

Schema Overview

The Switchyard database contains tables organized into focused domains:

Layered Product Architecture

Switchyard uses a layered product architecture that separates scraped data from the curated sellable catalog:
  1. Scraped Products Layer - Raw product data from retailer scrapers (unique by UPC)
  2. Sellable Products Layer - Curated catalog of products we sell (1:1 with scraped products)
  3. Inventory Layer - Physical stock in the RFC warehouse
  4. Order & Fulfillment Layer - Customer orders, bags, totes, and robot delivery

Complete Schema Architecture

Product Domain

scraped_products

The raw product catalog from scrapers. Unique by UPC/barcode.

sellable_products

The curated catalog of products we sell. 1:1 relationship with scraped_products.

retailer_mappings

Links scraped products to specific retailers and stores. Contains aisle/location data for sweeps.

Pricing Model

Switchyard tracks three types of prices:

Inventory Domain

inventory_items

Tracks physical inventory in the RFC warehouse. Supports FEFO/FIFO picking.
FEFO/FIFO Picking: Items are picked with expiring soonest first (FEFO), with oldest received as fallback for non-perishables (FIFO).

inventory_locations

Physical location within the RFC warehouse.

inventory_groups

Hierarchical warehouse organization: Zone → Aisle → Bay → Shelf → Slot

Partner Brand Domain

partner_brands

External brand partners who consign inventory.

partner_manifests

Shipments from partner brands to RFC.

partner_manifest_items

Line items on a manifest with expected and received quantities.

partner_reorder_requests

Admin-initiated requests for partner inventory.

consignment_sales

Records sales of consigned inventory for payout calculation.

shopify_sync

Per-product Shopify sync configuration.

Staff Domain

staff

Warehouse staff with role-based access control.
Roles determine what features staff can access:
  • superadmin: Full system access with all permissions
  • admin/manager: Full dashboard and scanner access
  • marketing: Partners, products (view), orders/customers (view)
  • warehouse: Scanner app only

Order & Fulfillment Domain

orders

Customer orders from app or admin dashboard.

order_items

Line items referencing sellable_products.

totes, bags, bag_items

Physical containers for robot delivery:
  • Order → has many Totes
  • Tote → has many Bags (one robot per tote)
  • Bag → has many Bag Items (temperature-separated)
  • Bag Item → fulfills an Order Item

Operations Domain

routes

Groups multiple sweeps together for a single driver trip.

sweeps

Shopping trips to retailers. Supports order sweeps and inventory sweeps.

sweep_economics_settings

Configuration for sweep profitability calculations.

pick_lists

RFC picking assignments assigned to staff (pickers).

Write Separation

To protect product data integrity, scrapers and admin have different write permissions:
Once a product exists, scrapers only update retailer-specific tables (pricing, availability), never core product attributes.