What fifteen years of small-team projects taught me about architecture and infrastructure
On this page
- Pick the simplest storage that survives
- One central app beats a plugin per site
- Content architecture is a product decision
- Enum-driven business logic
- Make the deploy boring
- Consolidate servers, isolate data
- Edge and mail are not your app
- Webhooks and background work: idempotent, 2xx, visible
- Private by default
- Measure in the real environment
- The short version
Most of what I have built was shipped by one to three people and then run by fewer. That shapes what I think good architecture is. These are the rules I keep coming back to, each with the project that taught it.
Pick the simplest storage that survives
Content goes in flat files. This site is Markdown in git; the Statamic sites I build are the same idea with a control panel. A small app with one writer gets SQLite. My one-time-purchase license site keeps its licenses in SQLite and a nightly job runs VACUUM INTO for a consistent snapshot, gzips it and drops it in a private S3 bucket under daily/, weekly/ and monthly/ prefixes. Lifecycle rules expire them at 14 days, 90 days and 2 years. No managed database, no replication, and restoring is "download, gunzip, replace the file". MySQL is for when there are concurrent writers.
One central app beats a plugin per site
Billing used to live wherever the client's site lived. Now it is one portal with multiple businesses in it. Invoices, estimates and retainer setup go out as emailed signed links, clients never log in, and an MCP server lets my tools create an invoice from a chat. One place for Stripe keys, one webhook endpoint, one upgrade.
Content architecture is a product decision
The Statamic pattern I reuse: a Replicator over a shared blocks fieldset, snake_case block handles, one Antlers partial per handle, a custom Img tag that handles WebP and lazy loading. Editors get freedom inside rails. I get exactly one place to style a block. Deciding that up front is deciding what the client can and cannot break. The starter I use for new sites ships with a set of blocks and a {{ blocks }} tag that reads the list straight from the fieldset, so the list of blocks is never documented twice.
Enum-driven business logic
Invoice status is a PHP enum with match for labels, colours and isOpen(). Before that it was strings compared in controllers, and "written off" was a special case that not every place remembered. An enum makes the new case a compile-time todo list:
public function isOpen(): bool
{
return in_array($this, [self::Sent, self::Overdue]);
}
Every place that asked "can this still be paid?" now asks the enum, and when I added WrittenOff the match expressions told me every spot that needed an answer. The same goes for estimate status, retainer status and recurring intervals. Transitions live next to the states, not in whichever controller happened to need them first.
Make the deploy boring
Forge with push-to-deploy. composer ci:check is the single gate: formatting, vue-tsc, Pint, PHPStan, content validation, tests. Dummy env values live in phpunit.xml so CI never needs a secret. Clear the route cache before the frontend build, because Wayfinder reads routes at build time and a stale cache from the last deploy can quietly produce an empty bundle. I learned that one in production. The other half of boring is that nobody types on the server. If a deploy needs a manual step, that step goes in the script or it does not exist.
Consolidate servers, isolate data
Four tiny droplets became one 4 GB VPS. Each client database has its own MySQL user and a client option file on the server, so a re-import never needs a password pasted into a terminal. Mail goes through an API provider because the box would not send on the normal SMTP ports anyway. nginx serves gzip_static and nothing fancier.
Edge and mail are not your app
Cloudflare in front for DNS, proxying, Turnstile and cache rules. Resend for mail with a scoped key per domain. S3 buckets provisioned per project by a script that creates a bucket-scoped IAM user behind a permissions boundary, so a leaked key reaches one bucket and cannot create a new admin. None of this is in the Laravel app and none of it should be.
Webhooks and background work: idempotent, 2xx, visible
Every handler checks whether it has already seen the payment intent or session id before writing. Events I do not act on get a 200. Logs say what was ignored and why. For personal automation I run a scheduled-job runner on my own machine with a UI, instead of a crontab entry I will forget exists.
Private by default
Internal services and the homelab server live on Tailscale. The one thing that must be public, expiring file-share links for clients, goes out through Funnel on a single port with an unguessable path and a cron job that tears it down on the expiry date. No public admin panels when an emailed signed link does the job.
Measure in the real environment
Simulated checks lie. A client-side bug gets reproduced in a real browser or the iOS simulator, not a headless HTML dump. A deploy gets judged by its log, not its green badge, because Forge reports a failed npm run build as complete. A mixed-content bug gets curl against the origin, because the cached HTML is what is actually served.
The short version
Fewer moving parts. One gate before every push. Deploys nobody has to watch. Private unless there is a reason not to be. Then spend the time that saves on the product, because for a small team the product is the only thing anyone is paying for.