Design a distributed system for managing dry-cleaning orders, with offline terminals and disputes.
Asked at
AI answer
I would split the system into an online API, an order service, terminal clients, synchronization, payments, and a disputes subsystem. An order is stored as an aggregate containing the customer, items, services, status, price, and change history. Status changes are made through permitted transitions, for example, “accepted” → “in progress” → “ready” → “picked up.”
The terminal stores a local database and a command queue, so it can accept orders and mark them as being processed without a network connection. Each command contains a unique ID, a terminal ID, an order version, and a timestamp. When connectivity is restored, the server applies commands idempotently. Conflicts cannot be resolved by relying only on the device’s clock: the server checks the version and transition rules. Non-conflicting fields can be merged, while status or payment conflicts are sent for manual review. The user can see the synchronization status.
To prevent duplicate payments and orders, we need an idempotency key, a transactional order record, and an outbox for publishing events. Events can be delivered through a broker with retries and deduplication. All changes, including actions made by offline terminals, are written to an immutable audit log.
A dispute is represented as a separate object linked to the order: reason, reported damage or discrepancies, photos, participants, deadlines, and status. Evidence is stored with checksums and upload timestamps; the resolution and compensation are also audited. Access to personal data is restricted by role. Monitoring should show synchronization lag, conflicts, payment errors, and unresolved disputes.
Also asked at Альфа-Банк
- Which company did you work for and what projects did you handle?
- Tell us about your experience deploying and operating Kubernetes clusters.
- Tell us about your professional experience: what have you done and how have you grown professionally?
- Do you have any questions for the company or about the process?
- What programming languages are you familiar with and do you use them for scripting?
Similar questions
- Design a distributed system for processing orders in an online store, including inventory reservation, payment, delivery, and returns.
- Design a distributed system for managing equipment reservations at a university, with priorities and offline operation.
- Design a distributed system for processing book printing orders, including layout versions, payments, and logistics.
- Design a distributed system for managing parking across 100 cities, with offline terminals and accurate billing.
- Design a distributed system for managing utility service subscriptions, including payments and billing adjustments.