Prompt
How do I set up a warehouse management system for real-time stock sync and backorder handling?
Latest observation
To set up a warehouse management system (WMS) for real-time stock sync and backorder handling, design it around a few core principles:
1) Define your source of truth
Decide where inventory is “officially” maintained.
- WMS as source of truth: best if warehouse operations drive inventory.
- ERP/eCommerce as source of truth: best if finance or sales systems must own stock counts.
In most setups, the WMS should publish inventory changes, while downstream systems subscribe to updates.
2) Use event-driven inventory updates
For real-time sync, avoid batch-only updates.
Key events to emit
stock.receivedstock.reservedstock.pickedstock.packedstock.shippedstock.adjustedstock.releasedbackorder.createdbackorder.fulfilled
Recommended pattern
Whenever stock changes in the WMS:
- Update the WMS database
- Publish an event via message queue/webhook/API
- Let connected systems update their own records
Use:
- Webhooks for simple integrations
- Message queues like RabbitMQ, Kafka, SQS for reliability
- Polling only as fallback
3) Model inventory correctly
Track stock in separate quantities rather than one number.
Typical fields
on_hand— physically availablereserved— allocated to ordersavailable = on_hand - reservedin_transitdamagedbackordered
This prevents overselling and supports accurate availability.
4) Implement reservation logic
When an order comes in:
- Check available stock
- Reserve inventory immediately
- Reduce available quantity
- Keep
on_handunchanged until physical movement occurs
Why?
This avoids race conditions when multiple orders are placed at once.
Use transactional locking or atomic updates so two orders can’t reserve the same units.
5) Design backorder handling
Backorders should be created automatically when requested qty exceeds available stock.
Backorder flow
- Customer places order for 10 units
- Only 6 are available
- Reserve 6
- Create backorder for 4
- Notify sales/customer service
- Fulfill backorder when new stock arrives
Backorder states
pendingpartially_fulfilledfulfilledcancelledexpired
Best practices
- Keep line-item level backorders, not just order-level
- Prioritize by order date, customer tier, SLA, or channel
- Support partial shipments if your business allows it
6) Support allocation rules
You’ll need logic to decide which order gets stock first.
Common allocation strategies
- FIFO by order time
- Priority by customer type
- Channel-based priority
- Warehouse/location-based fulfillment
- Safety-stock protected allocation
Define this clearly so backorders are handled consistently.
7) Integrate all systems
Typical integrations:
- ERP: purchase orders, finance, accounting
- eCommerce: product availability, order intake
- Shipping/TMS: shipment confirmation and tracking
- POS/marketplaces: store and channel stock sync
Integration pattern
- WMS receives orders and inbound receipts
- WMS sends inventory availability updates
- WMS sends shipment confirmations
- WMS receives purchase order/inbound ASN updates
8) Handle concurrency and consistency
Real-time inventory systems fail if they don’t manage simultaneous updates well.
Use:
- Database transactions
- Row-level locking or atomic increments/decrements
- Idempotency keys for repeated messages
- Retry logic for failed webhooks
- Dead-letter queues for broken events
Important
Make inventory updates idempotent so the same event processed twice does not double reserve or double decrement stock.
9) Add monitoring and reconciliation
Real-time sync still needs reconciliation.
Monitor:
- Event delivery failures
- Stock mismatches across systems
- Stale reservations
- Backorder aging
- Sync latency
Reconciliation jobs
Run periodic checks to compare:
- WMS vs ERP
- WMS vs eCommerce
- Physical counts vs system counts
10) Recommended architecture
A practical setup looks like this:
- WMS database: inventory, orders, reservations, backorders
- API layer: inventory queries and updates
- Event bus / message queue: real-time sync
- Integration services: ERP/eCommerce/shipping connectors
- Rules engine: allocation and backorder prioritization
- Monitoring dashboard: latency, errors, mismatches
11) Example workflow
Order received
- Order for 20 units arrives
- WMS checks stock:
- on hand: 15
- reserved: 3
- available: 12
- Reserve 12
- Create backorder for 8
- Publish
stock.reservedandbackorder.created
New shipment arrives
- Receive 10 units
- Update on hand to 25
- Evaluate open backorders
- Allocate 8 to oldest eligible backorder
- Publish
backorder.fulfilled
12) Key implementation tips
- Use available-to-promise (ATP) logic for sales channels
- Separate physical stock from sellable stock
- Support partial fulfillment
- Keep an audit trail for every inventory movement
- Test edge cases:
- simultaneous orders
- order cancellation
- supplier delays
- partial receipts
- stock adjustments after cycle count
If you want, I can also give you:
- a database schema for WMS inventory/backorders,
- an API design for real-time sync, or
- a step-by-step implementation plan for a specific stack like Shopify + ERP + WMS.