Case study 03 Event-driven decisions
ApproveFlow
An event-driven approval engine for business expenses and invoices — AI where it helps, deterministic rules where it matters.
fig. 03 — rules first, ai second
01
The problem
Approving expenses and invoices by hand is slow. Approving them with an AI model alone is a risk no finance team should accept.
Most requests are routine and match a clear policy; some aren't. The system needs to move routine requests quickly, route the rest to people, and explain every decision afterwards.
02
My responsibility
- 01Decision pipelineDesigned the sequence of policy validation, AI assessment and decision routing.
- 02Event flowBuilt the event-driven processing between steps on Dapr.
- 03Policy layerImplemented deterministic validation that runs before any AI step.
- 04AuditabilityPersisted requests, assessments and decisions in PostgreSQL so every outcome can be traced.
03
The architecture
Each stage consumes an event and publishes the next. Policy validation runs first and is fully deterministic; the AI assessment can only add information; the router makes the final call based on both — and every step is recorded.
04
Engineering challenges
Probabilistic models, deterministic domain
Model outputs vary between runs; policy outcomes must not.
Explaining decisions
Every approval or escalation needs a reason a reviewer or auditor can follow.
Independent failures
Steps can fail on their own; the pipeline must resume without losing decisions.
When to involve a human
Too many escalations waste reviewers' time; too few create risk.
05
The solution
- SubmitAn expense or invoice enters the system and is persisted with its full context.
- Validate policyDeterministic rules check the request. A violation routes straight to human review — the AI is never asked to override a rule.
- AssessAn AI step adds an advisory assessment and its reasoning, stored alongside the request.
- DecideRequests that pass policy and receive a confident assessment can be approved automatically; everything else goes to a reviewer.
- AuditEach step is recorded as an event, so any decision can be traced from start to finish.
06
Technologies
07
Outcome & lessons
AI is most useful as an advisor behind deterministic guardrails — fast where it is safe, accountable everywhere.
- Put rules before models.
- Design the audit trail first; it shapes the events.
- Make human review a first-class path, not an error state.