12 — Flexibility and scalability
The golden rule of altitude applied to architecture: change without a rewrite, grow without a rebuild — and scale only when a metric demands it, never “just in case”.
Rules
- Separate the layers by a contract, not by shared code: data ↔ ingest ↔ web, bound by the schema (→ 11) or an explicit API — An agreed way for two programs to talk to each other — one asks, the other answers in a set format. Through an API your app connects to outside services (payments, maps, AI). Treat an API key like a password. more in the glossary → contract. Either side can then be replaced.
- Changes are additive and backward-compatible: a new column, Endpoint — A single “address” in an API you send a request to for a specific thing (e.g. the list of orders). Apps talk through endpoints — one endpoint = one function you expose. more in the glossary → or language doesn’t break what works.
- Feature flag — An internal switch that turns a new feature on for some people, or off, without reworking the code. You roll a novelty out gradually and roll it back in a second — the cheapest insurance with any change. more in the glossary → arrive with the first risky change that reaches live users — ship dark, then ramp. Not on Day 0 of a prototype; never skipped once real users are at risk.
- Keep the process stateless where you can; sessions and state go to a store (→ 14).
- Platform is a recorded trade-off: always-on VPS — A rented piece of a cloud server “just for you”, where you put an app “live”. Predictable cost and full control. One VPS easily carries a few small projects. more in the glossary → (fixed cost, no cold start) vs scale-to-zero (pay per use, cold start) — chosen by traffic profile and budget, written down as an ADR (decision record) — A short note: what we chose, why, and which alternatives we rejected (Architecture Decision Record). Six months later nobody has to guess whether a decision was deliberate and whether it’s safe to change. more in the glossary →.
- Every Cache — A temporarily remembered result, so the same thing isn’t computed again on every request. Speeds the app up, but can be a trap: a stale cache shows old data. more in the glossary → has explicit invalidation and a stated lifetime.
- Pipeline — A chain of processing steps run in order, e.g. fetch → clean → enrich → check. When each step runs on its own and repeats safely, a failure halfway doesn’t mean starting from zero. more in the glossary → are composable and Idempotency — A property of an operation you can run many times with the same result — no duplication. Key for scripts and events: a re-run doesn’t break data. Like an “ON” switch. more in the glossary →: each stage runs alone, a re-run is safe (→ 04).
- Global product = i18n from the first Commit — A saved, labelled point in the project’s history — a confirmation of a specific batch of changes. Small, described commits make a history you can return to any working state from. more in the glossary →, not bolted on (→ 10).
- Scale by the numbers: SQLite — The simplest database — the whole thing lives in one file, with no separate server. A great default to start: zero configuration, easy backup (you copy the file). As you grow, you migrate up. more in the glossary → → PostgreSQL — A solid, “grown-up” database for bigger apps — runs as a separate server. The default step after SQLite, when you need many concurrent users and advanced features. more in the glossary →, Monolith — An app built as one whole (one deploy, one database), not a patchwork of separate services. A simple, cheap default to start — easy to grasp. You split it only when scale really demands. more in the glossary → → services, only when latency, cost or size measurably demand it — with an ADR (→ 13).
Anti-patterns
- 🚫 Microservices, Kafka or Kubernetes for a hundred users.
- 🚫 State in process memory that blocks restarts and scaling.
- 🚫 A big-bang rewrite instead of additive steps.
- 🚫 A risky change for live users with no flag and no ramp.
- 🚫 Migrating to PostgreSQL “just in case” while SQLite hasn’t broken a sweat.