Extend rules for trip-level aggregates and outputs
Quick Overview
This interview question evaluates requirements, scale assumptions, API/data design, architecture, trade-offs, failure modes, and rollout in a realistic interview setting. A strong answer for Extend rules for trip-level aggregates and outputs states assumptions, handles edge cases, explains trade-offs, and shows how to validate the result clearly.
Extend rules for trip-level aggregates and outputs
Company: Rippling
Role: Software Engineer
Category: System Design
Difficulty: medium
Interview Round: Technical Screen
Extend the same system to support aggregate trip‑level rules. Implement handling for rules like:
(
1) A trip’s total expenses cannot exceed $2000;
(
2) Total meal expenses per trip cannot exceed $200. In the provided sample, trip "002" violates both rules. Update the design and the evaluateRules return type so the output includes per‑trip violations alongside per‑expense violations. Describe grouping/aggregation strategy, evaluation order, explainability for aggregates, performance considerations, and how these results integrate into the expenses API used by many companies.
Quick Answer: This interview question evaluates requirements, scale assumptions, API/data design, architecture, trade-offs, failure modes, and rollout in a realistic interview setting. A strong answer for Extend rules for trip-level aggregates and outputs states assumptions, handles edge cases, explains trade-offs, and shows how to validate the result clearly.
You previously built an expense policy engine that evaluates per-expense rules (e.g., "a single meal cannot exceed $50"). Extend that system to support aggregate, trip-level rules that operate over groups of expenses for the same trip.
Assume each expense has at least: expenseId, tripId, employeeId, category, amount, currency, incurredAt. Currency normalization to a policy currency (e.g., USD) is available.
Requirements
Add support for aggregate rules including (but not limited to):
A trip’s total expenses cannot exceed $2,000.
Total meal expenses per trip cannot exceed $200.
In the provided sample, trip "002" violates both rules. Update the design and the evaluateRules return type so the output includes per-trip violations alongside per-expense violations.
Describe:
Grouping/aggregation strategy (how expenses are grouped and metrics computed)
Evaluation order (per-expense vs. per-trip and how updates flow)
Explainability for aggregates (what evidence is returned and how it’s human-readable)