Skip to content

docs(architecture): add mermaid architecture diagrams - #7

Merged
cms-release[bot] merged 1 commit into
mainfrom
assembly/2
Nov 2, 2026
Merged

cms-release[bot] merged 1 commit into
mainfrom
assembly/2

Conversation

@cms-looper

@cms-looper cms-looper Bot commented Oct 30, 2026

Copy link
Copy Markdown

🎯 Changes

Adds docs/architecture/overview.md, which has five Mermaid diagrams, adds a short summary diagram to the README, and links the new sections from the existing architecture pages. This PR changes docs only, so it has no changeset.

  • Overview: cmsVirtualRoutes(), the admin routes, /api/cms/v1, /api/mcp, WebMCP (/api/cms), the in-app content agent (agentChat), the ops registry in @tanstack/cms-api, and @tanstack/cms-core.
  • Data loading: in-process server functions from @tanstack/cms-api/start, and createCmsCollectionOptions() from @tanstack/cms-client/db reading through listPublishedDocuments into a live collection. That collection is joined with another service's collection in useLiveQuery. Markdown is read-only via markdownStorage(), or read directly with loadMarkdownDir().
  • Data storage: the StorageAdapter boundary (sqliteStorage, d1Storage, markdownStorage, postgresStorage from @tanstack/cms-store-postgres, libsqlStorage from @tanstack/cms-store-libsql, and per-collection collection.storage). The MediaAdapter side covers localMedia, s3Media from @tanstack/cms-media-s3, and optional sharp.
  • Mutations: a sequence diagram that follows the code. products.update calls onUpdate, then saveDoc with publish: true and expectedRevision, then an access check. From there the write goes one of two ways:
    • Staged with stageWrite().
    • Committed with commitDocument(), which runs preValidate, schema validation, field rules and postValidate. It then opens a transaction that re-checks access and the revision, writes the document, records a revision, and adds events and webhooks to the outbox. After that come afterChange, delivery of webhooks/events after commit, and a TanStack DB rollback if a CmsError is thrown.
  • Agent writes and review: content-agent, MCP and WebMCP calls go through cmsTools()/ops into stageWrite() and then the review queue. From there, approveChange publishes or keeps the document as a draft, rejectChange drops it, and a draft with a due publishAt is published by runScheduledPublishing().

Acceptance checklist

  • Five Mermaid diagrams under their own headings: docs/architecture/overview.md (Overview, Data Loading, Data Storage, Mutations, Agent Writes and Review)
  • README "Built on TanStack Start and TanStack DB" section has a summary diagram and a link: README.md
  • Every name in the diagrams exists on main. I checked them against packages/ui-react/src/virtual-routes.ts, packages/api/src/{ops,start,mcp,markdown}.ts, packages/client/src/db.ts, packages/core/src/server/store/{write,review,scheduling}.ts, packages/core/src/server/{outbox,cms-tools}.ts, packages/core/src/{storage,media}.ts, and the store/media package entry points.
  • Registered in docs/config.json under "Architecture & Auth" (addedAt: 2026-10-29). docs/architecture/data-layer.md links to #data-loading and #mutations, and docs/architecture/storage.md links to #data-storage.
  • Every Mermaid block parses. I checked the syntax by hand: quoted labels, pipe-form dotted edges, no reserved node ids. I couldn't run a parser locally, so please confirm in the GitHub rich diff preview.
  • pnpm test:docs and pnpm test:pr pass locally. The root targets test:sherif, test:knip, test:docs and test:kiira all passed, and kiira checked 124 snippets with 0 failures.

Where the request and the code differ (documented here, not fixed)

  • The issue describes the agent flow as "draft -> review -> publish". In the code, a draft is a publisher's private working copy and never enters the review queue. Agent and author writes are staged pending changes instead. The diagram shows the code's behavior: staged, then reviewed, then approved (publish or keep as draft), with scheduled publish for drafts that have a publishAt.
  • Webhooks are not sent inside saveDoc. They are written to the transactional outbox inside the commit transaction and delivered by the dispatcher after commit, and the diagram shows it that way.
  • The README "Pluggable storage and media" feature bullet doesn't mention @tanstack/cms-store-postgres, although the package exists. I left that prose unchanged because rewriting it is out of scope.
  • pnpm format (oxfmt) reformats about 48 unrelated source files on main. I didn't include those changes.

Closes #2

✅ Checklist

  • I have followed the steps in the Contributing guide.
  • I have tested code changes locally with pnpm run test:pr, or these tests do not apply to this pull request.
  • I fully understand the code in this pull request, including any code generated with AI assistance.
  • Docs: I updated docs/ for this change, or this change is not user-facing.
  • Changeset: I added a changeset (pnpm changeset), or this PR does not change a published package.

🚀 Release Impact

  • This change affects published code, and I have generated a changeset.
  • This change is docs/CI/dev-only (no release).

🤖 Generated with Claude Code

Add docs/architecture/overview.md with overview, data loading, storage,
mutations, and agent review diagrams, a summary diagram in the README,
and links from data-layer.md and storage.md.

Closes #2

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@cms-looper cms-looper Bot added state:in-progress The looper is working it risk:two-way Easily reversed labels Oct 30, 2026
@changeset-bot

changeset-bot Bot commented Oct 30, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 12b48ab

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai

coderabbitai Bot commented Oct 30, 2026

Copy link
Copy Markdown

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

Run configuration
  • Source mode: Auto
  • Repository: TanStack/cms
  • Branch: main
  • File: .coderabbit.yaml
  • Commit: 8d7f448
  • Layers: Repository YAML
  • Review profile: CHILL
  • Plan: Free
  • Run ID: 686cff3b-04a4-4f4f-8753-61387b91e4f6

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@cms-looper

cms-looper Bot commented Oct 30, 2026

Copy link
Copy Markdown
Author
handoff:
  from: looper
  to: looper
  issue: 2
  pr: 7
  attempt: 1
  risk: two-way
  risk_reasons:
    - docs-only
  summary: Add Mermaid architecture diagrams (overview, data loading, storage, mutations, agent review) to docs/architecture/overview.md with a summary diagram in the README
  acceptance:
    - "docs/architecture/overview.md contains five mermaid diagrams under their own headings: Overview (cmsVirtualRoutes, @tanstack/cms-api operations registry, admin UI, app loaders/components, HTTP /api/cms/v1, MCP /api/mcp, WebMCP, in-app content agent); Data loading (in-process Start server functions via @tanstack/cms-api/start, createCmsCollectionOptions from @tanstack/cms-client/db into a live TanStack DB collection with useLiveQuery including a join with another service, read-only markdownStorage()/loadMarkdownDir()); Data storage (storage adapter boundary in @tanstack/cms-core with sqliteStorage, d1Storage, markdownStorage, cms-store-postgres, cms-store-libsql, per-collection storage, media via local disk / cms-media-s3 / sharp); Mutations (optimistic products.update -> saveDoc -> CMS operations with validation, access rules, optimistic concurrency, revisions, hooks, webhooks, and rollback on failure); Agent writes and review (agent/MCP writes into the review queue, draft -> review -> publish, scheduled publish)"
    - The README "Built on TanStack Start and TanStack DB" section gains one short summary mermaid diagram and a link to docs/architecture/overview.md
    - Every function, package, route and option named in a diagram exists on main under that exact name, and no diagram shows a step the code doesn't perform (follow packages/api/src/ops.ts and packages/core when unsure)
    - The new page is registered in docs/config.json under "Architecture & Auth", and docs/architecture/data-layer.md and storage.md link to the relevant diagram section
    - Every mermaid block parses without error (Mermaid Live Editor or GitHub preview)
    - pnpm test:docs and pnpm test:pr pass
  out_of_scope:
    - Any change to source code, exports, APIs or behaviour; document code/doc mismatches in the PR description instead of fixing them
    - Rewriting existing README or architecture prose beyond adding the diagrams and links
    - PNG/SVG diagram assets, new tooling or dependencies
    - Changes under .github/** and changesets
  notes_for_next: >-
    Docs only (README.md, docs/config.json, docs/architecture/{overview,data-layer,storage}.md).
    Mermaid syntax was checked by hand only. No parser could be installed locally, so check the
    GitHub rich-diff render of overview.md and README.md. The Mutations sequence diagram follows
    saveAsHuman in packages/api/src/ops.ts and commitDocument in packages/core/src/server/store/write.ts.
    The agent-review diagram shows staged -> review -> approve (publish or draft) -> runScheduledPublishing,
    not the issue's "draft -> review -> publish", because drafts never enter the queue in code.
    The PR description lists this and the other mismatches.

Opened PR #7. CI was verified locally: pnpm test:pr passed (Successfully ran targets test:sherif, test:knip, test:docs, test:kiira for project root, and kiira checked 124 snippets with 0 failures). pnpm format reformatted about 48 unrelated source files that aren't formatted on main. I left those out of the PR.

@jherr jherr added the state:changes-requested Review sent the PR back to the looper label Oct 30, 2026
@cms-looper cms-looper Bot added state:needs-qa PR ready for QA and removed state:in-progress The looper is working it state:changes-requested Review sent the PR back to the looper labels Oct 30, 2026
@cms-looper

cms-looper Bot commented Oct 30, 2026

Copy link
Copy Markdown
Author
handoff:
  from: looper
  to: qa
  issue: 2
  pr: 7
  attempt: 2
  risk: two-way
  risk_reasons:
    - docs-only
  summary: Add Mermaid architecture diagrams (overview, data loading, storage, mutations, agent review) to docs/architecture/overview.md with a summary diagram in the README
  acceptance:
    - "docs/architecture/overview.md contains five mermaid diagrams under their own headings: Overview (cmsVirtualRoutes, @tanstack/cms-api operations registry, admin UI, app loaders/components, HTTP /api/cms/v1, MCP /api/mcp, WebMCP, in-app content agent); Data loading (in-process Start server functions via @tanstack/cms-api/start, createCmsCollectionOptions from @tanstack/cms-client/db into a live TanStack DB collection with useLiveQuery including a join with another service, read-only markdownStorage()/loadMarkdownDir()); Data storage (storage adapter boundary in @tanstack/cms-core with sqliteStorage, d1Storage, markdownStorage, cms-store-postgres, cms-store-libsql, per-collection storage, media via local disk / cms-media-s3 / sharp); Mutations (optimistic products.update -> saveDoc -> CMS operations with validation, access rules, optimistic concurrency, revisions, hooks, webhooks, and rollback on failure); Agent writes and review (agent/MCP writes into the review queue, draft -> review -> publish, scheduled publish)"
    - The README "Built on TanStack Start and TanStack DB" section gains one short summary mermaid diagram and a link to docs/architecture/overview.md
    - Every function, package, route and option named in a diagram exists on main under that exact name, and no diagram shows a step the code doesn't perform (follow packages/api/src/ops.ts and packages/core when unsure)
    - The new page is registered in docs/config.json under "Architecture & Auth", and docs/architecture/data-layer.md and storage.md link to the relevant diagram section
    - Every mermaid block parses without error (Mermaid Live Editor or GitHub preview)
    - pnpm test:docs and pnpm test:pr pass
  out_of_scope:
    - Any change to source code, exports, APIs or behaviour; document code/doc mismatches in the PR description instead of fixing them
    - Rewriting existing README or architecture prose beyond adding the diagrams and links
    - PNG/SVG diagram assets, new tooling or dependencies
    - Changes under .github/** and changesets
  notes_for_next: >-
    No code changed in this run. Mermaid syntax has still only been checked by hand, so please check the
    GitHub rich-diff render of docs/architecture/overview.md (5 diagrams) and README.md. Then spot-check the
    names in the diagrams against main: cmsVirtualRoutes, createCmsCollectionOptions, loadMarkdownDir,
    stageWrite, commitDocument, approveChange/rejectChange, runScheduledPublishing, cmsTools, postgresStorage,
    libsqlStorage, localMedia, s3Media. The agent-review diagram intentionally differs from the issue's
    "draft -> review -> publish"; the PR description explains why.

@jherr added state:changes-requested without a review or comment, so I had nothing specific to fix. I treated the label as a restart: the previous run handed off to looper and expected a CodeRabbit review, but CodeRabbit skipped this PR ("Bot user detected"). If you meant to ask for specific changes, please leave them as review comments and re-add the label.

CI was verified locally with pnpm test:pr: Successfully ran targets test:sherif, test:knip, test:docs, test:kiira for project root (docs link check: no broken links in 41 files).

@jherr jherr added state:needs-qa PR ready for QA and removed state:needs-qa PR ready for QA labels Nov 2, 2026
@tanstack-cms-qa tanstack-cms-qa Bot added state:needs-human The line stopped; a human decides and removed state:needs-qa PR ready for QA labels Nov 2, 2026
@tanstack-cms-qa

Copy link
Copy Markdown
handoff:
  from: qa
  to: human
  issue: 2
  pr: 7
  attempt: 2
  risk: two-way
  risk_reasons: [docs-only]
  summary: Add Mermaid architecture diagrams (overview, data loading, storage, mutations, agent review) to docs/architecture/overview.md with a summary diagram in the README
  acceptance:
    - "docs/architecture/overview.md contains five mermaid diagrams under their own headings (Overview, Data loading, Data storage, Mutations, Agent writes and review)"
    - "README section gains one short summary mermaid diagram and a link to docs/architecture/overview.md"
    - "Every function, package, route and option named in a diagram exists on main under that exact name, and no diagram shows a step the code doesn't perform"
    - "The new page is registered in docs/config.json under Architecture & Auth, and data-layer.md and storage.md link to the relevant diagram section"
    - "Every mermaid block parses without error"
    - "pnpm test:docs and pnpm test:pr pass"
  out_of_scope:
    - Any change to source code, exports, APIs or behaviour
    - Rewriting existing README or architecture prose beyond the diagrams and links
    - PNG/SVG assets, new tooling or dependencies
    - Changes under .github/** and changesets
  notes_for_next: Everything I could run passed. The one open item is that no Mermaid parser could run here, so please look at the GitHub rich-diff render of docs/architecture/overview.md (5 diagrams) and README.md (1 diagram). If they render, this is ready for review.

QA report

The PR is docs-only (~/assembly/bin/docs-only 7 exited 0) and risk stays two-way. The changed files are README.md, three files under docs/architecture/, and docs/config.json. No example sites were started.

I couldn't confirm that the Mermaid blocks parse, so I'm handing this to a human instead of passing it.

Criterion Check run Result Evidence
Five diagrams in overview.md Extracted mermaid fences with a script pass 5 blocks found
README summary diagram and link Same extraction on README.md pass 1 block found. I didn't separately check the link.
Names exist on main Grep of function definitions under packages/*/src pass for functions All these are defined: cmsVirtualRoutes, createCmsCollectionOptions, loadMarkdownDir, stageWrite, commitDocument, approveChange, rejectChange, runScheduledPublishing, cmsTools, postgresStorage, libsqlStorage, localMedia, s3Media, listPublishedDocuments, agentChat, markdownStorage, d1Storage, sqliteStorage
No diagram step the code doesn't perform — not checked I did not step through ops.ts and the store code against each diagram's flow. The PR description documents its deviations from the issue.
config.json registration and doc links — not checked I did not open these files. The link check below passes, so any anchors it resolves are valid.
Every Mermaid block parses pnpm dlx @mermaid-js/mermaid-cli not checked The install failed with ERR_PNPM_TRUST_DOWNGRADE for chromium-bidi@157.0.8090-0 (a puppeteer dependency). An npm install of mermaid into qa-runs was also blocked. This comes from the tooling, not from the PR.
pnpm test:docs and pnpm test:pr Ran both pass ✅ No broken links found! (41 markdown files). test:pr finished with sherif, knip, docs and kiira all passing, but those 4 targets were Nx cache hits rather than fresh runs.

For a human to check:

  • Mermaid parsing: the rich diff on docs/architecture/overview.md and README.md. Alternatively, run mmdc somewhere puppeteer installs cleanly. The extracted blocks are in ~/assembly/qa-runs/7/*.mmd.
  • Diagram accuracy: the Mutations and Agent writes diagrams against commitDocument and stageWrite. Only the names were checked.
  • Changeset: no changeset is needed, and none is required for a docs-only PR.

@tanstack-cms-qa tanstack-cms-qa Bot added the agent:blocked A station could not finish; see its last comment label Nov 2, 2026
@tanstack-cms-qa

Copy link
Copy Markdown

qa stopped: the run did not end with one valid handoff comment (claude exit 0). Fix the cause, remove agent:blocked, and re-add the state label to retry.

@jherr jherr added state:needs-qa PR ready for QA and removed state:needs-human The line stopped; a human decides agent:blocked A station could not finish; see its last comment labels Nov 2, 2026
@tanstack-cms-qa tanstack-cms-qa Bot added state:ready-to-merge Approved; release manager merges and removed state:needs-qa PR ready for QA labels Nov 2, 2026
@tanstack-cms-qa

Copy link
Copy Markdown
handoff:
  from: qa
  to: release
  issue: 2
  pr: 7
  attempt: 2
  risk: two-way
  risk_reasons: [docs-only]
  summary: Add Mermaid architecture diagrams (overview, data loading, storage, mutations, agent review) to docs/architecture/overview.md with a summary diagram in the README
  acceptance:
    - "docs/architecture/overview.md contains five mermaid diagrams under their own headings: Overview (cmsVirtualRoutes, @tanstack/cms-api operations registry, admin UI, app loaders/components, HTTP /api/cms/v1, MCP /api/mcp, WebMCP, in-app content agent); Data loading (in-process Start server functions via @tanstack/cms-api/start, createCmsCollectionOptions from @tanstack/cms-client/db into a live TanStack DB collection with useLiveQuery including a join with another service, read-only markdownStorage()/loadMarkdownDir()); Data storage (storage adapter boundary in @tanstack/cms-core with sqliteStorage, d1Storage, markdownStorage, cms-store-postgres, cms-store-libsql, per-collection storage, media via local disk / cms-media-s3 / sharp); Mutations (optimistic products.update -> saveDoc -> CMS operations with validation, access rules, optimistic concurrency, revisions, hooks, webhooks, and rollback on failure); Agent writes and review (agent/MCP writes into the review queue, draft -> review -> publish, scheduled publish)"
    - The README "Built on TanStack Start and TanStack DB" section gains one short summary mermaid diagram and a link to docs/architecture/overview.md
    - Every function, package, route and option named in a diagram exists on main under that exact name, and no diagram shows a step the code doesn't perform (follow packages/api/src/ops.ts and packages/core when unsure)
    - The new page is registered in docs/config.json under "Architecture & Auth", and docs/architecture/data-layer.md and storage.md link to the relevant diagram section
    - Every mermaid block parses without error (Mermaid Live Editor or GitHub preview)
    - pnpm test:docs and pnpm test:pr pass
  out_of_scope:
    - Any change to source code, exports, APIs or behaviour; document code/doc mismatches in the PR description instead of fixing them
    - Rewriting existing README or architecture prose beyond adding the diagrams and links
    - PNG/SVG diagram assets, new tooling or dependencies
    - Changes under .github/** and changesets
  notes_for_next: Docs-only (docs-only exit 0), risk two-way, no changeset needed. All six criteria pass; Mermaid blocks now verified with mermaid-check (the earlier blocker). Safe to merge under the docs-only rule.

QA report

Criterion Check Result
Five diagrams under their own headings Read docs/architecture/overview.md: Overview, Data Loading, Data Storage, Mutations, Agent Writes and Review each have one mermaid block pass
README summary diagram and link git diff main -- README.md: one flowchart plus link to ./docs/architecture/overview.md pass
Names exist in code Grep of packages/**/src: cmsVirtualRoutes, createCmsCollectionOptions, loadMarkdownDir, markdownStorage, sqliteStorage, d1Storage, postgresStorage, libsqlStorage, localMedia, s3Media, s3, runScheduledPublishing, cmsTools, commitDocument, stageWrite, listPublishedDocuments, and the approveChange/rejectChange ops with review.decide access all exist. /api/mcp, /api/cms/v1, /api/cms, /review, /agent, /content, /edit/$collection/$id routes exist. The content-agent and webmcp actors exist. pass
Registered in config.json; data-layer.md and storage.md link to sections Diff shows the entry under "Architecture & Auth", plus ./overview#data-loading, #mutations and #data-storage links. pnpm test:docs reports no broken links. pass
Mermaid blocks parse ~/assembly/bin/mermaid-check README.md docs/architecture/overview.md → 6/6 mermaid blocks render pass
pnpm test:docs and pnpm test:pr pnpm test:docs → "✅ No broken links found!". pnpm test:pr → "Successfully ran targets test:sherif, test:knip, test:docs, test:kiira". pass

Example sites: not started (docs-only PR).

Not covered by a check: the step-by-step accuracy of the Mutations sequence diagram (hook order, transaction contents) was not traced line by line through packages/core/src/server/store/write.ts. A reviewer may want to skim that diagram.

@cms-release
cms-release Bot merged commit e87be26 into main Nov 2, 2026
22 of 30 checks passed
@cms-release
cms-release Bot deleted the assembly/2 branch November 2, 2026 00:53
@cms-release

cms-release Bot commented Nov 2, 2026

Copy link
Copy Markdown

release: docs-only, two-way, QA passed on the head commit. Merged automatically.

cursor Bot pushed a commit that referenced this pull request Nov 6, 2026
…ale handling and change-set scheduling

Fixes phase 4 decisions:
- #2: the bus and webhook 'publish' event fires only when a document goes
  live; saving a live document fires the new 'update' event.
- #4: a write from another source while a change set is open is a CONFLICT
  naming it; same-source re-saves merge onto it.
- #5: a direct commit rebases an open proposal that changed other fields and
  invalidates one that changed the same field (audited discard, reason
  'stale', review.discarded to the proposer).
- #7: scheduling a live document's publish schedules its change set; live
  stays up until the scheduler sweep publishes it.

Decisions store strategy state on the change set (upgraded with migrate, or
stranded and refused until discarded; listStrandedChangeSets), and state-only
decisions are audited as 'transitioned' with from/to/effects.

Co-authored-by: jherr <jherr@pobox.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk:two-way Easily reversed state:ready-to-merge Approved; release manager merges

Projects

None yet

Development

Successfully merging this pull request may close these issues.

docs: add architecture diagrams to the README (data loading, storage, mutations)

1 participant