Skip to content

fig. SSystem design

Bengaluru--:-- IST

How systems hold up, drawn out.

A working notebook: each concept as a drawing you can play and step through, the trade-off it costs, and where it carries real traffic in the projects I've shipped.

fig. S.1concept atlas

Sixteen ideas, each with a bill.

  • Scale · 4
  • Data · 4
  • Async & real-time · 2
  • Resilience · 3
  • Security · 1
  • Delivery & ops · 2
fig. S.1.03 — scale03 / 16

Caching (cache-aside)

Keep hot, expensive-to-compute answers in memory next to the app, and only fall through to the database on a miss.

ClientGET /workspace/42FastAPIcache-asideRedisTTL 300sPostgreSQLsource of truth

The answer is already in memory.

01 / 04

How it works

  1. 01Read: check the cache; on a hit return it, on a miss query the database and write the result back with a TTL.
  2. 02Write: update the database first, then delete the cache key - deleting is safer than overwriting under concurrent writers.
  3. 03TTLs bound staleness; jittered TTLs and request coalescing stop a stampede when a hot key expires.

The trade-off

There are now two copies of the truth. Every cache is a promise about how stale you are willing to be - make it explicit per key.

Reach for it when

  • Read-heavy endpoints
  • The same query runs thousands of times
  • p95 is dominated by the database

fig. S.2blueprints

The same ideas, in production.

Every shipped project drawn in one notation. Replay a request, inspect a component, or turn on a concept lens to see which parts of the system practise it.

One deployable API split into 28 domain modules with hard boundaries, a PWA client that caches aggressively and survives offline, and Redis doing triple duty as cache, pub/sub and job broker in front of PostgreSQL.

Work OS case study

fig. S.2 — architecture · work os
Modular monolith · FastAPI + Next.js PWA
01 · Client02 · Edge03 · Application04 · Async05 · Data06 · PlatformNext.js 15React 19 · App RouterReact Queryclient cache · SWRService workerPWA · offline shellNginxTLS · gzip · proxyFastAPIJWT · RBAC · routingDomain modules28 bounded contextsWebSocket hublive board updatesTask workersexports · notificationsPostgreSQL 16source of truthRedis 7cache · pub/sub · queueMonorepoapps/web · apps/apiGitHub Actionslint · type · testDocker imagesone per app · by shaCompose hosthealth-checked
  • Client
  • Cache
  • Edge / proxy
  • Service
  • Worker
  • Database
  • Platform
  • async

Flow · Read · cache hit

Opening a workspace: two caches stand between the click and the database.

01 / 07

fig. S.3concept × project

Right-sized, not over-built.

A conference site does not need a message broker; a SaaS workspace does. The empty cells are decisions too.

fig. S.4contact

Let’s build something sharp.