C4 Dynamic Diagrams with VPasCode: Bridging UML and AI for Agile Architects

In the realm of Agile Enterprise Architecture, static models like the System Context or Container diagrams tell us what we have, but they often fail to explain how it works. This is where the C4 Dynamic Diagram steps in. By integrating the flexibility of UML Communication Diagrams with the rigor of architectural coding, tools like Visual Paradigm’s VPasCode allow teams to document complex runtime behaviors with clarity.
The Strategic Value of Dynamic Modeling
A C4 Dynamic Diagram is not just a picture of a flow; it is a behavioral view that traces a single scenario—such as a user placing an order—through the elements defined in your static architecture. Unlike traditional UML diagrams that might get lost in method-level details, C4 dynamic diagrams focus on architectural scale.
They answer critical questions that static diagrams cannot, such as:
- Which parts participate in the checkout process?
- What happens before the result is returned to the user?
- How do asynchronous messages affect the flow?
By focusing on one scenario per diagram, you provide a focused, maintainable explanation of the system’s behavior that is easy for developers and stakeholders to digest.
Choosing the Right Layout: Communication vs. Sequence
One of the most powerful features of C4 is that it permits two distinct layout styles to represent the exact same interaction. The choice depends entirely on what you need to emphasize to your audience.
- Communication-Style (Spatial View): Based on the UML Communication Diagram, this layout shows elements as nodes with numbered, directional messages. It is best when you need to emphasize who interacts with whom. It works exceptionally well when readers already understand the context and the flow is short enough to follow numbered links.
- Sequence-Style (Chronological View): This layout arranges interactions as an ordered series of messages over time. It is the superior choice when the main point is exact ordering, especially when dealing with many steps, repeated request/response exchanges, callbacks, or significant asynchronous behavior.
Implementing Diagrams as Code with VPasCode
For Agile teams, the “Diagram as Code” paradigm offers a distinct advantage: version control. By treating diagrams as text files (specifically PlantUML), you can diff changes, review them in pull requests, and keep them aligned with your documentation.
Visual Paradigm’s VPasCode is a text-based workspace that bridges the gap between AI-assisted generation and manual coding. It allows you to define your dynamic diagrams using specific syntax that renders into the C4 visual language.
Writing a C4 Communication Diagram
When authoring a C4 Dynamic diagram in code, you define objects (participants) and the interactions between them. The key is to label interactions with concise actions and manage numbering to ensure legibility.

@startuml
!include https://static.visual-paradigm.com/web/resources/plantuml-stdlib/themes/vp.puml
skinparam {
nodesep 80
}
title Online Shop — Place Order (Communication 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
' Define interactions with unique numbers
Customer -[#blue]- Web : "1: Submit checkout\n8: Display checkout result"
Web -[#green]- Orders : "2: Create order\n7: Return checkout result"
Orders -[#orange]- Payments : "3: Request authorization\n6: Return authorization result"
Payments -[#red]- Provider : "4: Authorize payment\n5: Return authorization response"
Orders -[#purple]- DB : "6a: Save order"
@enduml 
In this code snippet, notice the use of vpDiagramType CommunicationDiagram to enforce the C4 styling. The interactions are defined using the syntax Object -[color]- Object : Label. Crucially, we use unique numbering (1 through 8) to make the flow legible, even when messages are bidirectional.
Refining the Logic: Avoiding Ambiguity
A common pitfall in dynamic modeling is ambiguity. A sketch implies an order-save step but does not define whether the order is saved before or after authorization. When writing your code, ensure the sequence reflects your intended system design explicitly. If a failure path is critical (e.g., payment declines), consider documenting it as a separate scenario or using a sequence diagram to clearly branch the logic.
Best Practices for Agile EA Teams
Why combine modeling tools, code, and AI? The synergy allows for a faster first draft, reviewable changes via Git, and editable output that remains linked to the source code.
To maintain a healthy architecture documentation strategy, follow these rules:

- One Scenario Per Diagram: Give the view a specific title, such as “Place order — successful payment.” Do not try to cram multiple use cases into one view.
- Reused Elements: Participants should correspond to elements in your related C4 static diagrams, not arbitrary implementation details.
- Sparingly Used: Dynamic diagrams are artifacts that require maintenance. Use them only for interesting, recurring, or interaction-heavy behaviors that the static model cannot explain.
- Keep it Legible: If the flow is complex with many branches and loops, a detailed UML sequence diagram might be better. Keep the C4 view at an architectural scale.
By adopting this workflow, you move beyond static snapshots and provide your team with a living, breathing map of how your system behaves in the real world.