Skip to Content
All Systems

07GovernanceType: Reference architecture

A CRM built from a spec, with checks that can fail

A Zoho CRM design where one spec defines the system, scripts build it, AI agents work from it, and every check must prove it can turn red.

Shows

  • Software Architecture
  • Business Automation
  • Applied AI

Where this comes from: Drawn from systems I've designed on Zoho. The business, names and data here are generalized. The patterns and failure modes come from real work, and the design includes what that work taught me.

On This Page

In 30 Seconds

In this approach, the Zoho CRM configuration isn't described in documents. It is defined in one spec folder under version control. Generators produce every copy that code and screens need, and scripts apply the spec to an org and read every change back. Hundreds of live checks then test that the org and its data still honor the spec, and each check has to show it can fail before it counts.

What It Guarantees

  • Each module, field, endpoint and schedule is defined in exactly one place.
  • A copy that drifts from the spec fails the offline check, at zero API cost.
  • The backend refuses to start if its endpoints disagree with the spec.
  • A configuration write counts as done only after it is read back.
  • A check counts only after it has been seen to fail on broken data.

The Problem

A common setup: a Zoho CRM with custom modules, a backend service, embedded screens and a few scheduled jobs. The same field name is typed into code, screen field maps, a server allow-list, a list of scheduled routes and the documentation. Add a field and three copies change. The fourth falls behind, and nobody notices until a screen writes to a field the code no longer reads.

Changes also happen by hand in the org. The next script that touches the same setting quietly undoes them, and the API answers success. Documents keep describing buttons that were removed last week.

Then the system has to move to another org. Zoho's documentation says a sandbox deploys only to its own parent org, so between unrelated orgs everything is rebuilt. By hand, that is slow, error-prone and impossible to repeat exactly.

AI agents raise the stakes. They write fast, so copies drift fast, unless they work from one source.

The Approach, in One Sentence

One spec folder defines the configuration, and generated copies, read-back scripts and checks proven able to fail hold the code, the org and the data to it.

Architecture

One spec, many copies, checked both ways
Spec folderModules, fields, endpoints, schedules, screens, views, access
Agent rulesSpec first; open decisions are never applied
Generate copiesCode maps, allow-lists, indexes and guides
Offline checkStale copy or broken reference fails; no API calls
Dry runLists what would change in the org
Apply to orgIdempotent scripts; every write read back
Backend startRefuses to start if endpoints disagree with spec
UI-only stepsA runbook lists each one, with the reason
As-built snapshotDefinitions and layouts pulled back into the repo
Says the same?Read-only comparison of live org against spec
Live invariantsHundreds of data rules checked against the records
Checks on checksBreak the data once, watch it turn red

Connections in this diagram

  • Agent rules → Spec folder (agents edit here)
  • Spec folder → Generate copies (one source)
  • Generate copies → Offline check (before commit)
  • Offline check → Dry run (green only)
  • Dry run → Apply to org (reviewed)
  • Apply to org → Backend start (deploy)
  • Apply to org → UI-only steps (if UI-only)
  • Apply to org → As-built snapshot (pull back)
  • As-built snapshot → Says the same? (compare)
  • Says the same? → Live invariants (then data)
  • Live invariants → Checks on checks (proven to fail)
  • Checks on checks → Spec folder (new rule)

Offline checks cost nothing and, by rule, run before every commit. Live checks spend API credits and run when needed.

Key Decisions

  1. The repo defines the configuration; it doesn't describe it

    Alternatives: configure by hand and document it, or rely on sandbox promotion. Promotion only reaches a sandbox's own parent org, and a hand rebuild can't be repeated or checked. A spec that scripts apply can run again, in another org, with other credentials, and have its schema compared afterwards.

  2. Copies are generated, never edited

    Alternative: keep copies in sync through care and review. I found one field name in dozens of code files. A screen field map fell behind because regeneration ran "when someone remembered". So one command regenerates every copy, and the offline check regenerates again and fails if anything changed. Generation also validates the spec, so a malformed schedule stops it by name instead of failing quietly at its first run.

  3. Every write is read back, from where the truth lives

    Alternative: trust the status code. In my tests, some configuration writes answered success and changed nothing, and some settings lived somewhere other than where the API reported them. That may have changed. So every deploy script re-reads what it wrote from the endpoint that owns it, and reports "200 but not applied" when they differ.

  4. Three verdicts, and checks that must bite

    Alternative: pass or fail, and trust a green suite. Each live check returns pass, fail or warn. Warn means "measured, but the right behavior isn't decided yet", so red always means broken. A check counts only after it has proved it can fail: break the data once, watch it turn red, restore it. The red result must name the broken record. A false red gets fixed as urgently as a bug, because a check that cries wolf gets ignored.

When Things Go Wrong

  • Someone edits a generated file by hand

    → The offline check regenerates it, sees the difference and fails with the file's name.

  • An endpoint exists in code but not in the spec, or the reverse

    → The backend refuses to start, so the gap is a startup error, not a 404 in front of a user. Calls from screens or the scheduler to endpoints the spec doesn't allow are refused by name.

  • A setting is changed by hand in the org

    → The next apply would undo it with a success reply. A fresh snapshot and the read-only "says the same?" comparison show the drift first.

  • A check passes because it looked at nothing

    → I've seen this more than once. A filter on the wrong name field returned an empty list, so every check below it passed on zero records. A check looked for a status value that didn't exist and counted zero. Each case became a guard. A separate check asks the inverse question: does every case the code handles have an example in the data?

  • A rebuild depends on someone's memory

    → After a full data wipe, a rebuild came out half-built, and the live checks showed it: fewer passed. The missing steps had lived only in one agent session's memory. The rebuild order is now an executable file that verifies between steps.

What the Business Gets

  • A change is made once and reaches every place that depends on it.
  • The configuration is designed to be rebuilt in another org by script, with its schema compared afterwards, instead of recreated from screenshots.
  • Documentation is generated from the spec or checked against it, so drift shows up as a failing check instead of a surprise.
  • A green check means something: it has been seen to fail.

For Engineers

How I Build Systems Like This

I start from the spec, not the org: a change goes into the spec or the data model first and is applied second. AI agents (Claude Code) do much of my hands-on build work from it, under a rules file they read at the start of every session. It says: confirm which org before any write, write the spec first, never apply a decision that is still open, add a new endpoint as one line in the spec. By rule, the offline checks run before every commit.

How I Build With AI

On LinkedIn: more notes on Zoho architecture and AI.