Architecture observability (`pnpm arch:*`)
This repository treats **architecture as an observability surface**: reports and diagrams are generated from **source**, **workspace layout**, **TypeScript AST*
This repository treats architecture as an observability surface: reports and diagrams are generated from source, workspace layout, TypeScript AST, TypeDoc, dependency-cruiser, and seed configs — not from hand-drawn diagrams or unverifiable AI prose.
Why this exists
- Index, don’t replace, reading code. The goal is to answer “where is the hub?”, “which hook is heavy?”, “how do props flow?”, and “what does the app contract expose?” without opening every file.
- Honest uncertainty. Outputs marked heuristic, seed, or needs manual review are approximations. They must not be treated as ground truth without verification.
What arch:all does and does not do
pnpm arch:allruns one-shot generators (CLI completes). It does not start dev servers.- UI / Storybook for visual component work: use
pnpm dev:ui(same as@prox-os/ui-workshopStorybook). Optional alias:pnpm arch:ui→pnpm dev:ui. Storybook is intentionally not part ofarch:all.
Command reference
| Command | Output / behavior |
|---|---|
pnpm arch:file-graph | docs/architecture/generated/file-graph.dot; file-graph.svg if Graphviz dot is installed; copies to docs/architecture/dependency-graph.svg when SVG succeeds |
pnpm arch:code-symbols | generated/code-symbols.{md,json} — per-file exports, hooks, types, imports (ts-morph) |
pnpm arch:hook-complexity | generated/hook-complexity.md — metrics for use*.ts(x) |
pnpm arch:props-flow | generated/props-flow.{md,mmd} (+ optional .svg) — static JSX approximation |
pnpm arch:c4 | generated/c4-container.{mmd} (+ optional .svg) — workspace discovery + scripts/arch/c4-external.seed.json for external systems |
pnpm arch:state | generated/state-ownership.{md,mmd} (+ optional .svg) — regex/pattern buckets (manual review) |
pnpm arch:capabilities | generated/app-capabilities.{md,mmd} — contract vs forbidden shell imports in packages/os-apps |
pnpm arch:api | TypeDoc HTML → generated/api/ (entry: packages/app-contract/src/index.ts, options: root typedoc.json) |
pnpm arch:api:json | TypeDoc JSON → generated/api.json |
pnpm arch:unused | Knip (human-readable) |
pnpm arch:unused:json | generated/knip.json (always exit 0 via --no-exit-code; still review findings) |
pnpm arch:flow:* | generated/mmd/flows/<scenario>.{mmd,md} (+ optional .svg) — seed sequence diagrams |
pnpm arch:perf:report | generated/performance/*.md templates — no auto profiling |
pnpm arch:generated:index | Writes generated/index.html — lists outputs (TypeDoc is one link to api/index.html, not every file under api/) |
pnpm arch:generated:serve | Refreshes that index, then serves the folder on http://localhost:4000 (serve -l 4000) |
pnpm arch:check | dependency-cruiser rules (no file outputs) |
pnpm arch:update | deps.dot + file graph + circular report |
pnpm arch:all | Core static pipeline (see root package.json) |
Data sources (what is “real” vs “seed”)
| Source | Used by |
|---|---|
Files under apps/, packages/, tools/ | code-symbols, hook complexity, props-flow, state heuristics |
pnpm-workspace.yaml, package package.json files | C4 script |
packages/app-contract/src/index.ts | TypeDoc |
| dependency-cruiser | arch:file-graph, arch:check |
scripts/arch/c4-external.seed.json | external systems on C4 diagram (not inferable from imports alone) |
| Default strings | runtime-flow scenarios (upgrade: Playwright trace + optional window.__PROX_OS_ARCH_TRACE__ — not injected into app code in v1) |
C4 v1: roughly workspace auto-discovery plus a small seed for externals (Cloudflare, Neon, etc.). The split is intentional: external systems cannot be proven from repo imports alone.
AI-readable artifacts
- Markdown / JSON under
docs/architecture/generated/are suitable for tools and agents. They are not copied intoapps/docsbypnpm docs:sync(thegenerated/tree is excluded on purpose). Human-authored Markdown and MDX elsewhere under rootdocs/is mirrored into the docs app. - Mermaid
.mmdcan be pasted into viewers or rendered with@mermaid-js/mermaid-cli(mmdc). Ifmmdcfails (e.g. Chromium /pnpm approve-builds),.mmdremains the source of truth. - TypeDoc
api.jsonreflects the app contract public types.
Do not treat PNG screenshots or draw.io exports as canonical architecture assets for this pipeline.
Knip: classification before any delete
Knip reports are candidates, not orders. Do not bulk-delete based on JSON output.
| Category | Action |
|---|---|
| Safe delete | Only after proof: unused local helper, truly unused dependency, clearly abandoned temp file |
| Public API keep | app-contract exports, manifest types, package exports fields |
| Dynamic entry keep | App registry, localAppComponents, iframe/dev apps, Storybook stories, docs entry, config-only imports |
| Needs manual review | Anything unclear — especially “unused export” in boundary packages |
Local dependencies
- Graphviz
dot: required for SVG fromarch:file-graph. Without it, you still getfile-graph.dot. mmdc: optional for SVG from Mermaid.@mermaid-js/mermaid-cliuses Puppeteer and needs a Chrome build. Ifmmdcerrors with Could not find Chrome, run e.g.pnpm exec puppeteer browsers install chrome-headless-shell(or follow Puppeteer’s docs for your environment). You may also needpnpm approve-buildsafter adding the CLI..mmdfiles remain valid without SVG.
Future work
- Wire Playwright traces and optional
archTraceinstrumentation to replace or enrich seedarch:flow:*diagrams. - Surface
generated/*in the in-shell Architecture app as read-only artifacts.