This question evaluates system-design and API/interface skills for rule engines, focusing on data modeling, extensibility, maintainability, and rule/result schema design in the Software Engineering Fundamentals domain.
You are building a corporate employee expense card product. Admins define policies (“rules”) to prevent misuse and to flag policy violations.
You need to design a rules evaluation component that takes:
and returns a result that clearly marks:
trip_id
) violate which rules
All keys and values in the input expense objects are strings.
Assume money is in USD.
X
dollars. (
merchant_type == "restaurant"
)
category == "airfare"
)
category == "entertainment"
)
Y
dollars.
Z
dollars.
R
dollars.
Each expense is a dictionary like:
expense_id
: "001"
trip_id
: "001"
amount
: "23.312" (string)
purpose
: "client hosting"
merchant_type
: "restaurant"
merchant_name
: "Outback Roadhouse"
Design the function:
evaluate_rules(rules: List[...], expenses: List[Dict[str, str]]) -> ???
You do not need to write code; focus on interface and design.