Declarative Design (Blueprint-driven Architecture)

Declaring 'what to build' as structured data (a blueprint) and letting a general-purpose engine build it automatically, rather than writing imperative step-by-step code for each project.

General Meaning

In imperative programming, developers write step-by-step procedural code ('run A, then run B') for every new website or feature, which quickly leads to copy-pasted code and maintenance debt as sites multiply.

In Declarative Design (Blueprint-driven Architecture), you declare the desired structure and policies as structured data (JSON or YAML)—specifying the site title, data schema, sources, and UI blocks—while a shared engine reads the blueprint to generate, build, and validate the entire artifact automatically.

Why It Matters

  • Eliminating reinvented wheels and copy-paste bugs: Avoids hand-coding repetitive websites or scrapers; improvements to the shared engine automatically benefit every site.
  • Self-documenting specifications at a glance: Both humans and AI agents can understand what a site does and what data it handles by reading a single blueprint file.
  • Fast automated pre-validation: Because the blueprint is pure data, JSON Schema validation can verify required fields, types, and policy rules before any code runs.

How the Site Factory Uses It

The Site Factory drives new site creation and data pipelines from a single design.json blueprint per repository, declaring the site name, subdomain, data schema (record.fields), collection sources (sources), extraction instructions, UI components (pages[].block such as table, detail, region, compare, calculator, and calendar), review rules, publication criteria, and even lifecycle retirement conditions (fold, e.g., halting updates if monthly pageviews stay below 1,000 after 6 months).

engine/validate_design.py validates design.json against engine/schema/design.schema.json, while engine/new_site.py and engine/build.py automatically scaffold the repository, render static HTML into site/, and generate wrangler.jsonc without hand-written HTML.

Caveats & Operational Rules

  • Never hand-edit generated output files: Manually editing site/index.html generated by build.py will be overwritten on the next build; always fix design.json or the generator engine instead.
  • Do not make the declarative DSL overly complex: Trying to make every tiny edge case configurable bloats the blueprint until it is as complex as imperative code; stick to sensible defaults and composable blocks.
  • Watch for drift between blueprints and external websites: Source URLs in design.json can rot or change HTML structure over time, so runtime verification via check_sources.py and review.py remains essential.

Related Terms

References

  • Book: Mark Richards & Neal Ford, *Fundamentals of Software Architecture*; Martin Kleppmann, *Designing Data-Intensive Applications*

Verified: 2026-11-08