KatInterview

Design an Automated Order Exception & Dispute Resolution Service

System DesignModel answer
MediumModel answerSystem DesignAPI DesignData ModelingBusiness Logic

Last updated

Design and implement a microservice that handles customer order disputes, applies explicit refund business rules, and prevents duplicate processing.

Design an order dispute microservice responsible for handling customer complaints regarding missing, damaged, or delayed deliveries. The service must determine appropriate resolution actions (such as full or partial refunds) based on explicit policies and guarantee idempotent, auditable operations.

Requirements & Context

  1. Dispute Types: Handle three main exception types:
    • Complete Loss / Non-delivery: Item or entire delivery never arrived.
    • Partial Loss / Missing Items: Only a subset of items from an order are damaged or missing.
    • Delivery Delay: Order arrived late past an agreed SLA threshold.
  2. Policy Logic:
    • Define explicit, configurable refund rules (e.g., total order cost refund for complete loss, item-level refund for partial loss, fixed percentage credit or shipping cost refund for delays).
    • Ensure maximum refund limits: the cumulative refunded amount for any order can never exceed the original total charge.
  3. Idempotency & Auditing:
    • Prevent double-refunding from duplicate or repeated customer dispute submissions.
    • Maintain an immutable audit log of decisions made (inputs, applied policies, calculated amounts, and status changes).
  4. Execution Expectations:
    • Structure the API endpoint schemas (JSON).
    • Define data models for orders, disputes, and refund ledger entries.
    • Detail the operational workflow, edge cases, and transition to a production environment.

Clarifying Questions to Consider

  • How should multiple dispute reports for the same order be handled over time?
  • What data must be present in the incoming payload versus fetched from upstream services (e.g., Order Service, Delivery Tracking)?
  • Is payment gateway integration expected in this design, or just ledger/event emission?