Why a database is not yet a ledger
In plain words: what happens to money in an ordinary table, from double charges on a retry to negative balances and lost bookings. And what changes with a double-entry ledger where every operation runs exactly once.
Ask any AI agent to add a balance to your app. Almost certainly it will do this: a balance column appears in the users table, and a payment becomes "read the balance, subtract the amount, write it back".
It works. In the demo. With one user. Until something breaks.
Let's look at what happens when real money starts living in a table like that, and why it isn't the database's fault.
What can go wrong
A retry, and the money is charged twice. The customer presses "Pay", the network hesitates, the answer never arrives. They press again. Or the app retries on its own, because that's what it was told to do. The server faithfully runs both. The balance drops by 1,000 instead of 500.
Two at once, and the balance goes negative. The account holds 100. Two requests arrive at the same moment, both read "100", both decide 80 can be charged, and both charge it. The balance is minus 60, even though the code did check "is there enough money".
Half an operation. A transfer is "take from one" and "give to the other". The server dies between the two steps. The money left and never arrived.
Cents that wander off. In JavaScript, 0.1 + 0.2 equals 0.30000000000000004. Add a percentage fee, a multiplication by quantity and some rounding, and by the end of the month reconciliation is off by a few dollars. Nobody knows where they went.
One room, two bookings. Two guests book the last free room at the same moment. Both see "available", both get a confirmation. Cue an awkward chat at the front desk.
No history. A balance column only knows "how much right now". Why it was higher yesterday, who changed it and what for, is gone. And that's exactly what the customer, the accountant and the tax office will ask.
It's not the database's fault
Let's be fair: Postgres, Supabase, Firebase and other databases are excellent at keeping data. They have transactions, locks, unique keys, exact decimal types. An experienced engineer can build a correct ledger on top of them. Banks do.
The problem is elsewhere. A correct ledger is a dozen things you have to remember every single time: a transaction here, a lock there, a retry key, an exact type, a change log. Miss one and the bug stays quiet until a real customer shows up. An AI agent in a hurry to show results usually writes the simplest version. You can't really blame it: it just doesn't know this particular line will one day cost money.
What a double-entry ledger changes
Accountants solved this centuries ago. Money doesn't "change" in a column, it moves from one account to another. Every movement has two sides: from where and to where. All movements always add up to zero. A balance isn't a number someone wrote down, it's the sum of the entries, and you can always recompute it.
In Dirygent this is built into the platform, with what apps need on top:
- Every operation has a key. A repeat with the same key returns the same result instead of a new entry. A double click, a retried request, a resent webhook double nothing.
- The ledger itself refuses to overdraw a wallet, rather than a check in the code that someone can forget.
- A transfer either happens completely or not at all. No more "taken but never given".
- Reserve first, confirm later. Money can be reserved before calling the bank and confirmed when the answer arrives. If the answer never comes, the reservation releases itself after a set time.
- Bookings are accounts too. A room has a balance for every night. A five-night booking takes one from each night, or nothing at all if even one night is taken.
- Amounts are exact. Money travels as decimal strings, so cents don't wander off.
- History is forever. Every movement is recorded, so "why" always has an answer.
Same situation, two outcomes
| What happened | A balance column |
A double-entry ledger |
|---|---|---|
| The request was retried | Charged twice | Charged once: the repeat is recognised by its key |
| Two requests at once | Possibly negative | The request there isn't enough money for is refused |
| The server died mid-transfer | Money vanished | The transfer is either complete or never happened |
| Two people book the last room | Two confirmations | One booking, the other gets a polite no |
| "Why is the balance this?" | Unknown | Every movement is visible |
About agents and live data
In July 2025, SaaStr founder Jason Lemkin was running a "vibe coding" experiment on Replit. During a code freeze, the agent deleted a production database. The data was later recovered with a rollback. Replit's CEO called it unacceptable, and the company separated development and production databases and added other safeguards.
The lesson isn't "AI is bad". The lesson is that the rules have to be built into the platform, not live in the memory of an agent or a person. That's how we build Dirygent: the sandbox is separate from live, every change is a version you can roll back, and the platform won't save an unsafe change.
Together, not instead
If your data already lives in Supabase or Firebase, let it stay there. Dirygent works on top of existing systems and connects to them over HTTP and webhooks. Your tables keep profiles, products and texts. The ledger in Dirygent keeps money, bookings and stock.
How to put this together with a Lovable interface and a payment provider is in "Built an app in Lovable? Here's how to let it take money safely". The overall map of tools is in "Lovable, Bolt, Replit, v0, Supabase and Dirygent: who does what".
Dirygent is in early access. Request access if money is showing up in your app.