
In the fast-paced world of Agile Enterprise Architecture (EA), documentation often becomes a bottleneck. The C4 model was designed to solve this by offering a pragmatic approach to visualizing software architecture. While the core C4 model (Context, Container, Component, Code) provides the essential structural views, it is not a silver bullet for every architectural question. This is where supplementary diagrams and modern tooling like VPasCode shine.
This tutorial explores how to effectively extend the C4 model using specialized diagrams, leverage “Diagrams-as-Code” workflows, and integrate AI assistance to maintain clarity and precision in your architecture documentation.
1. The C4 Philosophy: Start with the Question, Not the Notation
The fundamental rule of the C4 model is to answer specific questions rather than creating exhaustive models. When you need to supplement the standard C4 views, you must first identify the “gap” in your understanding.
Consider the following decision guide based on your architectural needs:
- How do systems fit into an organizational landscape? Use a C4 System Landscape diagram. This is your high-level view of the enterprise ecosystem.
- Which system elements collaborate in a use case? Use a C4 Dynamic diagram. This shows the broad interaction between containers and components.
- What messages pass between participants, and in what order? Use a UML Sequence diagram. This is critical for debugging message flows and timing.
- What are the process steps, decisions, or parallel paths? Use a UML Activity diagram. This models the workflow logic.
- What states can an entity enter, and what triggers transitions? Use a UML State Machine diagram. This is for tracking the lifecycle of an entity like an Order or a Subscription.
- What are the important domain or code structures? Use a UML Class diagram. This defines the static structure of your data and logic.
- What data is persisted and how are records related? Use an Entity-Relationship (ER) diagram. This is the blueprint for your database schema.
- Where does software run in a particular environment? Use a C4 Deployment or UML Deployment diagram. This maps the software to the infrastructure.
Key Distinction: The official C4 model defines three supporting diagram types: Landscape, Dynamic, and Deployment. The UML-based diagrams (Sequence, Activity, State, Class) are supplementary notations used to answer specific questions that C4 does not cover in detail.
2. Keeping Your Diagrams Connected and Consistent
A common pitfall in Agile EA is creating “island” diagrams that are disconnected from the main architecture. To prevent this, supplementary views must remain tightly coupled with the C4 model.
Guidelines for Consistency
- Name the C4 Element: If a sequence diagram explains a checkout process, explicitly state that it elaborates on the interaction within the Orders API container.
- Match Terminology: Use consistent names for systems, containers, and components across all diagrams. If your C4 model calls it “Payment Adapter,” do not call it “Payment Service” in your sequence diagram.
- State the Scope: Clearly label whether you are showing a single request, a full lifecycle, or a specific deployment environment.
- Identify Abstraction Level: A domain class model is not a code class diagram, which is not a database schema. Label these distinctions explicitly.
- Link Views: Embed references to related C4 diagrams or keep the supplementary view in the same documentation section.
3. The Power of Diagrams-as-Code with VPasCode
Visual Paradigm’s VPasCode allows teams to write diagrams using code (primarily PlantUML) rather than dragging and dropping shapes. This approach offers several advantages for Agile teams:
- Version Control Friendly: Since diagrams are text, they can be stored in Git alongside your source code. You can use standard merge strategies to resolve conflicts.
- Automated Updates: If the architecture changes, you can update the text file, and the diagram regenerates automatically.
- Standardized Syntax: It removes the “pixel-perfect” debate. The focus remains on the structure and relationships, not the layout aesthetics.
Example: A C4 System Landscape
Below is an example of how a C4 Landscape diagram is written in code. This view helps stakeholders understand how the Online Shop fits into the broader enterprise.
@startuml
!include https://static.visual-paradigm.com/plantuml-stdlib/C4-PlantUML/master/C4_Context.puml
LAYOUT_LEFT_RIGHT()
LAYOUT_WITH_LEGEND()
skinparam vpDiagramType C4modelSystemLandscapeDiagram
skinparam defaultFontSize 14
skinparam defaultFontColor #333333
title System Landscape diagram for Online Shop
Person(customer, "Customer", "Browses the shop and places orders")
Person(agent, "Support Agent", "Handles customer requests")
Boundary(shopBoundary, "Online Shop") {
System(shop, "Online Shop", "Web shop front end and order management")
}
System_Ext(identity, "Customer Identity", "Customer authentication and profiles")
System_Ext(payment, "Payment Provider", "Authorizes payment transactions")
System_Ext(wms, "Warehouse Management", "Handles fulfilment of orders")
System_Ext(email, "Email Service", "Sends transactional notifications")
Rel(customer, shop, "Browses and places orders", "HTTPS")
Rel(agent, shop, "Handles customer requests", "HTTPS")
Rel(shop, identity, "Authenticates customers", "HTTPS/JSON")
Rel(shop, payment, "Authorizes payments", "HTTPS/JSON")
Rel(shop, wms, "Sends fulfilment requests", "HTTPS/JSON")
Rel(shop, email, "Sends notifications", "HTTPS/JSON")
@enduml
4. Integrating AI for Faster Drafting
VPasCode and similar tools often include AI-assisted features to help generate initial drafts. However, the role of the architect remains critical. AI is a tool for acceleration, not a replacement for architectural judgment.
Best Practices for AI-Assisted Modeling
- Be Specific: Don’t just ask for “a sequence diagram.” Ask for “a sequence diagram for one checkout attempt” including specific participants like “Web App” and “Orders API.”
- Constrain the Output: Explicitly tell the AI what not to do. For example: “Do not add retries, refunds, or other behavior unless specified.”
- Treat as Draft: AI can produce plausible-looking but incorrect relationships. Always validate the model against your actual requirements.
- Human Review: The architecture team is responsible for confirming that names, relationships, and flows reflect the actual design.
Example: AI Prompt for a Sequence Diagram
A good prompt looks like this:
Create a PlantUML sequence diagram for one checkout attempt.
Use these participants: Web App, Orders API, Payment Adapter, Payment Provider, and Orders DB.
Include approved and declined outcomes.
Do not add retries, refunds, or other behavior unless specified.
5. Deep Dive: Dynamic vs. Sequence Diagrams
It is common to confuse C4 Dynamic diagrams with UML Sequence diagrams. Understanding the difference is key to effective modeling.
C4 Dynamic Diagram
A C4 Dynamic diagram is best for showing which architectural elements participate in a use case and the broad sequence of collaboration. It is a high-level view.
@startuml
!include https://static.visual-paradigm.com/web/resources/plantuml-stdlib/themes/vp.puml
skinparam {
vpDiagramType CommunicationDiagram
nodesep 80
}
left to right direction
title Online Shop — Place Order (Dynamic View)
object "Customer" as Customer
object "Web App" as Web
object "Orders API" as Orders
object "Payment Adapter" as Payments
object "Orders DB" as DB
object "Payment Provider" as Provider
Customer -[#blue]- Web : ▶ 1: Submit checkout
◀ 8: Display result
Web -[#green]- Orders : ▶ 2: Create order
◀ 7: Return checkout result
Orders -[#orange]- Payments : ▶ 3: Request authorization
◀ 5: Return authorization result
Orders -[#purple]- DB : ▶ 6: Save order
Payments -[#red]- Provider : ▶ 4: Authorize payment
◀ 5a: Return authorization result
@enduml
UML Sequence Diagram
A Sequence diagram emphasizes messages exchanged over time. It is the better choice when replies, branching paths, and participant interactions are central to the explanation.
@startuml
title Online Shop — Checkout Sequence
actor Customer
participant "Web App" as Web
participant "Orders API" as Orders
participant "Payment Adapter" as Payments
participant "Payment Provider" as Provider
database "Orders DB" as DB
Customer -> Web : Submit checkout
Web -> Orders : createOrder(cart)
Orders -> Payments : authorize(amount)
Payments -> Provider : authorize(amount)
Provider --> Payments : authorization result
alt Payment approved
Payments --> Orders : approved
Orders -> DB : save(order, CONFIRMED)
DB --> Orders : saved
Orders --> Web : confirmation
Web --> Customer : Show confirmation
else Payment declined
Payments --> Orders : declined
Orders -> DB : save(order, PAYMENT_FAILED)
Orders --> Web : payment issue
Web --> Customer : Show payment issue
end
@enduml
6. Review Checklist for Supplementary Diagrams
Before publishing any supplementary diagram, run it through this checklist to ensure it adds value:
- Purpose: Does the title or surrounding text make the question clear?
- Scope: Is the system, environment, process, or scenario identified?
- Consistency: Do names match the C4 views and project terminology?
- Abstraction: Is this a system, container, component, domain, code, or database view?
- Relationships: Are arrows and labels clear about direction and meaning?
- Branches and States: Are important alternatives represented accurately?
- Readability: Can readers follow it without a dense tangle of elements?
- Maintenance: Is there a reason to update it, and a clear trigger for review?
- Value: Does this view add understanding, or merely repeat existing documentation?
Conclusion
The C4 model provides a solid foundation for architectural communication, but it is the strategic use of supplementary diagrams that fills the gaps. By combining the structural clarity of C4 with the behavioral depth of UML Sequence, Activity, and State diagrams, Agile EA teams can create a rich, multi-faceted view of their systems.
Leveraging tools like VPasCode and AI assistance allows these diagrams to be treated as code—versioned, maintainable, and integrated into the development lifecycle. Remember, the best supplementary diagram is not the most detailed one; it is the smallest, most accurate view that answers a specific question and remains connected to the rest of the architecture documentation.