Model Multi-Step Expense Approval Policies With Clean Classes

Last updated: November 29, 2026

Quick Overview

Design the classes for Ramp-style expense approval policies: rules decide which approval steps apply (manager, finance over a threshold, travel admin for large travel), the chain must skip self-approval and duplicates, and a request moves through a small state machine.

Ramp
Software Engineering Fundamentals
Software Engineer
Ramp
November 29, 2026
Software Engineer
Onsite
Software Engineering Fundamentals
Medium

0

0

0 solved


Design the classes for Ramp-style expense approval policies: rules decide which approval steps apply (manager, finance over a threshold, travel admin for large travel), the chain must skip self-approval and duplicates, and a request moves through a small state machine.

Ramp customers configure who approves a reimbursement or a bill based on amount, category and department, and finance teams change those rules often. This low-level design round looks for composable rules, a clear separation between policy and request state, and invariants like never letting someone approve their own expense.

What the Interviewer Expects
  • Separates the policy (configuration) from the request (runtime state)
  • Models rules as small composable objects rather than nested if statements
  • Enforces no self-approval and de-duplicates approvers
  • Rejects actions from anyone but the current approver and actions on closed requests
  • Explains how a policy change affects requests already in flight
Key Topics to Cover
Object-oriented design
Composite pattern
State machine
Invariants
Policy configuration
How to Approach This
  1. Apply SOLID principles. Single Responsibility makes code testable, Open/Closed makes it extensible.
  2. Choose data structures based on access patterns, not familiarity.
  3. Prefer immutable data and message passing over shared mutable state for concurrency.
  4. Design APIs with RESTful conventions, versioning, meaningful errors, and pagination from day one.
Possible Follow-up Questions
  • How would you support parallel steps where any one of three approvers is enough?
  • How would you persist this so a policy edit does not change in-flight requests?
  • How do you handle an approver who leaves the company mid-chain?
  • Where would delegation (out of office) fit in this model?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice System Design Problems
Sample Answer
Requirements

An expense has an amount, category, department and submitter. A policy is an ordered list of steps, each with a rule and a way to resolve the approver. The chain for an expense contains each applicabl...

High-Level Design
  • Rule is an abstract predicate with small implementations (AmountAtLeast, CategoryIn, Always) and a combinator AllOf, so admins compose conditions without new code.
  • ApprovalStep pairs a...

Submit Your Answer
Markdown supported

Related Questions