The things every feature needs and no feature owns.
~5,600 words across 7 notes. Built August 2026 — this section was a map pointing elsewhere until then, and one row of that map said “file uploads — not covered anywhere yet — a genuine gap.” That’s note 07.
The one idea: each of these is needed by every feature, which means each should be solved once, centrally, and applied by convention. When the same try/catch or the same permission check is pasted into twenty handlers, a cross-cutting concern has escaped into feature code — and that’s what middleware, filters and interceptors exist to prevent.
Reading order
- Validation and DTOs — [Intermediate] — parse, don’t validate, why the boundary is the only place, and what a DTO actually protects you from
- Configuration and Secrets — [Intermediate] — layering, validating config at startup, why secrets differ from config, and feature flags that never die
- Error Handling — [Intermediate] — one handler at the edge,
ProblemDetails, the status-code map, and the line between what the client sees and what you log - Rate Limiting — [Intermediate] — the four algorithms, what to key on, and why in-process limiting silently doesn’t work
- Idempotency and Retries — [Intermediate] — a timeout doesn’t tell you whether it happened, idempotency keys, backoff with jitter, circuit breakers
- Security Headers and CORS — [Intermediate] — the nearly-free headers, CSP properly, and what CORS actually protects (not your server)
- File Uploads — [Intermediate] — presigned URLs, magic-byte validation, decompression bombs, and the checklist
The things worth carrying
- After your check, can a downstream function still receive bad data? If yes, you validated rather than parsed → 01
- Returning your database entity directly is how
passwordHashreaches a client → 01 - Validate all config at startup. A container that refuses to boot beats one that fails at 3 a.m. → 02
- A leaked secret is not fixed by deleting the commit. Rotate first → 02
- 401 means “I don’t know who you are”; 403 means “I know, and no.” And 403 on a resource that exists confirms it exists → 03
- Log the exception object, not
ex.Message→ 03 - In-process rate limiting multiplies your limit by your instance count → 04
- Behind a proxy you rate-limit your own load balancer unless forwarded headers are configured → 04
- Three outcomes, not two: succeeded, failed, and unknown → 05
- Retry at one layer. Three layers × 3 retries is 27 requests to a struggling database → 05
- Jitter, or an outage recovery becomes a retry storm → 05
- CORS protects your users’ other tabs, not your server. A CORS error means the request probably ran → 06
- Extension and
Content-Typeare client-supplied text. Check magic bytes → 07
Still covered elsewhere, deliberately
Not everything cross-cutting belongs here — some of it has a better home and this section links rather than duplicates:
| Concern | Where |
|---|---|
| Caching | caching — strategies, stampede, penetration |
| Logging & observability | observability · what to log |
| Background jobs | messaging & async |
| Auth itself | 05-auth — flows, authorization, OAuth |
| Secret storage | secret management |
Per language
These notes are stack-agnostic on purpose. For the implementations side by side — rate limiting, auth, headers, graceful shutdown in six stacks — see cross-language recipes.
Related
Software engineering
Infrastructure & security
Computer science
Hardware & engineering