> **Technical Lead** · July 2023 to March 2025
> Source: https://www.simonbetton.com/case-studies/onetwo.md (markdown only; there is no HTML page for this document).
> Index of case studies: https://www.simonbetton.com/case-studies/index.md

# Case study: OneTwo

## Quick facts

|  |  |
| --- | --- |
| **Role** | Technical Lead of one of four engineering teams; code owner (reviewer of record) for the HLQ surfaces listed under "What I owned", several of them shared surfaces that engineers on the other teams built against |
| **Company** | OneTwo, a wholly owned ANZ subsidiary incubated by 1835i |
| **Deploying bank** | ANZ Australia |
| **Scope** | HLQ: the home-loan workflow platform (DSL, rules, task engine, human-in-the-loop application) and its integrations with bank systems and with Q, the document-intelligence platform owned by another team |
| **Unit of work** | `loan application`, with `Document` objects; workflow and rules versions pinned per `loan application` |
| **Timeline** | July 2023 to March 2025 |
| **HLQ stack** | Groovy DSL (a domain DOM of those objects), TypeScript rules, Node.js, Next.js and React, PostgreSQL for DOM state, Redis Streams |
| **Deployment** | ANZ-hosted Kubernetes inside the bank's environment |

## Context

OneTwo launched as an online home-loan lender in May 2022, backed by ANZ's venture arm 1835i. In OneTwo's words, "later in 2023 we reset our direction, moving away from home loans and are now wholly focused on developing our new innovative technology – the Q Platform." I joined in July 2023, so my time there spans that reset: the company stopped being a lender and became the builder of home-loan process automation for its parent bank.

The product ANZ received is HLQ. ANZ's Managing Director of Home Loans described it in October 2024 as "a new platform called HLQ, designed to support our Customer Operations teams to speed up home loans processes", automating document ingestion, image processing, categorisation, indexing, redaction and data extraction, and organising the relevant documents and data for a given staff activity. Internally the work was split in two: Q, a Python platform that ingested and interpreted documents, and HLQ, the workflow platform that moved a `loan application` through the bank and put people in front of the decisions software could not make. I led the HLQ team.

## The problem

A `loan application` is the unit of work: a long-running workflow, not a form. It arrives as document packs from email and bank systems, passes through credit and policy rules, may be linked to another `loan application` (a partner, a debt consolidation), and ends with a Credit Assessment Officer who signs or rejects a pack under a delegated approval limit. Those limits, known as CAD levels, depend on seniority and on the size and type of loan, so the pack has to reach an officer whose delegation covers it or the file bounces.

Two things made this hard to automate inside a bank.

First, the underlying systems stay fragmented. HLQ had to present one workflow on top of RLS, the bank's legacy retail lending origination system; RLM, the Retail Lending Manager, whose data had to be enriched; an internal banking API called CoreEngine; and Q. None of those could be rewritten for our convenience.

Second, an automation that fails is not allowed to strand a customer. Automatic failures — integration failures, `loan application` or `Document` failures, missing data, errored automation, stuck workflows — as well as low-confidence Q results, policy exceptions, and sampling for accuracy, all have to become a user task, with the context they need, and then rejoin the automated flow.

## Constraints

The runtime lived where the bank operated: ANZ-hosted Kubernetes inside the ANZ Australia environment, not a cloud account OneTwo controlled. Releases reached the bank through ANZ's own testing teams, so each fortnightly release carried a changelog written for testers who did not share our backlog.

Every run had to be reconstructable for audit: which version of the workflow ran, which facts were written, which task fired, who decided. At the same time, operational logs could hold no personal information. Names, account numbers, and document contents stayed on the `loan application`; log lines carried identifiers and event types. Keeping personal data out of logs was a responsibility every team shared, not an HLQ invention.

## How HLQ was designed

The workflow and the objects it operates on — `loan application` and `Document` — are written in a human-readable DSL implemented in Groovy. That DSL is a document-object model of the domain: a DOM of those objects, not a browser DOM. Each published version of the DSL is stored as a row in PostgreSQL, and a `loan application` pins the workflow and rules versions it started on. That is what makes an older `loan application` replayable for audit after the rules change, and it is why policy can be read as language rather than traced through code. I was code owner for the DSL and developed it heavily with my team.

TypeScript rules run against those shapes and write facts back onto the `loan application`. I led the rules work and my team built it. I was also code owner for the core rules engine, an existing implementation I inherited rather than designed from scratch. A rule that finds a missing fact does not stall; it creates the next piece of work, either an automatic task or a user task. The task engine groups work into stages, applies tasks when conditions on the object graph are met, repeats over lists, and can bind a task to a service contract: an API call with a defined request and response shape.

Failure handling is nested. Automatic failures — integration failures, `loan application` or `Document` failures, missing data, errored automation, stuck workflows — fall back to another path; if that fails, they fall back again; the last fallback is always a human task. Work does not stop in an error queue. This was my team's design, under my lead.

A user task is a first-class workflow state with a decision attached, not a UI layered over an otherwise automatic pipeline. User tasks arrive from three directions: an HLQ rule that requires judgement, Q flagging a `Document` as needing review, and an exhausted fallback chain. The Next.js application shows all three as the same kind of task and assembles the documents and facts relevant to that activity.

Redis Streams carried evented work between services; PostgreSQL held the workflow state, its history, and the DSL versions. One store for both would have made catch-up after an outage and audit reconstruction harder. The Streams and Postgres split was in the platform core when I joined; I inherited it.

## What I owned

I led technical direction for the HLQ team: architecture, engineering standards, and delivery of the parts we owned. I was a founding contributor to the user-facing application, shared UI library, home-loan business rules, and workflows.

I was code owner for the user-facing HLQ application, the shared UI library, the inherited core rules engine, the DSL and home-loan workflow definitions, the CoreEngine API integration, the domain services for RLS and RLM enrichment, and the integration to Q. Code owner here means reviewer of record for changes to those paths, whichever of the four teams made them. It does not mean I wrote them alone.

The review rule I applied at the HLQ/Q boundary was simple to state. If a change was about how a `loan application` moved, which facts it held, or who had to approve it, it belonged in HLQ. If it was about ingest, indexing, or what a `Document` contained, it belonged in Q. My work in Q itself was limited to minor Python plugin changes for integration with HLQ; the document-intelligence internals belonged to its own team.

## Agreeing how much flexibility the task UI needed

Before we knew how many task variants the bank would need, the backend team proposed an API that could describe dynamically composed interfaces. Reviewing the prototype, I thought the frontend would need more machinery to interpret those shapes than the forms justified. The backend team also had constraints: they had inherited an implementation that limited the API shapes they could offer.

We worked through it in discussion. The combinations of form fields were finite, even though the tasks varied, so we agreed on a strongly typed JSON matrix of supported combinations. We ended up with around forty variants following the same patterns. Engineers picked those patterns up quickly, and new variants were straightforward to build and mock.

Consistency mattered to the people using the result. ANZ operators handled hundreds of tasks a day, so the aim was to keep field placement and interactions predictable enough for muscle memory to do some of the work. Operators saw the finished interface, not the API decision. The outcome we observed directly was on the engineering side: the team could extend the task UI without designing a new rendering pattern each time.

## Helping the team take ownership

Engineers joining the company or moving into my team worked closely with me through their first few months. I set clear expectations, then handed over larger pieces of work as they became ready to deliver independently. A junior engineer who needed more support paired with a colleague whose domain experience fitted the task. People used their own judgement about when to ask for help, including from each other.

Detailed pull-request reviews were a large part of that support. Advice, discussion and examples sat against the code being changed, where the engineer could connect them to the work. I was also available to jump on a call. Senior engineers took on delegated work while I spent more time with the engineering manager on sprint planning, backlog refinement and requirements, bringing the architectural context into those discussions.

At the end of each sprint I ran a stop, start, continue retrospective. The same principle ran through onboarding, review and planning: make expectations clear, give people room to deliver, and adjust the support as they took on more responsibility.

## Release decisions with the business

Some rules depended on criteria the business was still defining, including checks across linked loan applications, Documents and other sources. When a rule could not be automated in time for a release, the business decided whether manual handling was acceptable. The human-task fallback gave them that option. A check on whether an applicant was over 65, for example, could become a user task until the automated rule was ready. The check still had to happen; the decision was who would perform it for that release.

We also worked on technical debt each sprint: reducing prop drilling, improving abstractions, and making better use of Next.js parallel and intercepting routes. An improvement that was not ready stayed out of the release and moved to a later one. Image delivery became a more immediate concern because its cost was paid repeatedly by the people processing loan applications.

## Two things I built

### A mock layer so the UI and its tests did not wait for the workflow

The human-in-the-loop screens depended on a full DSL graph, populated `loan application` state, and Q results. Waiting for all three before frontend work could start would have serialised the team behind the workflow engine. I built a stateful mock implementation of the HLQ backend on mocks-server so React developers could build and ship user task UI against realistic workflow states without satisfying every rule and data prerequisite. Because the mock held state, the same layer let Playwright, Cypress, and Cucumber suites drive the application in parallel. The cost of any mock is drift from the real contract; that is the price of not serialising the team.

The team's DSL and TypeScript rule tests took the same approach from the other side: they ran against an in-memory instance of that domain DOM rather than a browser DOM, so pure DSL unit tests and rule tests shared one double, and the DSL could change without freezing the UI team.

### A document review canvas that keeps regions stable under zoom and rotation

Classification, extraction, and redaction tasks put a scanned page in front of a person. They need to see Q's proposed redactions and their own drafts together, draw a new region, remove a wrong one, rotate a landscape scan, zoom in, and jump from a cropped thumbnail in a sidebar back to the region on the page. Drawing rectangles was not the hard part. Keeping every rectangle stable in document space while the viewport zoomed between 50% and 300%, rotated in 90 degree steps, changed page, and scrolled, was.

I built the surface as a reusable canvas toolkit on React and Canvas 2D rather than a one-off screen. The decisions that made it hold:

- Regions persist as coordinates relative to the natural image, never the CSS box. CSS transforms rotate and scale the container, the canvas bitmap stays at natural image size, and only the pointer is inverted through the rotation. Without that inversion, every click on a rotated page misses the box the user sees.
- The document sits in a square container sized from the longer side and the zoom level, so a rotation never clips or walks off centre. On zoom, scroll position is restored by ratio so the reviewer keeps looking at the same part of the page.
- Four overlay canvases, not one: machine redactions, human drafts and highlights, a pulse layer for "navigated to" from the sidebar, and a live drawing layer. Each clears and restyles on its own, so a hover reveal cannot wipe a rubber band mid-drag.
- Machine redactions are audit-sensitive, so removing one sets a removed flag and renders it dashed rather than deleting it. Human drafts are deleted outright. The two paths are deliberately different.
- Undo and redo are a generic typed history stack, not canvas state. The drawer either owns history or delegates to the parent through a callback, never both on the same update, so local and parent-controlled undo cannot fight.
- Sidebar crops render lazily one panel ahead of the viewport at device pixel ratio, so a long redaction list does not decode every page image up front.
- Zoom and rotation reset when the document identity changes, so a new file does not open at 270 degrees and 180%.
- Overlay colours come from CSS custom properties, so design can restyle without touching fill and stroke code. Read-only and result-only modes hide the live canvas rather than unmount it, so overlay layout does not collapse.

Each piece has its own unit tests (drawer, crop maths, document sizing, history, zoom, rotation, scroll centring), and Storybook covers the composed canvas so design could rotate and zoom without the full application running.

## Making document navigation keep up with the operator

Document packs could run to more than a hundred pages. Operators in Australia and India worked through ANZ's VPN and virtual environments, sometimes over slow or unreliable connections. A small wait on each page accumulated across the day's work. We used Splunk and conversations with real users to understand where those delays were happening.

We added services to deliver optimised images and changed how the thumbnail strip and the canvas used them. Separate thumbnail and full-size URLs meant loading a thumbnail did not prepare the resource the viewer would need. We used the same full-size image URL in both places, displaying it at thumbnail size in the strip. That gave the browser one resource identity to fetch and decode ahead of navigation, with the strip keeping the image in use so the viewer could reuse it.

The interaction we were designing for was a keypress. The next page needed to be ready before the operator asked for it, rather than starting another fetch and decode on navigation. Browser memory retention is not guaranteed, but sharing the resource removed the separate thumbnail-to-full-size loading path.

Following the changes, application SLA performance improved and operators stopped reporting the navigation delay as a bug. loan applications fell into three processing SLA categories. Those were targets for getting a `loan application` through the system, not timings for an individual keypress; I do not recall the exact thresholds.

## Q, as HLQ saw it

Q was a separate Python platform with a plugin architecture, owned by another team. It ingested documents from email, RLM, and other sources, then indexed, linked, classified, redacted, and extracted from them. When Q's confidence was low or a sample needed checking, it raised a request for a human; HLQ surfaced that as a user task on the same Next.js application. RLM data that arrived through Q was then enriched on the HLQ side. HLQ could ask Q for document facts without owning ingest, classification, redaction, or extraction.

## Technologies and standards

| Layer | Choices |
| --- | --- |
| Workflow language | Human-readable DSL implemented in Groovy: a domain DOM of `loan application` and `Document` (not a browser DOM) and the workflow over them; each version stored in PostgreSQL and pinned per `loan application` |
| Rules | TypeScript rules that read and write those shapes and originate tasks |
| Human-in-the-loop UI | Next.js and React; a React and Canvas 2D document canvas with layered overlays, image-space coordinates, and a generic undo history |
| Runtime | Node.js services; Redis Streams for evented work; PostgreSQL for durable workflow state |
| Deployment | ANZ-hosted Kubernetes inside the ANZ Australia environment |
| Testing | mocks-server for a stateful backend double; Playwright, Cypress, and Cucumber end-to-end; unit tests per canvas module; Storybook; in-memory domain-DOM double for DSL and rule tests |
| Performance investigation | Splunk and operator feedback; optimised image delivery with a shared resource URL across thumbnails and the document viewer |
| Audit and privacy | Durable workflow history and DSL version pinned per `loan application`; no personal information in logs |
| Integrations | RLS (legacy retail lending origination); RLM (Retail Lending Manager) enrichment; CoreEngine internal banking API; Q document-intelligence platform (Python, separate team) |

## What changed

HLQ went live for ANZ's Customer Operations teams, automating document handling and organising the documents and data staff need for each activity. Loan volumes, cycle times, and cost figures are ANZ's, and I do not publish them.

From my own work: the frontend and its end-to-end suites stopped waiting on the workflow engine once the mock layer existed; and the document review surface that staff use to correct machine redactions and extractions is a tested, reusable toolkit whose regions survive zoom, rotation, and page changes, and in which removing a machine redaction is recorded rather than erased.

From the team, with me as its technical lead: a workflow platform in which an automatic failure ends as a human task rather than stopping in an error queue, and in which any `loan application` can be reconstructed for audit without personal data reaching a log line.

The task UI grew to around forty variants on shared patterns that engineers could build and mock easily. New team members progressed from close support to owning larger pieces of delivery. The image work improved application SLA performance, and the operator reports about document-navigation delays stopped.
