Building a pluggable risk engine with design patterns
This hard coding problem tests whether you can compose a configurable pipeline using Chain of Responsibility, Strategy, and Builder patterns — exactly the kind of architecture real trading firms use to keep risk checks maintainable and extensible. The challenge is not the math; it's structuring the code so new checks can be added without touching existing logic, and ensuring the audit trail is complete even when early checks fail.
Strong solutions carefully separate concerns: each check is a self-contained class with a single responsibility, the engine orchestrates them without knowing their internals, and the builder wires everything together fluently. Key details include handling the three verdict types correctly, tracking which check failed first, and always running the full pipeline regardless of intermediate rejections. Interviewers often probe whether you understand why running all checks matters (compliance, debugging, risk visibility) and how you'd extend the design to add custom checks or conditional branching.
- Chain of Responsibility for sequential decision-making
- Strategy pattern for swappable check implementations
- Builder for fluent, composable configuration
- Decision aggregation logic across multiple verdicts
- Audit trail and observability