Task Flow Engine — a configurable rule engine
A rule engine and visual flow editor for a corporate lending platform · Java/Spring · Vue 3 + GoJS + Electron
The problem
Batch and workflow-style financial processing runs a chain of conditional checks over many records, branching and looping on the results. The conventional approach writes those rules directly into code — so every rule change means editing, testing and redeploying. The codebase swells as rules accumulate, logic scatters, and nothing is traceable. In banking, business rules are precisely the thing that changes most often.
The design: turn flow logic into data
Business checks never enter the codebase. Each step of a flow is one row in a configuration table; the engine reads that configuration and assembles an executable chain of tasks. Changing a rule becomes data maintenance rather than a code change.
TASK_FLOW (one row = one task node)
├─ TASK_TYPE CONTROL (branch/loop) │ OPERATOR (compute) │ QUERY (lookup)
├─ BLOCK_ID / SEQ the block a task belongs to, and its order within that block
├─ NEXT_BLOCK_ID the block to branch to when the condition holds
├─ NESTED_BLOCK_ID nested block — the body of a FOR loop
├─ SOURCE_FROM data source: query result │ variable pool
├─ LOGIC_TYPE … EQUAL / GREATER / LESS / ALWAYS + target field and comparison value
├─ OPERATOR_EXPRESSION expression (arithmetic, dates, financial functions)
└─ VARIABLE_NAME name under which a result is stored in the variable pool
At runtime the engine walks tasks from the starting block in sequence order: CONTROL tasks decide where the flow goes (including FOR loops and nested loops), OPERATOR tasks write results into the variable pool, and QUERY tasks fetch data for later conditions to use. Those three task types compose into a complete business-check flow — and every decision leaves a log entry behind.
The expression engine: from string to executable decision
A rule stored in a table is just a string. Turning it into safe program behaviour takes a small compilation pipeline. I rewrote this part clean-room as an open-source library: flow-expression-engine (pure Java 17, zero dependencies, 15 tests) — everything described here actually runs there.
"AMT * 0.8 > LIMIT" ─→ Shunting-yard ─→ RPN │ variable lookup ←── Predicate / SpEL ←┘
- Type-aware evaluation: more than arithmetic — date ± days, datetime hour offsets, differences between two dates, and other mixed-type combinations all have defined semantics.
- Illegal operations rejected: combinations that are meaningless by type (multiplying or dividing a date) are refused during evaluation with a readable message, rather than surfacing an opaque runtime exception. Business staff author these rules — the error has to make sense to them.
- Financial and custom functions: common financial calculations ship as built-ins, and business-specific logic can be registered as a custom function without touching the engine core.
Dynamic queries: even "what to look up" is data
Query rules are configuration too: a SOURCE_RULE table defines the target table, the
selected columns and the where clause. At runtime the query is assembled with the JPA Criteria API,
with column names mapped SNAKE_CASE → camelCase onto entities. Adding a new data source takes one
configuration row, not a new repository method.
Flow Studio: an editor for humans
Rules living in database rows are a nightmare to maintain by hand — hence the visual editor. GoJS renders the whole task flow, node properties and branches are edited directly on the canvas, and JSON import/export bridges back to the tables. It ships to the team as a desktop application packaged with Electron.
| Layer | Stack |
|---|---|
| Engine | Java · Spring Boot · rule tables · full execution log |
| Editor | Vue 3 (Composition API) · TypeScript · Vite · GoJS · PrimeVue |
| Packaging | Electron Forge (Windows release) |
| Testing | Playwright E2E · Vitest · JUnit |
What I owned
- Execution-path log analyser (Flow Studio): the price of "configuration as program" is debuggability — when something goes wrong there is no stack trace, only a long execution log. My module takes an uploaded engine log, reconstructs the path that actually ran, and presents it as a table of decision points: which task, on what condition, sent the flow where. It preselects the relevant analysis fields per business module, and aggregates result codes using the display flag so nothing is over-reported. It cut debugging from half a day of reading logs by hand down to minutes — this module is what makes a data-driven rule architecture operable at all.
- Core flow-editor fixes: restricting a task's successor candidates to its enclosing ForBlock (otherwise the editor can draw flows the engine cannot run), treating an empty block as a natural terminus to repair broken loop endpoints, and emitting explicit sequence numbers on export with array-order validation — the diagram and the engine's actual execution must stay strictly equivalent.
- Engine side: SpEL financial functions, logic-executor tests, and a refactor of variable resolution.
- Release management: Electron packaging and the release process, iterating through an issue → AI-assisted fix → human review workflow that closed several issues per week.
Trade-offs (the questions I get asked, answered up front)
- Why not an off-the-shelf rule engine (Drools / Camunda)? The requirements were: maintainable by business staff, deeply integrated with the bank's own tables, and fully traceable logs in the team's working language. The learning and customisation cost of a general-purpose engine exceeded building a small one with a clearly bounded scope — a scope-for-simplicity trade, not NIH.
- Where does "rules as data" stop? Only checks that change frequently become data; stable core calculations stay in code. Push it all the way and the system turns into an interpreter with no type checking.
- Flexibility has a price: you buy the freedom not to change code, and you pay in debuggability. That is why the logging and the visual tooling are not nice-to-haves — they are the conditions under which this architecture survives.
- The toolchain is the delivery: engine, editor, log analysis, packaged release. Miss one corner and users ask you to hard-code the rules again.