Model Return Eligibility Rules as a Chain of Responsibility
Last updated: November 29, 2026
Quick Overview
Design classes that decide whether a customer return is approved, denied, or sent to manual review, where each policy (non-returnable categories, return windows, opened software, high-value items) is its own rule that can be added or reordered without editing the others.
Amazon
November 29, 20260
0
0 solved
Design classes that decide whether a customer return is approved, denied, or sent to manual review, where each policy (non-returnable categories, return windows, opened software, high-value items) is its own rule that can be added or reordered without editing the others.
Amazon's returns policy differs by category, membership, and price, and new rules arrive constantly from legal and category teams. This low-level design round checks whether you can isolate each rule, keep the orchestrator closed for modification, and make the outcome explainable to customer service.
What the Interviewer Expects
- Defines a small Rule interface that either decides or passes to the next rule
- Keeps each policy in its own class with its own parameters
- Returns a reason string with every decision for auditability
- Explains why rule order matters and who owns it
- Shows how a new rule is added without touching existing ones
Key Topics to Cover
How to Approach This
- Apply SOLID principles. Single Responsibility makes code testable, Open/Closed makes it extensible.
- Choose data structures based on access patterns, not familiarity.
- Prefer immutable data and message passing over shared mutable state for concurrency.
- Design APIs with RESTful conventions, versioning, meaningful errors, and pagination from day one.
Possible Follow-up Questions
- How would you load rule order and thresholds from configuration instead of code?
- Some rules should collect all failures rather than stop at the first; how would you change the design?
- How would you unit test each rule and the full chain?
- How would you A/B test a new window length?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice System Design ProblemsSample Answer
Requirements
- Input: category, days since delivery, opened flag, price, Prime status.
- Output:
APPROVED,DENIED, orMANUAL_REVIEWwith a reason. - Rules change often; adding one must not require editing ot...
High-Level Design
Each Rule implements check(req) returning a Decision or None. The base handle calls check and forwards to the next rule if there is no decision, defaulting to approval at the end. then r...