I didn't think much about system design when I started building Spluur. I needed a feature, so I built it. Something broke, so I fixed it. There was no big architecture diagram, just me trying to get the thing working, and for most of the app that's a fine way to work.
Then billing showed up, and I had to slow down. This wasn't another feature. This code can move money.
Billing bugs have a person on the other end#
Spluur takes payments through Paystack, and once money is involved, bugs stop being merely annoying. A broken button is a broken button. A failed deployment sends me to the logs. A billing bug means someone gets charged twice, or doesn't get charged, or sees the wrong balance, or pays and the platform never records it. There's a person on the other side of that, and trust is involved.
So I started asking questions I hadn't asked about the rest of the app. What if the price is wrong? What if a request retries, or Paystack sends the same webhook twice? What if I call the payment code from somewhere I didn't expect, or break a working flow next month?
The one that kept coming back: what happens with 100 customers instead of just me testing? When I'm the only user, a bug is "huh, that didn't work." With customers, the same bug is "why did your platform charge me twice?"
One big billing module was the easy option#
The obvious design is one billing module that calculates the price, checks the plan, charges the customer and updates the balance. Everything sits close together, one function calls another, and you never jump between files. It feels great while you're moving fast.
But as the app grows, the code that calculates a price sits next to the code that can charge somebody. The code that checks whether a user may do something sits next to the payment logic. Every one of those parts now has a path to the money, and I kept asking: why does this part have that capability at all? It doesn't need it, so why give it?
That's where the idea came from. Not "let's design four elegant services", but "I don't want every part of this thing to be able to touch money".
Four jobs#
I ended up with four pieces, and four isn't a magic number. It just matched what each part is responsible for:
Pricing → "this should cost X"
Limits → "this person is allowed to do it"
Billing → "this is what they owe"
Wallet → "this is where money actually moves"The last one is the point. The ability to move money lives in one small place, not scattered across API routes and not anywhere that happens to have Paystack credentials.
Here's a simplified sketch of the idea (not Spluur's actual code):
type Quote = { planId: string; currency: string; amountMinor: number };
interface Pricing { quote(planId: string, currency: string): Quote }
interface Limits { allows(userId: string, action: string): boolean }
interface Billing { charge(userId: string, quote: Quote): Promise<void> }
interface Wallet {
debit(userId: string, amountMinor: number, idempotencyKey: string): Promise<void>;
}I'm not showing it because the architecture is clever. I'm showing it for what each piece is allowed to do. Pricing gives a number, Limits says yes or no, Billing works out what's owed, and only Wallet moves money.
Why the split matters#
If Pricing has a bug, someone sees the wrong quote. That's bad, but Pricing shouldn't be able to charge anyone just because its arithmetic is wrong. If Limits has a bug, someone might do something they shouldn't, but that code can't call Paystack either.
A bug is one problem. A bug plus unnecessary capability is a bigger one. I want the dangerous capability to have a small blast radius.
The same thinking applies to security. If the server is compromised, or a secret leaks, or one endpoint has a vulnerability, does the attacker land somewhere payment code is scattered everywhere? Splitting the code doesn't secure a platform, and a compromised system is still compromised. But I don't want to hand every part of the app more power than it needs. With Spluur this goes beyond payments, because the code controls deployments, containers, routing, domains, workers and databases. The question isn't only "could someone copy my code?" but "what could someone do if they controlled the code that controls my platform?"
Money is weird#
Inside the wallet, a couple of small decisions matter a lot.
Amounts are never floating-point decimals. You don't want to wonder where 100.499999999 came from, so amounts are integers in the smallest unit: kobo, cents. Explicit and boring.
And payment requests retry. Webhooks arrive twice, networks fail, servers restart. When the same operation shows up again, I don't want "nice, another payment", I want "didn't I already process this?" That's what the idempotency key is for: the wallet recognises an operation it has already handled instead of doing it again. It isn't a fancy feature, just what you start caring about once you imagine a perfectly normal network hiccup delivering the same request twice.
What it costs#
The point isn't prettier code. It's that the thing which can move money is small, narrow and easy to scrutinise, so it's the part I can test hardest and the part fewer things touch. Pricing can be a plain function: same inputs, same quote, no payment provider needed to test it.
The cost is real, though. More boundaries, more interfaces, more to keep in sync. A plan upgrade is no longer one function. A quote happens at one moment, a limit check at another and a charge later, and things can change in between. Even I, as one person, have more to hold in my head. The boundaries aren't there to coordinate a team. They're there to protect me from myself on the day I'm tired and thinking "this is just a small change".
Is four overkill?#
Maybe. Spluur is still being built. I don't have millions of customers or years of production history, and I haven't seen every refund or payment edge case. One boundary might move later, or two pieces might merge again. I'm more sure of the principle than the exact shape: dangerous capability should live in as few places as possible.
I haven't turned into a system-design person. I still build first and fix my bad assumptions as I find them. The difference is that for some parts of the system I now stop and ask what happens when it goes wrong, and who pays for it. Before, I only asked how to make it work. For billing, the better question is: it works, but what happens when it doesn't?