Diagrams ClaudeCursor Advanced

C4 Diagrams in Mermaid

Model system architecture with C4 context, container, and component diagrams

46 of 66

C4 model overview

C4 describes software architecture at four levels of zoom:

  1. Context -- system + external actors
  2. Container -- deployable units (apps, databases, queues)
  3. Component -- internal modules within a container
  4. Code -- class/function level (rarely diagrammed)

C4 Context in Mermaid

C4Context
    title System Context

    Person(user, "Developer", "Uses the tool")
    System(app, "Agent Lore", "AI tutorial hub")
    System_Ext(github, "GitHub Pages", "Static hosting")

    Rel(user, app, "Browses tutorials")
    Rel(app, github, "Deployed to")

C4 Container diagram

C4Container
    title Container Diagram

    Person(user, "Developer")

    Container_Boundary(web, "Web App") {
        Container(html, "index.html", "HTML", "App shell")
        Container(js, "ES Modules", "JavaScript", "App logic")
        Container(css, "style.css", "CSS", "Styling")
    }

    ContainerDb(storage, "localStorage", "Browser", "Filter state")

    Rel(user, html, "Loads")
    Rel(html, js, "Imports")
    Rel(js, storage, "Reads/writes")

Tips

  • Start with Context (zoom out), then drill into Containers
  • Use System_Ext for third-party services
  • Keep each diagram focused on one level
  • GitHub renders C4 Mermaid natively since 2024

Working out which model to run this on? See The Codex. Packaging it as a reusable skill? See The Armory.