Skip to content

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

Closed

Description

@jherr

Problem

The README explains the architecture in prose (Start as the runtime, TanStack DB as the data layer, pluggable storage, agents going through a review queue), but it has no diagrams. A few Mermaid diagrams would make the system much easier to understand at a glance.

Acceptance criteria

  1. A new page docs/architecture/overview.md contains five fenced ```mermaid diagrams, each under its own heading:
    1. Overview: the Start app mounting the CMS via cmsVirtualRoutes(), the operations registry in @tanstack/cms-api, and the surfaces that call it: admin UI, app loaders and components, HTTP /api/cms/v1, MCP /api/mcp, WebMCP, and the in-app content agent.
    2. Data loading: in-process reads via Start server functions (@tanstack/cms-api/start, no HTTP hop); createCmsCollectionOptions() (@tanstack/cms-client/db) feeding a live TanStack DB collection queried with useLiveQuery, including a join with another service; and the read-only markdownStorage() / loadMarkdownDir() path.
    3. Data storage: the storage adapter boundary in @tanstack/cms-core with sqliteStorage(), d1Storage(), markdownStorage(), @tanstack/cms-store-postgres and @tanstack/cms-store-libsql behind it; per-collection storage; and the media path (local disk, @tanstack/cms-media-s3 for S3/R2, sharp resizing).
    4. Mutations: an optimistic TanStack DB write (products.update(...)) → saveDoc → CMS operations, showing validation, access rules, optimistic concurrency, revisions, hooks, webhooks, and rollback of the optimistic state on failure.
    5. Agent writes and review: agent/MCP writes landing in the review queue, then draft → review → publish, including scheduled publish.
  2. The README's "Built on TanStack Start and TanStack DB" section gains one short summary Mermaid diagram (the overview, or a condensed version of it) and a link to docs/architecture/overview.md.
  3. Every function, package, route and option named in a diagram exists on main under that exact name (each can be found with grep in packages/). A diagram must not show a step that the code doesn't perform; if a step's behaviour is unclear (for example, the exact order of hooks and access checks in saveDoc), follow the code in packages/api/src/ops.ts / packages/core.
  4. The new page is registered in docs/config.json under "Architecture & Auth", and the existing docs/architecture/data-layer.md and storage.md link to the relevant diagram section.
  5. Every Mermaid block is valid syntax (renders in the Mermaid Live Editor or on GitHub's markdown preview without a parse error).
  6. pnpm test:docs (link verification) passes, and so does pnpm test:pr.

Out of scope

  • Any change to source code, exports, APIs or behaviour. If a diagram exposes a mismatch between docs and code, document what the code does and note the mismatch in the PR description; don't fix the code.
  • Rewriting the existing prose in the README or the architecture docs, beyond adding the diagram and links.
  • Images or binary diagram assets (PNG/SVG) and new tooling or dependencies for diagrams.
  • Changes under .github/** and changesets (docs-only change, no package release needed).

Original report

The README explains the architecture in prose (Start as the runtime, TanStack DB as the data layer, pluggable storage, agents through a review queue), but there are no diagrams. A few visuals would make the system much easier to grasp at a glance.

Proposed diagrams

Mermaid blocks so they render on GitHub and stay editable in the repo:

  1. High-level overview: the TanStack Start app hosting the CMS (cmsVirtualRoutes()), the operations registry in @tanstack/cms-api, and the surfaces that call it (admin UI, app loaders/components, HTTP /api/cms/v1, MCP /api/mcp, WebMCP, in-app content agent).
  2. Data loading: how reads flow, both in-process via Start server functions (admin and loaders, no HTTP hop) and through createCmsCollectionOptions() into a live TanStack DB collection queried with useLiveQuery, including joins with other services and the read-only markdownStorage() / loadMarkdownDir() path.
  3. Data storage: the storage adapter boundary in @tanstack/cms-core and the adapters behind it (sqliteStorage(), d1Storage(), markdownStorage(), Postgres, libSQL/Turso), per-collection storage, and the media path (local disk, S3/R2, sharp resizing).
  4. Mutations: an optimistic TanStack DB write (e.g. products.update(...)) through saveDoc and the CMS operations, showing validation, access rules, optimistic concurrency, revisions, hooks, webhooks, and how rollback happens on failure.
  5. Agent writes and review: agent/MCP writes landing in the review queue, and the draft to review to publish flow (including scheduled publish).

Acceptance

  • Diagrams added to the README (or to docs/architecture/ with a short summary diagram and links from the README).
  • Each diagram is checked against the current code so names match real functions and packages.
  • Rendering verified on GitHub.

Activity

  1. added
    state:needs-triage
    on Oct 30, 2026
  2. added
    risk:two-way
    state:ready
    and removed
    state:needs-triage
    on Oct 30, 2026
  3. cms-triager commented on Oct 30, 2026

    @cms-triager
    handoff:
      from: triager
      to: looper
      issue: 2
      pr: null
      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. Edit README.md (lines ~29-66), add docs/architecture/overview.md, register it in
        docs/config.json (Architecture & Auth children, with addedAt 2026-10-29; see scripts/sync-docs-config.ts),
        and add links from docs/architecture/data-layer.md and storage.md. To check names, look at
        packages/ui-react/src/virtual-routes.ts (cmsVirtualRoutes), packages/api/src/{ops,start,http,mcp,markdown}.ts,
        packages/client/src/db.ts (createCmsCollectionOptions), packages/core/src/storage/{node-sqlite,d1,markdown}.ts,
        packages/core/src/server/webhooks.ts and the review-queue/scheduled-publish code in packages/core/src/server.
        docs/architecture/events-and-hooks.md describes the hook order. Test with pnpm test:docs, then pnpm test:pr.

    Triaged as a docs-only change (two-way). I couldn't read the author association from the API in this run. The author, jherr, wrote most of the commits on main, and the issue had state:needs-triage, so I treated them as a maintainer. I chose docs/architecture/overview.md plus a README summary diagram, one of the two layouts the original report offered, so the README stays short.

  4. added
    state:in-progress
    and removed
    state:ready
    on Oct 30, 2026
  5. added
    agent:blocked
    on Nov 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent:blockedrisk:two-waystate:in-progress

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions