C4 Model Integration - atterdag/archflow-it-architecture-hub GitHub Wiki

C4 Model Integration

This section details how ArchFlow leverages the C4 Model for software architecture visualization, integrated seamlessly with Structurizr DSL for defining diagrams as code and Kroki for dynamic rendering.


1. The C4 Model in ArchFlow

The C4 Model (Context, Container, Component, Code) provides a hierarchical approach to diagramming software architecture, allowing different levels of abstraction to be understood by various stakeholders. ArchFlow adopts the C4 Model as its primary standard for visual architectural documentation.

Within ArchFlow, C4 diagrams are treated as a specific type of "architectural artifact" (type: 'c4-model'). They are intrinsically linked to systems and can be related to other artifacts like Architectural Decision Records (ADRs) or Arc42 documentation sections.

Levels of Abstraction Supported:

  • System Context Diagram (C1): Shows the system in scope and its relationships with users and other systems.
  • Container Diagram (C2): Decomposes the system into containers (applications, data stores, microservices), showing their interconnections.
  • Component Diagram (C3): Breaks down a container into its core components, detailing their responsibilities and interactions.
  • Code Diagram (C4 - Conceptual): While ArchFlow doesn't generate actual code diagrams, the Structurizr DSL can represent elements at this level, serving as a conceptual bridge to code.

2. Structurizr DSL: Diagrams as Code

ArchFlow champions the "diagrams as code" approach using Structurizr DSL (Domain Specific Language). This provides several benefits:

  • Version Control: C4 models are stored as plain text files (or content within Firestore documents), allowing them to be version-controlled alongside your code.
  • Consistency: Ensures all diagrams adhere to the C4 Model standard and can be programmatically validated.
  • Automation: Enables automated rendering and integration into documentation workflows.
  • Collaboration: Teams can collaborate on diagrams using standard code review processes.

How it Works in ArchFlow:

When you create or edit a C4 Model artifact in ArchFlow, you directly input or generate Structurizr DSL in the content editor.

Example Structurizr DSL (within ArchFlow artifact content):