man@mndev:~/portfolio/notes/backend
← portfolio

Domain-Driven Design in a banking teller backend

What DDD looked like in practice across five Spring Boot services for branch banking: boundaries, aggregates and events.

Backend··2 min read

Branch banking software looks simple from the outside: a teller takes cash, records it, the books balance. Inside, it’s full of rules: cash limits, ATM replenishment, end-of-day balancing, and an audit trail for everything. On a teller platform for a bank in Singapore, I helped build five core Spring Boot services using Domain-Driven Design. Here’s what was worth it.

Start with the language, not the tables

The most useful DDD practice was the least technical: use the business’s words in the code. When operations staff say “vault”, “till” and “cash position”, classes and API names say the same. That made requirement discussions with BAs and QA much faster, because nobody had to translate.

Boundaries that matched how the bank works

We split services along bounded contexts instead of along database tables:

Context Owns
Cash management Till and vault positions, cash movements
ATM management Replenishment and balancing of ATMs
Audit An append-only record of who did what, and when

Each context owned its data. Another context could ask through an API or react to an event, but never reach into the other’s tables.

Aggregates protect the rules

An aggregate is the unit that enforces an invariant. “A till can’t go negative” lives inside the till aggregate, not in a controller or a SQL trigger. In Spring Boot that meant:

Events for everything that happens “because of” something else

When cash moves, audit needs to know, and other systems may care too. Those reactions travel as domain events over Kafka instead of direct calls. This keeps the core transaction small, and lets audit and reporting scale on their own.

Worth deciding early (I’d emphasise this even more next time):

DDD isn’t free. It adds structure up front. But in a domain where a wrong number is a real problem, putting the rules in one obvious place paid for itself.

// related