Design a Rules Engine for Corporate Card Expenses
Context
You are building an expense policy engine for a corporate credit-card system. Managers define policies (rules) that must be evaluated against expense transactions. Each expense is represented as a dictionary/map with string keys and string values.
Task
Design and describe an implementation for:
-
A rule representation that supports at least the four sample policies below and scales to hundreds of rules.
-
A function: evaluateRules(rules: list
<rule>
, expenses: list
<expense>
) -> ?
-
Define what the function should return as an API response that downstream services and UIs can consume.
-
Explain conflict handling and precedence, auditing/explanations, performance and scalability, and how managers select and manage rules.
-
State assumptions and product clarifications you would ask before coding.
Given Policies (minimum support)
-
No restaurant expense over $75.
-
No airfare expenses.
-
No entertainment expenses.
-
No expense over $250.
The system must flag violating expenses.