PaymentAntino Labs
Casha - Digital Payment Platform
Two pieces of backend work on Casha, a Nigerian payment app built around community savings (AJO): access control for the staff back office that could be changed without a redeploy, then a hunt for why automated contributions were sometimes deducted two or three times.
01
The problem
Casha is a Nigerian payment app built around AJO, a savings model where a group contributes on a schedule and the pot rotates between members. I worked on two parts of it. The first was the back office, used only by Casha's staff: it needed access control an admin could change, including taking access away, without anyone shipping code. The second was the AJO contributions themselves. Deductions ran automatically, and every so often a customer was charged twice or three times for one contribution.
02
The approach
For the back office, access is data rather than code. Each table is a resource, roles carry permissions, and permissions carry create, read, update and delete rules, all stored in PostgreSQL. Endpoints declare what they need through metadata, and a NestJS guard reads the caller's permissions from the database on every request and checks them. For the contributions, the clue was that the failure was intermittent. The scheduled job that processed contributions ran on more than one pod. When the pods fired at slightly different times, the second one saw the contribution was already processed and skipped it. When they fired at the same moment, each read the contribution as unprocessed before any of them had written, and each charged the customer.
Overview
- 0
- redeploys needed to revoke a staff member's access
- 3×
- a single contribution could be charged, before the fix
- 2
- systems: staff access control, then AJO contributions
03
Key decisions
Roles, permissions and CRUD rules stored in the database
over Permissions written into the code
The whole point was to change who can do what without a release. If a permission lives in code, taking it away from someone means a code change and a deploy, which is far too slow when the reason is that a member of staff should no longer see customer data. With the rules in PostgreSQL, an admin changes a row and it applies.
Reading permissions from the database on every request
over Caching them, or putting them in the login token
A cached permission or one baked into a token stays valid until the cache expires or the token does, so revoking it doesn't really revoke it. Reading on every request costs a query each time, and in exchange a revoked permission is gone on the very next request. For a back office with access to a payment app's data, that was the right trade.
Treating the double charge as a timing problem
over Looking for a mistake in the deduction logic
The deduction code was correct for a single run, which is why it passed every time it was read. It only went wrong when the same job ran on two pods at the same moment, both checked the contribution's state before either had written to it, and both went ahead. A bug that appears only sometimes and charges two or three times rather than at random points at concurrency, not at the arithmetic.
04
What I built
Back-office access control
NestJS · PostgreSQL
Roles, permissions and per-table CRUD rules held as data, so staff access is managed without code changes.
Permission guard
NestJS guards · route metadata
Each endpoint declares what it needs, and the guard checks it against the database on every request, so a revocation applies on the next call.
Duplicate contribution fix
Scheduled jobs · Kubernetes
Traced deductions charged two or three times to the same job running on several pods at once; the duplicates stopped once the fix shipped.
Contribution dates
JavaScript Date
Near midnight, the server's UTC clock and Nigerian local time named different days for the same contribution, which the scheduling logic had to account for.
05
The outcome
The access-control system was built so that revoking a permission takes effect on the staff member's next request, with no deployment. I then moved to the AJO work, where the duplicate deductions stopped once the fix shipped. Along the way we also had to deal with JavaScript's Date object, where the server's UTC clock and Nigerian local time disagree about which day a scheduled contribution belongs to.
Stack
- NestJS
- TypeScript
- PostgreSQL
- Access control
- NestJS guards
- Scheduled jobs
- Kubernetes
- Concurrency



