PracHub
QuestionsPremiumLearningGuidesCheatsheetNEWCoaches
|Home/System Design/Rippling

Design a scalable expense rules engine

Last updated: Mar 29, 2026

Quick Overview

This question evaluates system-design and data-modeling competency for building a scalable, multi-tenant rules engine (category: System Design) that supports per-entity and aggregate (trip-level) evaluations, backward-compatible APIs, explainability/auditability, parsing/validation of string-typed inputs, and operational concerns like determinism, idempotency, and resilience. It is commonly asked to assess trade-off reasoning around extensibility, evaluation semantics (priority, combinators, short-circuiting), aggregation and caching strategies, and API/data-model stability, with a level of abstraction that is practical application focused while requiring conceptual architectural trade-offs and concrete design details.

  • hard
  • Rippling
  • System Design
  • Software Engineer

Design a scalable expense rules engine

Company: Rippling

Role: Software Engineer

Category: System Design

Difficulty: hard

Interview Round: Technical Screen

Design a rules engine to evaluate corporate credit-card expenses and flag items for manager review. Initial requirements: - Enforce base rules: ( 1) no restaurant expense over $75, ( 2) no airfare expenses, ( 3) no entertainment expenses, ( 4) no expense over $250. - Inputs: expenses provided as a list of dictionary objects with string keys and values. - Define types for rules (your choice) and propose the function evaluateRules(rules: list<Rule>, expenses: list<Expense>) -> ReturnType, where the return will be used by an expenses API serving many companies. Design goals: - Support 100+ rules selected per manager/team; allow adding new rules and rule creation via an API without breaking clients. - Specify evaluation semantics: priority/ordering, combinators (AND/OR/NOT), short-circuiting vs exhaustive evaluation, and conflict resolution. - Provide explainability/audit: per-violation reason, rule metadata, timestamps, and who/what policy triggered the violation. - Address multi-tenant isolation, authorization, observability, idempotency, deterministic ordering, and resilience to partial failures. - Define core data models (Expense, Trip, Rule, Policy, RuleResult, EvaluationSummary) and how string-typed inputs are parsed/validated (amounts, categories, vendor types). Extension (aggregate rules): - Add group-by rules such as: (a) a trip’s total expenses must not exceed $2000, and (b) total meal expenses per trip must not exceed $200. In the provided sample, trip "002" violates both. - Extend the engine to evaluate both per-entity (expense) and aggregate (trip) rules in one pass; describe aggregation strategy, caching, and incremental updates. - Propose a backward-compatible ReturnType that surfaces both expense-level and trip-level violations: entity type (expense/trip), identifiers (expense_id/trip_id), violated rule codes, severity, human-readable messages, machine-readable fields, and pagination. Product questions to clarify: - How are policies scoped (company/team/user) and how do overrides/precedence work? - Currency/FX handling, locales, tax/tip treatment for meal caps, per-diem vs per-transaction limits. - Category taxonomy (expense_type, vendor_type), who classifies, and how to handle unknown/mislabeled categories. - Time windows (per trip/day/month), receipt requirements, exception workflows and approvals, SLAs/notifications. - Versioning and rollout (A/B, canary), API rate limits, and return-type compatibility strategy over time.

Quick Answer: This question evaluates system-design and data-modeling competency for building a scalable, multi-tenant rules engine (category: System Design) that supports per-entity and aggregate (trip-level) evaluations, backward-compatible APIs, explainability/auditability, parsing/validation of string-typed inputs, and operational concerns like determinism, idempotency, and resilience. It is commonly asked to assess trade-off reasoning around extensibility, evaluation semantics (priority, combinators, short-circuiting), aggregation and caching strategies, and API/data-model stability, with a level of abstraction that is practical application focused while requiring conceptual architectural trade-offs and concrete design details.

Related Interview Questions

  • Design a Scalable News Feed - Rippling (medium)
  • Design Scalable Expense Violation Processing - Rippling (hard)
  • Scale a rules engine for high traffic - Rippling (medium)
  • Design a news aggregator like Google News - Rippling (medium)
  • Design several large-scale systems - Rippling (hard)
Rippling logo
Rippling
Sep 6, 2025, 12:00 AM
Software Engineer
Technical Screen
System Design
87
0

Design a Rules Engine for Corporate Credit-Card Expense Review

Context

You are designing a rules engine that evaluates corporate credit-card expenses and flags items for manager review. The engine will be used by an expenses API serving many companies (multi-tenant). Expenses are provided as a list of dictionary objects with string keys and string values.

Assume each expense has identifiers and basic fields like amount, currency, expense_type, vendor_type, merchant, transaction_date, and optionally trip_id.

Initial Base Rules (must be supported)

  1. No restaurant expense over $75.
  2. No airfare expenses.
  3. No entertainment expenses.
  4. No expense over $250.

Inputs

  • expenses: list<dict<string, string>> (string-typed fields that must be parsed/validated).
  • rules: list <Rule> (you define the rule types and semantics).

Function to Propose

  • evaluateRules(rules: list <Rule> , expenses: list <Expense> ) -> ReturnType
  • The ReturnType must be stable/backward compatible for clients across many companies.

Design Goals

  • Support 100+ rules selected per manager/team; allow adding new rules and rule creation via an API without breaking clients.
  • Specify evaluation semantics:
    • Priority/ordering of rules
    • Combinators (AND/OR/NOT)
    • Short-circuiting vs exhaustive evaluation
    • Conflict resolution across rules
  • Provide explainability/audit:
    • Per-violation reason, rule metadata, timestamps, and who/what policy triggered the violation
  • Address multi-tenant isolation, authorization, observability, idempotency, deterministic ordering, and resilience to partial failures
  • Define core data models and parsing/validation strategy:
    • Expense, Trip, Rule, Policy, RuleResult, EvaluationSummary
    • How to parse/validate amounts, categories, vendor types from string-typed inputs

Extension: Aggregate (Group-By) Rules

Support trip-level rules such as:

  • (a) A trip’s total expenses must not exceed $2000
  • (b) Total meal expenses per trip must not exceed $200

In the sample dataset, assume trip "002" violates both.

Requirements:

  • Extend the engine to evaluate both per-entity (expense) and aggregate (trip) rules in one pass.
  • Describe aggregation strategy, caching, and incremental updates.
  • Propose a backward-compatible ReturnType that surfaces both expense-level and trip-level violations, including:
    • entity type (expense/trip), identifiers (expense_id/trip_id)
    • violated rule codes, severity, human-readable messages
    • machine-readable fields (e.g., observed_value, threshold, currency)
    • pagination (cursor-based)

Product Questions to Clarify

  • Policy scoping (company/team/user) and overrides/precedence
  • Currency/FX handling, locales, tax/tip treatment for meal caps, per-diem vs per-transaction limits
  • Category taxonomy (expense_type, vendor_type), who classifies, handling unknown/mislabeled categories
  • Time windows (per trip/day/month), receipt requirements, exception workflows and approvals, SLAs/notifications
  • Versioning and rollout (A/B, canary), API rate limits, and return-type compatibility strategy over time

Solution

Show

Comments (0)

Sign in to leave a comment

Loading comments...

Browse More Questions

More System Design•More Rippling•More Software Engineer•Rippling Software Engineer•Rippling System Design•Software Engineer System Design
PracHub

Master your tech interviews with 7,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.