Scrivio Interview library
DesignIntermediate6 min read · updated 12 November 2026

Your company needs a workflow engine for loan approvals with human tasks, timers and audit. Compare building on Spring State Machine and custom tables, using an open-source engine, or a managed service.

Building on Spring State Machine and custom tables gives full control, but we must build persistence, timers, versioning of running workflows, a task UI and audit ourselves. An open-source workflow engine brings these proven features, but we operate it and must learn its model. A managed service removes most operations work but raises cost, vendor lock-in and data residency questions. The deciding checks are how each option handles a process change while loans are still in flight, and the total cost over several years including staff time.

Why this question is asked

Loan approval is a classic long-running process: an application can wait days for a document, sit in an underwriter's queue, escalate after a timer and must leave a full audit trail for regulators. Teams often underestimate how much of a workflow engine they would have to rebuild. Interviewers ask this to see whether we can compare build, open source and managed options on the hard parts, not the easy ones. In this answer, we will recap what the process needs, look at each option, examine process versioning with in-flight instances, and estimate the total cost over several years.

1What a Loan Approval Workflow Needs

A workflow engine runs a process definition: the steps, the decisions between them and who performs each one. Our loan process has automatic steps, like a credit check call, and human tasks, like 'underwriter reviews application', which wait for a person to claim and complete them. It has timers: if no documents arrive in 5 days, send a reminder; after 14 days, cancel. And it needs an audit trail: who did what, when and with which data, kept for years.

Notice that instances live long. With 2,000 applications a day and an average duration of 10 days, about 20,000 loans are in progress at any moment. Whatever we choose must survive restarts, deployments and process changes while those 20,000 are waiting.

2Option 1: Spring State Machine and Custom Tables

Spring State Machine is a Spring project for modelling states and transitions in code. It works well for the logic of moving from state to state, and it has support for persisting a machine's state. But everything around the states is ours to build: tables for instances and their variables, a scheduler for timers that survives restarts and runs once across several instances, a task list with claiming and assignment, a UI for underwriters, an audit log, and reports on where loans are stuck.

Java
// The easy part: states and transitions
states.withStates()
.initial(LoanState.SUBMITTED)
.states(EnumSet.allOf(LoanState.class));
transitions.withExternal()
.source(LoanState.SUBMITTED).target(LoanState.IN_REVIEW).event(LoanEvent.DOCS_RECEIVED);
// Still to build ourselves: timers that survive restarts, human task lists,
// assignment and claiming, a UI, audit history, versioning of running instances

The appeal is full control and no new product to learn. The cost is that we are writing a workflow engine, and the hard parts, timers and versioning, are exactly the ones that bite in production. Check whether the Spring State Machine version you plan to use is still actively maintained, since that also affects the long-term cost.

3Option 2: An Open-Source Workflow Engine

Open-source engines that run on the JVM, typically using BPMN (a standard notation for process diagrams), provide persistence, durable timers, human tasks, history and audit tables, and often a task UI or the APIs to build one. Many embed into a Spring Boot application with a starter. Business analysts can read the process diagram, which helps when compliance asks what the process really does.

The cost is operations and learning. We run the engine and its database, upgrade it, and learn its model: transactions boundaries, retries of failed steps, how its job executor works. Licensing also needs a careful look, since some engines have changed their open-source terms in recent years.

4Option 3: A Managed Workflow Service

Cloud providers and workflow vendors offer hosted engines where we deploy definitions and the provider runs everything. Operations work drops sharply: no engine database to tune, no upgrades. But a loan workflow holds personal and financial data, so we must check where the data is stored and processed, which matters for data residency rules, and whether the service meets our regulator's audit requirements. We also take on vendor lock-in, because process definitions and history are often in a vendor-specific format, and costs that grow with the number of executions or state transitions.

Three ways to run loan approvals
ConcernState Machine + tablesOpen-source engineManaged service
Timers and human tasksbuild themincludedincluded
Audit and historybuild itincludedincluded, vendor format
Versioning in-flight loansdesign it yourselfbuilt-in versioningcheck the service
Operationsour app onlyengine and its databaseprovider
Lock-in and residencynonelowvendor and region questions
Learning curvelow at firstmediummedium
The rows we would build ourselves in option 1 are the expensive ones.

5The Hard Question: Changing a Process With Loans in Flight

Six months after launch, compliance adds a fraud check before underwriting. What happens to the 20,000 loans already running under the old definition? This is the question that separates the options.

Mature engines version process definitions: new instances start on version 2, while existing instances finish on version 1, and there are tools to migrate selected instances to the new version when needed. With a custom build, we must design this ourselves: store a version with each instance, keep old transition logic alive in code until the last old instance finishes, and write migration scripts for the rest. For a managed service, we check its documentation for exactly how definition updates affect running executions. We should ask every option to walk through this exact scenario.

Step throughA process change with 20,000 loans in flight
  1. Deploy definition version 2adds a fraud check
  2. New applications start on version 2
  3. Existing loan must get the fraud check?
    YesMigrate it to version 2 with a mapped stateNoLet it finish on version 1
  4. Retire version 1after its last instance completes

4 steps in order. Play them, or step through them one at a time.

6Estimating the Total Cost Over Several Years

We compare options over three to five years, not the first sprint. For the custom build: perhaps two engineers for six months to reach parity on timers, tasks, UI and audit, then about one engineer ongoing for maintenance and new needs. At a loaded cost of, say, 150,000 a year per engineer, that is roughly 150,000 to build and 150,000 a year after, before the cost of incidents in home-grown timers. For an open-source engine: integration effort, maybe half an engineer ongoing for operations and upgrades, plus support licences if we choose them. For a managed service: the subscription or usage fees at our volume, integration, and a planned exit cost if we ever leave.

With these numbers in one table, the discussion becomes concrete. For a regulated, long-running process with human tasks and timers, an existing engine, open source or managed, usually wins, and the choice between those two often comes down to data residency and operations capacity. We record the reasoning and assumptions in an ADR.

7Follow-up questions

When would building on Spring State Machine be the right choice?

When the process is short-lived, fully automatic and simple, for example a device that moves through a few states within seconds, with no human tasks, long timers or strict audit needs. Then a full engine is overhead, and a state machine in code is clear and cheap.

How do you keep the business logic portable if you choose an engine?

Keep the engine as orchestration only: the process definition decides what happens next, while each step calls ordinary Spring services that contain the real logic. Then moving to another engine means rewriting definitions and adapters, not business code.

What audit requirements would you check with compliance?

How long history must be kept, whether it must be immutable, what data each entry must hold (who, when, what changed), and whether regulators need to see the process definition that was in force for a given loan. That last one makes definition versioning an audit requirement, not just a technical convenience.

8Conclusion

In this answer, we saw that a custom build on Spring State Machine gives control but leaves us building persistence, timers, versioning, a task UI and audit. An open-source engine brings those features at the cost of operating it and learning its model, and a managed service removes operations work but raises cost, lock-in and data residency questions. The deciding checks are how each handles process changes with loans in flight and the multi-year cost including staff time.

What to say in the interviewAbout 90 seconds aloud

Open with

I would first spell out what the process needs: automatic steps like a credit check, human tasks for underwriters, timers such as a reminder after 5 days and cancellation after 14, and a full audit trail.

Then, if they want more

With maybe 20,000 loans in flight at any time, everything has to survive restarts and process changes.

Building on Spring State Machine with our own tables gives full control and nothing new to learn, but state transitions are the easy part; we would still build durable timers, task lists, a UI, audit history and versioning of running instances, which is basically writing a workflow engine.

An open-source BPMN engine gives those features proven, and analysts can read the diagrams, but we run it and its database and have to learn its model, and I would check its licence. A managed service removes most operations work, but loan data is sensitive, so I would check data residency and audit compliance, plus lock-in and usage costs.

The question I would put to every option is: compliance adds a fraud check, what happens to the loans already in flight? Engines version definitions; a custom build has to design that. Then I would estimate cost over three to five years including staff time. For this kind of regulated process, an existing engine usually wins.

About this answer

Last updated
12 November 2026
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the official documentation for the version you use. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "Your company needs a workflow engine for loan approvals with human tasks, timers and...": https://scrivio-interview-library.netlify.app/architecture/architecture-decisions/fa33e60cd5/