All work

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.

Domain
Expense & invoice approvals
Architecture
Event-driven pipeline
Decision model
Rules first, AI advisory
Stack
C#, .NET, Dapr, PostgreSQL

fig. 03 — rules first, ai second

request expense · invoice policy.check deterministic ai.assess advisory only rules pass · confident auto-approve human.review policy violation event stream → audit logpostgresql submitted → evaluated → assessed → decided
Illustrative diagram — not a product screenshot.

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.

  • 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.

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.

01

Probabilistic models, deterministic domain

Model outputs vary between runs; policy outcomes must not.

02

Explaining decisions

Every approval or escalation needs a reason a reviewer or auditor can follow.

03

Independent failures

Steps can fail on their own; the pipeline must resume without losing decisions.

04

When to involve a human

Too many escalations waste reviewers' time; too few create risk.

  1. SubmitAn expense or invoice enters the system and is persisted with its full context.
  2. Validate policyDeterministic rules check the request. A violation routes straight to human review — the AI is never asked to override a rule.
  3. AssessAn AI step adds an advisory assessment and its reasoning, stored alongside the request.
  4. DecideRequests that pass policy and receive a confident assessment can be approved automatically; everything else goes to a reviewer.
  5. AuditEach step is recorded as an event, so any decision can be traced from start to finish.
Backend
  • C#
  • .NET
Messaging
  • Dapr
  • Event-driven architecture
Data
  • PostgreSQL
AI
  • LLM-assisted assessment
  • Human-in-the-loop review

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.