ADR-003: Architecture model adapter system
Status: Accepted
Date: 2026-02-27
Authors: Anders Hassis
Context
Section titled “Context”Architecture models can be written in different formats. LikeC4 uses a custom DSL (.c4 files). Structurizr uses its own workspace format. Teams choose based on existing tooling, team preferences, or ecosystem compatibility.
Erode needs to load, query, and patch architecture models regardless of format. Hardcoding support for a single format would limit adoption.
Structurizr support was initially implemented with a custom recursive-descent DSL parser (~567 lines). This was replaced by wrapping the official Structurizr CLI for reliability and reduced maintenance burden.
Decision
Section titled “Decision”Define an ArchitectureModelAdapter interface that covers all operations the pipeline needs: loading a model from a path, finding components by repository URL or ID, querying dependencies and dependents, checking if a dependency is declared, and listing relationships. Each adapter carries AdapterMetadata with format-specific display information and help text.
Two implementations exist: LikeC4Adapter and StructurizrAdapter. An AdapterFactory creates the correct one based on configuration.
Rationale
Section titled “Rationale”The adapter pattern decouples the pipeline from model format details. Adding a new format means implementing the interface without changing pipeline code.
AdapterMetadata lets each adapter provide format-specific user-facing messages (like “no component found” help text) without the pipeline knowing format details.
Consequences
Section titled “Consequences”Positive
Section titled “Positive”- New architecture model formats can be added by implementing the interface.
- Pipeline code stays format-agnostic.
- Each adapter owns its parsing, querying, and error handling logic.
Negative
Section titled “Negative”- The interface must cover the superset of all format capabilities. Format-specific features that do not fit the interface require workarounds or optional methods.
- The
checkVersionmethod is optional, creating inconsistency in version checking across adapters.
Amendments
Section titled “Amendments”- 2026-11-17: Added optional
getValidationBaseline?()to the adapter interface and a matching optionalvalidationBaselinefield onModelPatchOptions. The LikeC4 adapter captures the model’s validation warnings at load time, and patch validation reports only warnings the patch introduces. - 2026-11-17:
ModelRelationshipandComponentRelationshipgain optionaltechnology,descriptionandtags. The LikeC4 adapter fills them and the drift prompt renders them; the Structurizr adapter leaves them unset because it already maps description totitleand technology tokind. - 2026-11-17:
ModelRelationshipgains an optionalbidirectionalflag. Adapters set it when one declared relationship permits both directions (LikeC4a <-> b). The LikeC4 adapter indexes both directions for dependency checks; formats without the concept leave it unset. - 2026-11-17:
ArchitectureModelAdaptergains an optionalgetElementSourceFiles()(element ID to declaring file), andModelPatchOptionsan optionalelementSourceFiles. The patcher uses them to pick the file to patch and falls back to its own file scan when they are absent. Only the LikeC4 adapter implements it. - 2026-11-17: Structurizr element IDs come from the
erode.idproperty, then thestructurizr.dsl.identifierproperty the DSL parser writes into the workspace JSON, then the parent ID plus a snake_case name. Numeric JSON IDs only resolve relationship endpoints and are never exposed. Identifiers containing a UUID segment (anonymous elements) are ignored, because the parser regenerates them on each export. Element types come from the JSON array an element sits in. Duplicate IDs fail the load with anAdapterErrornaming both elements, rather than being suffixed, since suffixes would depend on declaration order.ArchitectureModelAdaptergains an optionalgetDslReferences()(element ID to DSL identifier) andModelPatchOptionsan optionaldslReferences. When it is set, the Structurizr patcher writes relationships with DSL identifiers and skips relationships to elements without one.
Related commits
Section titled “Related commits”8691ba8- chore(release): release 0.4.0 (#24)