
In the fast-paced world of Agile Enterprise Architecture, teams need to communicate complex software structures without getting bogged down in rigid, static documentation. This is where the C4 model shines. By focusing on static structure through a hierarchy of views, it allows teams to describe what a system is, what it contains, and how its parts relate.
However, static structure is only part of the story. To truly understand a system, you often need to answer questions about how systems collaborate, how data flows, or where software actually runs. This is where supplementary diagrams come into play. This tutorial explores how to combine the structural power of C4 with specialized UML notations, utilizing Visual Paradigm‘s VPasCode tool and AI assistance to create “Diagrams as Code” for modern software architecture.
1. The C4 Hierarchy and the Need for Supplementary Views
The C4 model is built on four levels of detail, moving from the broadest context to the code level:
- System Context: Shows the system and its users.
- Containers: Shows the high-level technology choices (e.g., Web App, API, Database).
- Components: Shows the major building blocks within a container.
- Code: Shows the internal structure of a component (optional).
While C4 provides the skeleton, it does not cover every aspect of software architecture. As noted in architectural guides, you should choose a focused view when C4 diagrams leave a question open. This often involves three official C4 supporting views (Landscape, Dynamic, Deployment) and several supplementary UML types.
When to Use Supplementary Diagrams
Instead of creating a diagram for every possible view, follow this decision guide to select the right tool for the job:
- System Landscape: Use when you need to show how several systems fit into an organizational or technical landscape.
- C4 Dynamic Diagram: Use for a concise architectural interaction among elements (collaboration).
- UML Sequence Diagram: Use when timing and message order matter.
- UML Activity Diagram: Use when the workflow and its decisions matter.
- UML State Machine: Use for an entity’s lifecycle (e.g., Order status transitions).
- UML Class Diagram: Use when structure (domain or code) is the question.
- Entity-Relationship Diagram (ERD): Use to show persisted data and database structure.
2. Connecting Supplementary Views to C4
A common pitfall in architecture documentation is creating “islands” of information. A supplementary diagram should clarify one concern without becoming a disconnected second architecture model. To keep your documentation coherent, follow these best practices:
- Name the C4 Element: Explicitly state which container or component the diagram elaborates on.
- Use Consistent Names: Match the system, container, component, and actor names used in your main C4 views.
- State the Scope: Make it clear if the view shows one request, one lifecycle, or a wider landscape.
- Identify Abstraction Level: Distinguish between a domain class model and a database schema. They are not interchangeable.
- Add Titles and Keys: C4 notation recommends clear titles, explicit element types, and labeled relationships.
3. The “Diagrams as Code” Workflow with VPasCode
Visual Paradigm’s VPasCode is a browser-based workspace that allows architects to write diagrams as text. This approach is ideal for Agile teams because it integrates with version control (Git), facilitates peer review, and enables AI-assisted drafting.
The Practical Workflow
- Choose the Diagram: Decide what question it answers and which C4 view it supplements.
- Gather Names: Use existing architecture and requirements as the source of truth.
- Draft the Code: Write the PlantUML directly in VPasCode or ask its AI feature to create an initial draft.
- Constrain AI Prompts: Be specific. Specify the diagram type, scope, participants, and required branches.
- Render and Inspect: Check that the code is valid and the rendered diagram is legible.
- Verify Meaning: Confirm that names, relationships, and flows reflect the actual design.
4. Deep Dive: From C4 to UML
Let’s explore how specific supplementary diagrams function, using an “Online Shop” example to illustrate the transition from C4 structure to UML detail.
System Landscape and Dynamic Views
The System Landscape diagram offers a wider view than the standard System Context, showing multiple software systems within a scope (e.g., a department or enterprise). It uses simple boxes and arrows to show relationships between systems like a “Payment Provider” or “Warehouse Management” system.
For interactions, the C4 Dynamic Diagram describes how elements collaborate to complete a use case. It is helpful for a short architectural interaction that can be explained with ordered steps. However, if you need to show specific message ordering or replies, a UML Sequence Diagram is the better choice.
Workflow and Lifecycle
When the process itself is the subject, the UML Activity Diagram focuses on workflow logic: steps, decisions, and parallel paths. It can describe a technical or business process without implying that each activity is a software component.
For entity lifecycles, such as an Order moving from “Pending” to “Shipped,” the UML State Machine Diagram is ideal. It models the lifecycle of one kind of entity, where transitions represent events or conditions that move the entity from one state to another.
Data and Deployment
When the question is about the database, an Entity-Relationship Diagram (ERD) focuses on persisted data, tables, keys, and relationships. It is often more direct than a class diagram for database schema design.
Finally, the Deployment Diagram (either C4 or UML style) describes where software runs within a deployment environment. It maps software-system instances to deployment nodes, which may represent physical, virtual, or containerized infrastructure.
5. Writing PlantUML for Architecture
VPasCode uses PlantUML syntax. Below are examples of how these diagrams are structured in code. Remember to preserve line breaks and indentation when writing these in your text editor.
Example: UML Sequence Diagram
@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
Example: C4 Deployment Diagram
@startuml
title Online Shop — Production Deployment
node "Customer Device" as Device {
artifact "Browser" as Browser
}
node "Cloud Region" as Region {
node "Web Tier" as WebTier {
artifact "Web App" as WebApp
}
node "Application Tier" as AppTier {
artifact "Orders API" as OrdersAPI
artifact "Payment Adapter" as PaymentAdapter
}
database "Managed Orders DB" as OrdersDB
}
cloud "Payment Provider" as Provider
Browser --> WebApp : HTTPS
WebApp --> OrdersAPI : HTTPS
OrdersAPI --> OrdersDB : SQL
OrdersAPI --> PaymentAdapter : internal call
PaymentAdapter --> Provider : HTTPS
@enduml
6. Review Checklist
Before publishing a supplementary diagram, ensure it meets the following criteria:
- 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?
- 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?
Conclusion
C4 supplementary diagrams fill gaps that structural architecture views are not intended to cover. By combining the C4 model with specialized UML diagrams and leveraging the power of “Diagrams as Code” in VPasCode, Agile Enterprise Architecture teams can create documentation that is both accurate and maintainable.
Remember, the best supplementary diagram is not the most detailed one; it is the smallest accurate view that answers a real question and remains connected to the rest of the architecture documentation.
