Skip to content

ADR-003: Architecture model adapter system

Status: Accepted
Date: 2026-02-27
Authors: Anders Hassis

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.

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.

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.

  • 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.
  • 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 checkVersion method is optional, creating inconsistency in version checking across adapters.
  • 2026-11-17: Added optional getValidationBaseline?() to the adapter interface and a matching optional validationBaseline field on ModelPatchOptions. The LikeC4 adapter captures the model’s validation warnings at load time, and patch validation reports only warnings the patch introduces.
  • 2026-11-17: ModelRelationship and ComponentRelationship gain optional technology, description and tags. The LikeC4 adapter fills them and the drift prompt renders them; the Structurizr adapter leaves them unset because it already maps description to title and technology to kind.
  • 2026-11-17: ModelRelationship gains an optional bidirectional flag. Adapters set it when one declared relationship permits both directions (LikeC4 a <-> b). The LikeC4 adapter indexes both directions for dependency checks; formats without the concept leave it unset.
  • 2026-11-17: ArchitectureModelAdapter gains an optional getElementSourceFiles() (element ID to declaring file), and ModelPatchOptions an optional elementSourceFiles. 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.id property, then the structurizr.dsl.identifier property 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 an AdapterError naming both elements, rather than being suffixed, since suffixes would depend on declaration order. ArchitectureModelAdapter gains an optional getDslReferences() (element ID to DSL identifier) and ModelPatchOptions an optional dslReferences. When it is set, the Structurizr patcher writes relationships with DSL identifiers and skips relationships to elements without one.
  • 8691ba8 - chore(release): release 0.4.0 (#24)