You open a friend's side project. It's fast, it looks good, and you start wondering what's underneath. Maybe a three-thousand-line server.js. Maybe something that would survive a day with ten times the traffic. You can't tell from the UI; you have to look at the architecture.
So here is the architecture of two side projects I run in production: Ăn Gì, which picks one place to eat near you, and Wishjar, a jar of Vietnamese wishes. Both are small and both run on a single VPS. I drew them in C4 to show where I left room for growth on purpose, and where I haven't yet.
The C4 model in two minutes, and how to read these diagrams
Simon Brown's C4 model draws a system at four zoom levels, the way you zoom a map. L1 System Context shows who uses the system and which outside systems it depends on. L2 Container opens it into the things that run and store data on their own: the web app, the database, the cache. L3 Component opens one container into its main building blocks. L4 is the code itself, so I skip it.
What I like about C4 is that each level answers one question. A product person can stop at level 1. Someone about to deploy reads level 2. Someone about to change the code reads level 3. Nobody has to squint at one giant poster.
The diagrams are dense and small on a phone. Open large shows one full screen, where you can drag, zoom and tap any box for its explanation. Boxes with a level underneath have a Look inside button.
Ăn Gì: a monolith with clear borders
Ăn Gì is a Next.js app. On the L1 diagram, look at two things: who is allowed to call outside services, and how each paid one is capped.
Ăn Gì depends on five outside services. The three that cost money or carry a quota (Claude, HERE, Google Places) are called only from the server, behind hard caps in code: 900 HERE calls a day and 30 Google Places calls. A traffic spike can thin out the nearby list, but it can't run up the bill. Directions go to Google Maps entirely. Routing is a different product, and people already trust Google Maps for it.
Scaling starts at L2. Data lives in Postgres, and rate-limit counters and the nearby cache live in Valkey, so the web container keeps almost nothing of its own. That's the stateless processes rule from the Twelve-Factor App. "Almost" because the Next cache and the chat limits still live inside the container; both are in the table at the end.
The two stores also play different roles. Postgres must survive, so a nightly pg_dump keeps 14 copies. Valkey has persistence turned off on purpose: losing it resets rate limits and a 30-minute cache, nothing more. When something breaks at 2 a.m., you already know which one to save first.
The VPS has no public port. Cloudflare Tunnel dials out from the machine, so a port scan of its IP finds nothing to knock on.
Two things at L3 are worth a close look. First, every page request and data read goes through one gate called the Shield: a nonce CSP, HMAC data tokens, rate limits, DNS checks for Googlebot and Bingbot, and 24-hour bans for attack probes and scripted clients. A new page gets all of that by default. Nobody has to remember to copy a check.
Second, every read goes through one data layer with a cache tagged places. Approving a place writes it to the database and calls revalidateTag in the same action. There's no TTL to guess: the cache refreshes when the data changes.
Wishjar: static reads, one paid path
Wishjar is much smaller. The library of 1,008 wishes is static content, and the "ask AI to tweak this" button is the only thing that costs money, so the design keeps those two apart.
At runtime Wishjar has a single paid dependency, Claude, and one at build time, Codex CLI. Codex writes new lines against a JSON schema, a script checks each line and drops near-duplicates, and I read them before committing. The content exists before anyone opens the app, so a tap returns a line instantly.
At L2, the whole library ships in the bundle (the main chunk is about 73 KB gzip) and a service worker precaches the app. Reading a wish never touches the server, and the jar still shakes offline. The Node server serves static files and exactly one endpoint, POST /api/rewrite. Each fresh AI line lands in SQLite so I can review the good ones and serve them to other people later.
L3 is a pipeline where any step can turn the request away, and the cheap steps run first. The origin and content type are checked first. Then come the per-caller limits: 6 calls a minute and 60 a day per IP, 40 a day per visitor. Only then is the body read, capped at 1 KB, and looked up in the 24-hour answer cache, where identical requests arriving together share one call. On a cache miss, two more checks run: 3,000 calls a day in total and at most 8 model calls in flight. Claude only sees a request that every cheaper step let through.
The request never carries free text, either. The client sends a library id, a style and an audience, and the prompt contains only our own lines, so there's nothing to inject. The reply is parsed against a schema and checked again against the same token and length rules the generator applies.
What "ready to scale" means here
Neither app needs to scale today. I put the borders in the right places, so on the day it matters I replace one box on the diagram and leave the rest alone. Six habits cover most of it:
- Separate state that must survive from state you can lose. Postgres and the SQLite file get backups; Valkey, caches and rate limits can vanish.
- Every paid path has a ceiling, written in code, not only in a provider's dashboard.
- One gate for outside requests: the Shield in Ăn Gì, the request guard in Wishjar. Abuse rules live in one place.
- Caches know when to refresh: Ăn Gì flushes by tag when data changes, and Wishjar keys its cache on the wish, the style and the audience.
- Do work as early as you can: at build time (prerendering, content generation), at the edge (immutable assets, image cache), or on the device (search, spin, offline).
- Monolith first. Martin Fowler noticed that almost every successful microservice story started with a monolith that grew too big and was then split. Clear borders inside a monolith are far cheaper than network borders between services.
One more habit sits outside the diagrams: write the reasons down. Ăn Gì has 33 ADRs as of 22 November 2026, over 1,000 Vitest tests and over 200 Playwright tests. I write ADRs for future teammates, and the teammate is usually me a few months later.
When the UI grows
An app that gains a screen every week gets messy fast if the interface has no system behind it. Ăn Gì has about 100 design tokens as CSS custom properties for color, spacing and type, 39 of them redefined for dark mode, CSS Modules per component, one shared Sheet component for every slide-up panel, and typed Vietnamese and English dictionaries, so a missing translation fails the build.
Performance has a budget too: the server sends the first 20 place cards, about 11 to 13 KB gzip, and the rest arrives after first paint. A bundle check script blocks leaked source maps and keys. Mobile LCP is still 2.9 to 3.7 seconds against my own 2.5-second target, so that's next on the list. Wishjar goes the other way: no UI framework, state in the URL so a shared link reopens the same card, and the whole app in about 73 KB gzip.
Where they aren't ready yet
These are the places that would break first under real growth, and what I plan to do when that day comes:
| App | Breaks first | Next step |
|---|---|---|
| Ăn Gì | The data layer loads every place into memory, and the client receives the full dataset after first paint. Fine for a few hundred places. | Query by area and paginate in Postgres, keeping the same cache tag. |
| Ăn Gì | Migrations run on startup. Two web replicas would run them twice. | Run migrations as a separate deploy step before the new version takes traffic. |
| Ăn Gì | The Next cache lives on local disk, and chat rate limits live in memory. | A shared cache handler, and every counter moved to Valkey. |
| Ăn Gì | One VPS, backups only as a nightly dump plus one before each deploy, errors only as PostHog exceptions, no tracing. | WAL archiving or a managed Postgres, then a real error tracker and OpenTelemetry. More in observability as a design choice. |
| Wishjar | Rate limits, the answer cache and in-flight calls are all in memory. The code says so: safe for one container only. | Move them to Valkey before running a second copy. |
| Wishjar | SQLite allows many readers but one writer at a time, and writes run synchronously on the event loop. | Fine for an archive. Move to Postgres once reviewing AI lines becomes a real feature. |
| Wishjar | The library ships in the bundle, so more lines mean a heavier bundle. | Split the JSON per occasion and load only the one on screen. |
| Wishjar | Deploy builds on the VPS and has no rollback. | Build the image in CI and keep the previous tag. Ăn Gì has a documented manual rollback, but it builds on the VPS too. |
I found most rows of this table while drawing the diagrams. Once the borders are on paper, weak spots tend to sit on the arrows: state held in memory, or a step that would run twice with two copies. For the deeper version of each fix, there are posts on cache pitfalls, scaling a database one step at a time and when to split a monolith.
Try it on your own side project
This week, take a sheet of paper and draw levels 1 and 2 of your side project, nine boxes at most per level. Mark three things: which paths cost money, which state has to survive, and how many gates an outside request passes. If you can't say where some piece of state lives, that's the first thing to fix.
And if you'd like to see both apps running, each has a demo on my apps page: spin a dish with Ăn Gì, shake a wish out of Wishjar.