Notes from the build
Blog
Notes on problems I solved building production systems in TypeScript, NestJS and PostgreSQL.
NestJS
One database, many companies: how StaffDock keeps each company’s data apart
StaffDock serves many UK companies from one shared database. Every query is scoped to one company inside the NestJS API, and tests prove one company can never read another’s data.
· 4 min read
PostgreSQL
When a record is evidence: saved checks the app can never change
A right to work check is evidence for the Home Office. In StaffDock, one guard in the API’s database layer refuses any edit or delete on a saved check, whichever part of the app asks.
· 4 min read
Security
A document vault even we can’t open: client-side encryption in RightUni
RightUni students keep passports and bank statements in a vault that only they can read. Files are encrypted in the browser with AES-256-GCM, so the server only ever stores ciphertext.
· 3 min read
PostgreSQL
Spending a credit exactly once: a locked transaction and a balance that can’t go negative
In RightUni, agencies prepay credits for student leads. Each credit is spent in the same locked transaction as its ledger row, and the database refuses a negative balance, so two leads at once can’t overspend.
· 3 min read
AI
An AI chatbot for a law firm that never gives personal legal advice
For Stonebridge Legal, I built a chatbot that explains UK immigration in general terms and hands anything personal to a booked consultation. The hardest design decision was what it must never do.
· 4 min read
Architecture
Not losing booking emails when a server crashes: the outbox pattern
Exactly-once email is impossible, so Slotwise aims for at-least-once with deduplication: an outbox table, deterministic job ids, a send log and a separate worker.
· 3 min read
TypeScript
Handling UK clock changes in a booking engine with the Temporal API
Twice a year, UK clocks change and careless booking code moves appointments by an hour. How Slotwise keeps instants and wall-clock hours apart with Temporal.
· 4 min read
PostgreSQL
How I stopped double-bookings with a PostgreSQL exclusion constraint
Check-then-insert lets two customers book the same slot. In Slotwise, PostgreSQL refuses the overlap itself: 100 parallel requests, exactly one booking.
· 4 min read
