This question evaluates a candidate's competency in system design for backend rule engines, covering data aggregation and grouping strategies, rules evaluation and explainability, API/schema design, and performance considerations.
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.
Add support for aggregate rules including (but not limited to):
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:
Provide:
Login required