Expand description
Archify architecture-diagram JSON exporter (seeded, grouped, tier-typed). Archify architecture-diagram exporter.
Turns a seeded, depth-limited code subgraph into
Archify architecture diagram JSON.
sqry supplies the code-grounded facts (real symbols, kinds, files,
languages, calls, HTTP/DB/queue edges); Archify owns the presentation layer
(themed HTML/SVG rendering). This module is the bridge and adds no new graph
facts, node kinds, or edge kinds.
§What it emits
A typed model (Section “Emission model”) that mirrors Archify’s schema
exactly, so invalid diagram types, component types, card colours, or extra
fields are unrepresentable. Symbols group into tier-typed components and
package boundaries; retained edges aggregate into connections; summary
cards explain the picture; a deterministic grid layout fixes placement
with no pixel math.
§Independent edge retention (decoupled)
[archify_classify_edge] is this module’s own edge-retention policy. It
retains the semantically rich cross-service edges (HttpRequest, DbQuery,
MessageQueue, …) that the raw dot / d2 / mermaid / json exporters
intentionally drop. It does not touch, widen, or share the MCP export
walk’s classify_edge_for_export, so those existing formats are provably
unchanged by this feature.
§Determinism
Same graph + same seeds + same limits produce byte-identical JSON, including
across parallel graph rebuilds. Every ordering is explicit: the seeded walk
([super::subgraph]) is deterministic, component ids are assigned in sorted
cluster-key order with stable collision suffixing, connections sort by
(from, to), grid columns follow stable BFS rank, and elision tie-breaks by
(degree, id).
§Confidence tiers (fail-safe inference)
Component-type inference is tiered. High-confidence types are code-evident
(a React component node, an HTTP endpoint, a DB target). Medium/Fallback
types are inferred and degrade to backend / external, are tagged
inferred with their basis in the sublabel, and are listed in an “Inferred
tiers” card. Low-confidence cloud / security name heuristics are
deliberately deferred in v1 (never emitted); such clusters fall back to
backend / external.
Structs§
- Archify
Boundary - A package/region boundary wrapping component ids.
- Archify
Build Meta - An Archify document plus the seeded-walk signals (
ArchifyBuildMeta) callers need to report accuratetruncated/totalfields, instead of hardcoding them (the walk itself is the only place that knows whethermax_resultswas hit). - Archify
Card - A summary card.
- Archify
Component - A single architecture component.
- Archify
Config - Archify exporter configuration.
- Archify
Connection - An aggregated connection between two components.
- Archify
Document - Top-level Archify architecture document.
- Archify
Layout - Grid layout descriptor (
mode: "grid"only). - Archify
Meta - Diagram metadata block.
Enums§
- Archify
Edge Class - Archify connection category for a retained edge.
- Archify
Error - Fail-closed self-validation errors. The exporter returns one of these rather than write a malformed diagram to disk.
- Boundary
Kind - Archify boundary kind.
- CardDot
- Archify card accent colour.
- Component
Type - Archify component tier type (the seven schema
componentTypevalues). - Variant
- Archify connection visual variant.
Constants§
- ARCHIFY_
SCHEMA_ VERSION - Archify JSON schema contract version this exporter targets.
- DEFAULT_
MAX_ COMPONENTS - Default cap on the number of emitted components after grouping.
- GRID_
COL_ CAP - Archify grid layout hard column cap (schema:
colsin1..=12).
Functions§
- archify_
classify_ edge - The Archify edge-retention policy: independent from the raw exporters.
- build_
archify_ document - Build an Archify architecture document from concrete seeds.
- build_
archify_ document_ with_ meta - Build an Archify document, also returning the seeded-walk’s truncation/total signals.
- export_
archify_ json - Build an Archify document and serialize it to pretty JSON bytes-string.