Rzemiosło · The Craft
What is The CraftLevelsGet startedChapters Search Download PLEN
Level 3 · Codex ~2 min read

In one sentence: Separate the layers and use feature flags, so the app grows without rewriting it from scratch.

This chapter in plain terms

A chapter about building so you can change and grow later — without rewriting everything from scratch. And about the equally important other side: don’t over-engineer. A simple architecture you know how to extend beats a distributed one you don’t need.

Three habits give you flexibility:

Separate the layers. The database, the data-fetching and the page are three separate worlds joined by a contract (an agreed format), not by shared code. Then you can Database swap — Replacing the whole production database with a new version, carrying over user accounts and data. The hardest operation in The Craft — it has its own runbook and needs explicit consent. more in the glossary → one part without touching the rest.

Change by “adding”, not “rebuilding”. A new column, a new 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 →, a new language — done so that what already works keeps working.

Hide risk behind a switch (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 →) — from the first risky change that reaches real users (not on Day 0, when there’s no one to protect yet). A new feature ships to the app turned off; you enable it first for yourself, then for a fraction, then for everyone. Without it every change is “all or nothing”.

And above all: scale when a metric forces you, not “because it’ll grow someday”. 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 → and a static site carry a surprising amount of traffic; you move to heavier solutions when the numbers (cost, latency, database size) demand it — deliberately, with a written rationale.

Example: microservices and Kubernetes for an app with a hundred users is premature complexity — you add the network and a new class of failures and gain nothing. Start with a 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 → (one application).

Read more: feature toggles (Martin Fowler) · “monolith first” · scalability.

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

  1. 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.
  2. 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.
  3. 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.
  4. Keep the process stateless where you can; sessions and state go to a store (→ 14).
  5. 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 →.
  6. 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.
  7. 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).
  8. 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).
  9. 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.
Chapter deep-dive 12Why these rules, examples and stories from projects — what the core deliberately leaves out.

The canonical doctrine is written in English.