This question evaluates proficiency in designing in-memory data structures, modeling state transitions and idempotent operations, indexing for efficient lookups by order_id and user_id, and reasoning about complexity and testability.

Implement an in-memory order stream service with operations: add(order), delete(order_id), pause(order_id), resume(order_id); follow-up: delete_all_by_user(user_id). Define the order schema and valid state transitions, ensure operations are idempotent, and support efficient lookups by order_id and by user_id. Describe chosen data structures, expected time/space complexity, and provide example tests. Discuss how you would extend it for persistence and concurrency if required.