All skills
lexler avatar

/c4-diagrams

@45ff07e
by Lada Kesselerlexler/skill-factory238 stars
61

Creates C4 architecture diagrams for designing, documenting, or understanding software architecture. Use when working through system design, mapping existing codebases, or visualizing structure at any level from system landscape down to code.

Use this Skill: https://skilld.dev/gh/lexler/skill-factory/c4-diagrams

This session only. Nothing lands on disk.

referencesformatsstructurizr.md

≈1.8k tokens on demand. Your agent reads this file only when SKILL.md points to it.

Structurizr DSL

Architecture as code. Define the model once, generate multiple views. Render at structurizr.com/dsl or run locally.

These illustrate the syntax. Consider what fits your context.

Workspace Structure

workspace "Name" "Description" {

    model {
        // define people, systems, containers, components, relationships
    }

    views {
        // define which diagrams to generate from the model
    }
}

The model defines elements and relationships. Views select what to show in each diagram. This separation means you model once and create multiple views of the same architecture.

Model Elements

People and Software Systems

person <name> [description] [tags]
softwareSystem <name> [description] [tags] {
    // containers go here
}

Assign to variables for referencing in relationships and views:

user = person "Customer" "A customer of the bank"
bankSystem = softwareSystem "Internet Banking System" "Allows customers to manage accounts" {
    webapp = container "Web Application" "Serves the SPA" "Java/Spring Boot"
    spa = container "Single-Page App" "Banking UI" "React"
    api = container "API" "Banking API" "Java/Spring Boot"
    db = container "Database" "Stores account data" "PostgreSQL" "database"
}
mainframe = softwareSystem "Mainframe Banking System" "Core banking" "existing"
email = softwareSystem "E-mail System" "Sends emails" "existing"

Containers and Components

container <name> [description] [technology] [tags] {
    // components go here
}
component <name> [description] [technology] [tags]

Tags

Tags control styling. Built-in tags: Element, Person, Software System, Container, Component, Relationship. Add custom tags:

db = container "Database" "Stores data" "PostgreSQL" "database"
mainframe = softwareSystem "Mainframe" "Legacy system" "existing"

Relationships

source -> destination [description] [technology] [tags]

Within an element's scope, the source is implicit:

user = person "User" {
    -> webapp "Views pages using" "HTTPS"
    -> spa "Interacts with"
}

Between named elements:

spa -> api "Makes API calls to" "JSON/HTTPS"
api -> db "Reads account balances from and writes transactions to" "JDBC"
api -> mainframe "Gets account info from" "XML/HTTPS"
api -> email "Sends email using" "SMTP"

Views

System Context

views {
    systemContext bankSystem "Context" "System Context diagram" {
        include *
        autoLayout
    }
}

Container

    container bankSystem "Containers" "Container diagram" {
        include *
        autoLayout
    }

Component

    component api "Components" "API Component diagram" {
        include *
        autoLayout
    }

System Landscape

    systemLandscape "Landscape" "All systems" {
        include *
        autoLayout
    }

Dynamic

    dynamic bankSystem "SignIn" "Sign-in flow" {
        user -> spa "Opens in browser"
        spa -> api "Sends credentials to"
        api -> db "Validates against"
        api -> spa "Returns auth token to"
    }

Deployment

    deployment bankSystem "Production" "Prod" "Production deployment" {
        include *
        autoLayout
    }

Deployment Model

model {
    prodEnv = deploymentEnvironment "Production" {
        deploymentNode "AWS" "" "Amazon Web Services" {
            deploymentNode "ECS Cluster" "" "Amazon ECS" {
                containerInstance api
                containerInstance webapp
            }
            deploymentNode "RDS" "" "Amazon RDS" {
                containerInstance db
            }
        }
    }
}

Styling

views {
    styles {
        element "Person" {
            shape Person
            background #08427B
            color #ffffff
        }
        element "Software System" {
            background #1168BD
            color #ffffff
        }
        element "Container" {
            background #438DD5
            color #ffffff
        }
        element "database" {
            shape Cylinder
        }
        element "existing" {
            background #999999
        }
        relationship "Relationship" {
            color #707070
            thickness 2
        }
    }
}

Available shapes: Box, Circle, Cylinder, Ellipse, Hexagon, Person, Pipe, Robot, RoundedBox, Component, Folder, WebBrowser, MobileDeviceLandscape, MobileDevicePortrait

View Modifiers

  • include * — include all elements relevant to this view's scope
  • exclude <element> — remove a specific element
  • autoLayout [tb|bt|lr|rl] [rankSep] [nodeSep] — automatic layout (top-bottom default)
  • animation { ... } — step-by-step reveal for presentations

Groups

Visual groupings within a view:

model {
    bankSystem = softwareSystem "Banking" {
        group "Frontend" {
            spa = container "SPA" "" "React"
            webapp = container "Web App" "" "Spring Boot"
        }
        group "Backend" {
            api = container "API" "" "Spring Boot"
            db = container "Database" "" "PostgreSQL"
        }
    }
}

Complete Example

workspace "Internet Banking" "An example workspace" {

    model {
        customer = person "Customer" "A bank customer"
        
        bankSystem = softwareSystem "Internet Banking System" "Allows customers to manage accounts" {
            spa = container "Single-Page App" "Banking UI" "React"
            api = container "API Application" "Banking logic" "Java/Spring Boot"
            db = container "Database" "Stores accounts, transactions" "PostgreSQL" "database"
        }
        
        mainframe = softwareSystem "Mainframe" "Core banking system" "existing"
        email = softwareSystem "E-mail System" "Sends notifications" "existing"
        
        customer -> spa "Manages accounts using"
        spa -> api "Makes API calls to" "JSON/HTTPS"
        api -> db "Reads account balances from and writes transactions to" "JDBC"
        api -> mainframe "Gets account data from" "XML/HTTPS"
        api -> email "Sends notifications via" "SMTP"
    }

    views {
        systemContext bankSystem "Context" {
            include *
            autoLayout
        }
        
        container bankSystem "Containers" {
            include *
            autoLayout
        }
        
        dynamic bankSystem "SignIn" "Customer sign-in flow" {
            customer -> spa "Opens banking app"
            spa -> api "Submits credentials"
            api -> db "Validates credentials"
            api -> spa "Returns session token"
        }

        styles {
            element "Person" {
                shape Person
                background #08427B
                color #ffffff
            }
            element "Software System" {
                background #1168BD
                color #ffffff
            }
            element "Container" {
                background #438DD5
                color #ffffff
            }
            element "database" {
                shape Cylinder
            }
            element "existing" {
                background #999999
                color #ffffff
            }
        }
    }
}

Paste into structurizr.com/dsl to visualize.

Source: https://docs.structurizr.com/dsl/language

Source: SKILL.md on GitHub

No alerts3mo3 checks · Risk SAFE
  • Gen Agent Trust Hub3mo

    The skill facilitates the creation of C4 architecture diagrams by providing detailed guidelines for various diagram levels and formats. It includes a Python script for validating the visual alignment of ASCII diagrams. The skill's instructions and script are focused on architectural documentation and do not contain malicious patterns.

  • Socket3mo

    No alerts

  • Snyk3mo

    Risk: LOW · No issues

Signed by skilld at 45ff07e. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub last month.

Steadyupdated 6 months ago

README badge

README badge for lexler/skill-factory/c4-diagrams