Open in TheBrain

Generate C4 Diagrams from Code or External Data

Generate C4 Diagrams from Code or External Data

Overview

Use EA automation, import facilities, APIs, or scripts to create or update C4-level model elements from source code, repositories, service catalogs, CMDBs, or architecture data. The resulting diagrams can use standard UML, a UML Profile, or a custom C4 MDG Technology.

How to implement

  1. Choose the authoritative source for each data category.
  2. Define mappings from source records to C4 elements:
    • Service catalog entry -> Software System or Container
    • Deployable application -> Container
    • Module/package -> Component
    • Source class -> Code element
    • API dependency -> Relationship
  3. Establish stable external identifiers to prevent duplicates.
  4. Write an import or synchronization process using EA automation/API capabilities available in the environment.
  5. Apply stereotypes, tagged values, notes, and relationship labels during import.
  6. Generate or update diagrams at the appropriate C4 level.
  7. Mark generated content clearly and define which fields are editable in EA.
  8. Schedule synchronization and review exceptions rather than blindly overwriting manual changes.

Example mapping

CMDB application: Customer Portal

-> C4 Software System: Customer Portal

Deployment service: Portal API

-> C4 Container: Portal API

Repository module: authentication

-> C4 Component: Authentication Module

Dependency: Portal API calls Identity Service

-> Relationship label: calls

Advantages

Disadvantages

Recommended practice

Automate inventory and dependency data, but retain architectural review for boundaries, purposes, abstractions, and stakeholder-facing descriptions. Treat generated diagrams as a maintained product, not an unquestioned export.