Ăn Gì and Wishjar in the C4 Model, Including What Won't Scale Yet
C4 diagrams of two side projects I run in production: where state lives, how paid APIs are capped, and what would break first at ten times the traffic.
Writing
How to structure source code so it survives growth, teams, and change.
Software architecture and source-code structure, explained with diagrams: Ports & Adapters, Clean Architecture, dependencies, module boundaries and trade-offs.
C4 diagrams of two side projects I run in production: where state lives, how paid APIs are capped, and what would break first at ten times the traffic.
Before you draw a box: the questions that change a design, a one-minute scale estimate, how to say assumptions out loud and where the gaps between boxes hide.
Defaults decide what happens when nobody decides. How to pick ones that fail safely: closed for access, off for new flags, explicit timeouts, and fallbacks you can see.
Wide data contracts get depended on in ways nobody planned. How to keep APIs and events small: one meaning per field, consumer-driven tests and safe schema changes.
Why good module boundaries look plain: each change lands in one place, no flag-stuffed abstractions, lines follow language and teams, and a clear rule for what crosses.
Every production system needs emergency paths. How to build ones that are narrow, logged and rehearsed, so the 2 a.m. fix never becomes a hidden back door.
Slow, partial, stale or uncertain: how to show real system limits on screen, what the backend must track to do it, and how to word the message so users trust it.
Every abstraction has a running cost. How to find the changes your code has really seen, where flexibility pays off, and when a short note beats another layer.
A layer name on a diagram feels clear until the first real ticket arrives. Concrete examples show who owns what, what may cross and where a boundary sits wrong.
Big architecture decisions are hard to undo. How to spot the one-way doors, split the rest into small records, and write down the signal that says it's time to revisit.
How to design an interface that survives rewrites: hide what's likely to change, mind Hyrum's Law, publish late, test the promise, evolve it without breaking callers.
Trace one business rule, pin its behavior with characterization tests, give it one home and one name, and ship small refactors that make the next change easy.
Code shows a system's shape but never the reason. A one-page decision record keeps the context, the options you rejected and the signal that says to revisit it.
Before you pick a queue, a database or a framework, name who owns each rule, what must stay consistent and which words mean different things. Then pick tools.
Whether production can explain itself depends on choices made before release: event names, one trace ID through every hop, and alerts that point at user pain.
Why saving to the database and then publishing to a broker can lose events, how a transactional outbox closes the gap, and what relays and consumers still need.
What a service mesh really does, what it can't fix, which production numbers to pull first, the failures it adds and how to pilot one with a rollback.
Event Sourcing stores every change as an event and rebuilds state from that history. How it works, what it buys you, what it costs, and where plain CRUD is fine.
CQRS separates the code that changes data from the code that reads it. Where the idea came from, what each side looks like, and how far to split before it costs too much.
Serverless takes servers off your plate and moves work to retries, limits, cold starts and the bill. What you still own, with real Lambda numbers, and when to skip it.
Cache-aside, read-through, write-through and write-behind compared, plus TTLs, invalidation order, stampedes and the metrics that show a cache actually helps.
Sharding splits one database across many. When it's worth the cost, how to pick a shard key that avoids hot spots, and what gets harder: joins, transactions, rebalancing.
REST gives you resources and HTTP caching almost for free. GraphQL lets each screen ask for its exact shape and moves the cost to the server. How to choose.
Retries and double clicks are normal. How idempotency keys, request fingerprints, conditional updates and boring responses keep one payment from becoming two.
What to count, which algorithm to pick, how to word a 429, and why client retries matter as much as server limits, with real numbers from Stripe, GitHub and Cloudflare.
A saga splits one business transaction into local steps, each with a way back. How to order steps around the pivot, choose orchestration or choreography and debug it.
What an API gateway should own (routing, token checks, rate limits, tracing), when a BFF earns its keep, and how to keep the gateway from becoming your next monolith.
One refund button, built the hexagonal way: write the rule as a sentence, name ports after the feature, test the core with fakes, and know when to skip it.
Eventual consistency from the user's side: how stale each feature may be, how the screen should say pending, and how to catch data that never catches up.
Dependency direction is one rule about who may know what: business rules don't import frameworks, databases or vendor SDKs. A refund example shows why it pays off.
Layered code groups files by kind; vertical slices group them by request. How each shapes coupling, when sharing pays off, and how to switch one feature at a time.
Microservices give teams room to move, and the bill comes in operations, data, observability, testing and coordination. What each line costs and how to tell you're ready.
Before you shard, read the query plan. The order that works for scaling a database: indexes, a bigger box, read replicas, a cache, then sharding, and what each costs.
When one request crosses ten services, no single log tells the story. Trace IDs, RED metrics, SLOs, burn-rate alerts and sampling, explained with sources.
When to call a service and when to publish an event, what brokers really guarantee, how to survive duplicate messages, and when events only add complexity.
When services stop sharing a database, you lose JOINs and cross-service transactions. Here's who should own what, and which pattern fills each gap.
A call that leaves your process can hang, fail or run twice. How timeouts, jittered retries, idempotency keys and circuit breakers stop that failure from spreading.
Hexagonal architecture in plain words: what Cockburn meant by ports and adapters, the one dependency rule behind it, and how much of it your codebase really needs.
Hexagonal, Onion and Clean Architecture share one rule: dependencies point inward. What each one adds, how their terms map, and how much your team needs.
DI is one small move: stop letting a class build its own dependencies and hand them in. Constructor injection, the composition root, containers and the usual traps.
Your top-level folders decide how many places one change touches. When layer-first is fine, when feature or domain folders win, and how to keep boundaries honest.
Most teams should start with a monolith, enforce module boundaries next, and split out services only when team or scaling pain is real. Here's how to tell.
Micro-frontends let each team ship its own slice of the UI. How the pieces get stitched together, what it really costs to run, and when a tidy monorepo is enough.