15
Domain models
saas · 2024 - 2025 · client unnamed
One backend serving many client websites, each defining its own content types, its own team permissions and its own subscription.
15
Domain models
99
Route declarations
3 + 5
Permission model
roles plus per-resource grants
3
Architecture rewrites
each narrower and more capable
The problem
An agency running websites for many clients was maintaining a separate backend per site. Every client wanted different content types, their own editors with their own permissions, and their own billing. A codebase per client means every fix has to be applied everywhere.
The approach
One centralised backend where content structure is data rather than code. A client defines a collection with its own fields from the dashboard and starts storing rows immediately, with no migration and no deploy. Each site is a tenant with its own users, per-resource permission grants, trilingual content, and an independent subscription with invoicing and gateway payment.
Architecture
Schema as data: collections declare their fields, items store shapes against them. Three roles plus five per-resource grant lists, so permissions are per-collection rather than global. Full subscription lifecycle with invoice generation and gateway integration.
Each with what it cost
A decision without a stated tradeoff is a preference.
01
Why
The product premise is that clients define their own content types. Storing field definitions as data is what allows onboarding without a deploy.
What it costs
Content fields cannot be indexed because names are not known ahead of time, and validation against declared types has to be rebuilt at the application layer rather than inherited from the database.
02
Why
Subscription and invoice are created before the gateway call, so a gateway failure has to unwind both rather than leaving an orphaned pending subscription.
What it costs
Two writes to undo instead of one transaction, the cost of an external system that has no concept of your transaction.
03
Why
A payment gateway that stops responding must fail fast rather than hold a request open, because the retry path is safe and the hung path is not.
What it costs
A slow but successful response can be abandoned, which webhook reconciliation resolves.
Outcome
A new client site onboards without touching the codebase. One deployment serves all of them, so a fix ships once instead of per site.