Sourcing Architecture
Switchyard uses a multi-channel sourcing model that combines warehouse inventory, retail sweeps, and partner brand consignment to fulfill customer orders.Sourcing Channels
RFC Inventory
Overview
The RFC (Rapid Fulfillment Center) is our warehouse where we pre-stock high-velocity and perishable items for immediate fulfillment.Inventory Structure
Picking Strategy
FEFO/FIFO (First Expiring First Out / First In First Out):- Items with earliest expiration date picked first
- For non-perishables, oldest received date picked first
- Reserved quantities tracked to prevent over-allocation
Key Tables
Retail Sweeps
Overview
Sweeps are shopping trips to partner retailers (HEB, Target, Walmart, Central Market, Whole Foods, Costco, Trader Joe’s) to source items not stocked in the RFC.Sweep Economics
The system optimizes sweeps based on profitability:Sweep Optimization
The Sweep Optimizer consolidates under-threshold sweeps:- Identifies sweeps below breakeven threshold
- Finds alternative sweeps at same location with capacity
- Moves items to maximize efficiency
- Cancels empty sweeps
Sweep Flow
Key Tables
Partner Brand Consignment
Overview
Partner brands ship their own products to our RFC for consignment sale. We handle fulfillment and take a commission on sales.Partner Lifecycle
Commission Model
Commission can be overridden at the product level via
sellable_products.commission_rate.
Manifest Flow
Partner manifests use TYPE 27 taxonomy IDs for QR code scanning:- Admin creates reorder request with items and quantities
- Partner has 7 days to accept/reject
- On acceptance, manifest auto-created with QR code
- Partner ships to RFC with tracking info
- Staff scans manifest QR at receiving
- Items scanned into consignment inventory
Consignment Sales Tracking
When consignment inventory is sold:record_consignment_sale()function triggered- Captures commission rate at time of sale
- Records
commission_amountandnet_to_partner - Assigns to
payout_period(YYYY-MM format) - Partner views via portal, admin settles monthly
Shopify Integration
Partners can sync products from their Shopify store:Key Tables
Partner-Specific Fields
Onscraped_products:
partner_brand_id- Links product to partner
sellable_products:
is_partner_brand- Flag for partner productscommission_rate- Product-level commission override
inventory_items:
partner_brand_id- Tracks consignment ownershipis_consignment- Flags consignment inventorymanifest_item_id- Links to receiving manifest
Allocation Engine
Decision Flow
When an order arrives, the allocation engine analyzes each line item:Sourcing Priority
- RFC Inventory - Check available stock (FEFO/FIFO)
- Best Retailer - Compare prices across retailers
- Bulk vs Individual - Consider bulk SKU breakdowns
- Route Optimization - Prefer existing routes when possible
Key Functions
Database Views
Prebuilt views for common queries:Background Jobs
Scraper Scheduling
Retailer scrapers run onpg_cron schedules:
- Updates
retailer_pricingwith current costs - Updates
retailer_mappingswith availability - Wakes scraper workers via
pg_netHTTP calls
Shopify Sync
Daily sync at 6am CST viapg_cron:
- Triggers
trigger_shopify_sync()function - Calls internal API endpoint
- Updates products based on sync configuration
Reorder Request Expiry
Requests expire after 7 days:expire_old_reorder_requests()function- Marks status as
expired - Partner notified of expiry