Design: Order Tracking State Machine
Design the state machine logic, API interface, and data model for order states. Out of scope: payment processing, inventory management.
Functional Requirements
FR1: Track the state of an order from placement to delivery
FR2: Support states: Created, Confirmed, Packed, Shipped, Out for Delivery, Delivered, Cancelled
FR3: Allow valid transitions only (e.g., cannot ship before packing)
FR4: Notify users on state changes
FR5: Handle concurrent updates safely
FR6: Provide API to query current order state
FR7: Support at least 10,000 orders concurrently
Non-Functional Requirements
NFR1: API response latency p99 < 100ms
NFR2: System availability 99.9%
NFR3: State transitions must be consistent and atomic
NFR4: Scalable to handle peak loads during sales events