When you build a new business banking app you should be prepared to make some bold decisions:
“Creativity is thinking up new things. Innovation is doing new things.“
Theodore Levitt
At Mettle, we chose to do something new. When we looked at how financial professionals such as accountants work, we realised that there was a relationship between the way that they work and the way that the Event Sourcing pattern works.
“Accountants use pens.”
Gregory Young
You might think that using a pencil would make more sense but the convenience of being able to erase mistakes and change history brings you ever closer to the risk of covering up mistakes and committing fraud. A real accountant uses a pen, correcting mistakes visibly and honestly.
An engineering culture like the one Mettle is trying to create should have very similar characteristics. We own our mistakes, talk about them and learn from them.
More importantly for Mettle, as a place where our customers trust us to keep their money safe, is that we need to follow similar principles to the accountant, always using pens.
This is the essence of the “Event Sourcing” pattern:
“The fundamental idea of Event Sourcing is that of ensuring every change to the state of an application is captured in an event object, and that these event objects are themselves stored in the sequence they were applied for the same lifetime as the application state itself.”
Martin Fowler
Event Sourcing is the technological equivalent of using a pen and not a pencil.
This is one of the many reasons why we at Mettle are building all our systems, including our financial ledger, using Event Sourcing.
Where does Double Entry come into it?
Double Entry Book Keeping is the practice of always recording, in a ledger, both a credit and a debit for every transaction. The debits and credits are always for equal amounts. Money is always coming from somewhere and is always going somewhere.
This leads us to some interesting fundamental properties of a Double Entry ledger:
The money is always there – it may be in the wrong place, but a complete record exists of where it has gone so any mistakes can be corrected by putting in new records to move the money to the correct place
If the credits and debits in a Double Entry are for equal amounts you can prove that you have not accidentally ‘created’ or ‘destroyed’ money
If you add up all the credits and debits in a Double Entry ledger then the ledger always adds up to zero. This is the most basic form of a “checksum”. If it adds up to something other than zero then there is a mistake in your ledger
At Mettle, we spotted something unique about the combination of Double Entry and Event Sourcing.
We could have a ledger whose credits and debits could be guaranteed to add up to zero and would keep a complete record of everything that happened.
We call this pattern Write Once Double Entry – WODE. WODE dictates that the only type of events that can move money in our ledger are Double Entry events.
The basic structure of a Double Entry event that achieves this is simple:
Timestamp (when the event happened)
Source Account
Destination Account
Amount Moved
You cannot move money in anything but a balanced way. The checksum is built into the fabric of our ledger such that it always passes.
WODE further dictates that the events cannot be deleted or changed. By using an event store with this property we can be certain that it is met.
With this approach, Mettle is excited to have built a new type of ledger giving us confidence that our customers’ money is always properly accounted for.