Order Flow
This document describes the complete lifecycle of an order in the Goods/Switchyard system, from customer placement through robot delivery.Overview
Orders in Goods can be fulfilled from two sources:- RFC (Warehouse) - Items stocked in our fulfillment center, available for immediate picking
- Retailers - Items sourced from partner retailers (HEB, Target, Walmart, Central Market, Whole Foods, Costco, Trader Joes)
Order Fulfillment Flow
Bags, Totes, and Order Assembly
Relationships:
- Order → has many Totes (one order may require multiple totes)
- Tote → has many Bags (bags go inside totes)
- Bag → has many Bag Items (items packed into a bag)
- Bag Item → links to Order Item (fulfills an order item)
- Tote → paired with Robot for delivery (1:1)
Bag Types
Bags are temperature-separated:- ambient - Room temperature items
- chilled - Refrigerated items
- frozen - Frozen items
Order Statuses
Staff Roles
Staff members can have both picker and driver roles, but cannot perform both simultaneously. Each pick_list is assigned to a staff member with the picker role. Each sweep is assigned to a staff member with the driver role.
Detailed Flow
1. Order Placement
Customer places an order through the Goods mobile app or admin dashboard. Orders reference:- location_id - Store location for pricing and tax
- customer_id - Customer placing the order
- source - ‘app’ or ‘admin’
2. Source Analysis (Allocation Engine)
When an order arrives, the allocation engine analyzes each line item: Decision Factors:- RFC inventory availability (using FEFO/FIFO)
- Retailer pricing (we track costs at each retailer)
- Bulk vs individual SKU pricing
- Route optimization
- Check inventory_items for available stock (FEFO/FIFO order)
- If sufficient stock → allocate to pick_list (fulfillment_source = ‘inventory’)
- If insufficient/none → allocate to sweep (fulfillment_source = ‘sweep’)
- For sweeps, select best retailer based on price (including bulk SKU options)
3. RFC-Only Orders (Inventory Path)
Orders containing only RFC-stocked items:- Order items allocated to pick_list
- Pick_list assigned to staff (picker)
- Picker uses Zebra scanner to locate items (FEFO/FIFO order)
- Picker scans items into bags (temperature-separated)
- Bags assigned to totes
- Totes staged for robot delivery
4. Sweep Operations
Orders requiring retailer items: Routes and Sweeps:- Routes group multiple sweeps for a driver trip
- Each sweep is for one retailer store
- Sweep type: ‘order’ (for customer orders) or ‘inventory’ (for stock replenishment)
- Aggregates items from sweep_items
- Includes aisle locations from retailer_mappings
- Driver receives manifest on their device
- Driver shops the manifest
- Records actual_price paid
- If item is out of stock, can be pushed to another sweep or substituted
5. Intake Processing
When drivers return from sweeps:- Items scanned at intake station
- Scanned items create bag_items linked to:
- sweep_item_id (for tracking)
- order_item_id (for fulfillment)
- Bags assigned to totes per order
6. Order Picking (RFC Items)
Pickers use Zebra scanners with the picking app:- Picker assigned to pick_list
- App guides picker to inventory items (FEFO/FIFO order)
- pick_list_item.inventory_item_id tracks which specific item
- Picker scans into bag, creates bag_item
- pick_list_item.bag_item_id links to the created bag_item
7. Staging
Completed orders are staged in totes:- Bags from both pick path and sweep path combined
- Each tote has a tote_code (QR)
- Totes staged at inventory_locations
- One robot assigned per tote (1:1)
8. Robot Delivery
- Robot scans tote QR (tote_code)
- Robot delivers tote to customer location
- Customer picks up order
- Order marked as delivered