Mastering Agile Architecture: The C4 Model, Visual Paradigm VPasCode, and AI-Assisted Diagramming

Infographic comparing C4 and UML diagram types for system architecture design

In the fast-paced world of Agile Enterprise Architecture, teams often find themselves bogged down by documentation that fails to communicate effectively. The C4 Model offers a solution by providing a structured way to visualize software architecture, focusing on static structure and dynamic interactions. However, the true power of C4 emerges when it is combined with modern “Diagrams as Code” tools like Visual Paradigm’s VPasCode and the efficiency of AI assistance. This guide explores how to leverage these technologies to create clear, maintainable, and accurate architectural views.

1. The Philosophy: Choosing the Right View

The core principle of effective architecture documentation is to choose the right view for the specific question you are trying to answer. The C4 model provides four primary levels of abstraction, but it also supports three official supplementary diagram types and a wide range of standard UML diagrams. The goal is not to create a diagram for every possible view, but to select a focused view that answers a question left open by the standard C4 diagrams.

Decision Guide: From Question to Notation

Before opening a drawing tool, start with the question. Use the following logic to select your diagram type:

  • How do several systems fit into an organizational or technical landscape?
    Use a C4 System Landscape diagram. This is a wider view than a system context, showing multiple software systems within a chosen scope.
  • Which system elements collaborate in a use case?
    Use a C4 Dynamic diagram. This provides a concise architectural interaction among elements.
  • What messages pass between participants, and in what order?
    Use a UML Sequence diagram. This is the better choice when timing, message order, and request/response behavior are central.
  • What are the process steps, decisions, or parallel paths?
    Use a UML Activity diagram. This focuses on workflow logic, such as business processes or technical workflows.
  • What states can an entity enter, and what triggers transitions?
    Use a UML State Machine diagram. This models the lifecycle of a single entity (e.g., an Order), not a process involving many participants.
  • What are the important domain or code structures?
    Use a UML Class diagram. Use this when domain concepts or code-level structure are important to understanding a component.
  • What data is persisted and how are records related?
    Use an Entity-Relationship (ER) Diagram. This is the most direct way to understand tables, keys, and data relationships.
  • Where does software run in a particular environment?
    Use a C4 Deployment or UML Deployment diagram.

2. Keeping Supplementary Views Connected

A supplementary diagram should clarify one concern without becoming a disconnected “second architecture model.” To maintain consistency across your documentation:

  1. Name the C4 Element: If a sequence diagram explains a checkout interaction, specify that it elaborates on the “Orders API” container from the C4 context diagram.
  2. Use Consistent Names: Match the system, container, component, and actor names used in the main C4 views.
  3. State the Scope and Scenario: Make it clear if the view shows one request, one lifecycle, or a wider landscape.
  4. Add Titles and Keys: Use clear titles and labeled relationships. If you use colors or shapes to convey meaning, explain them in a key.
  5. Link Related Views: Embed the supplementary view in the same documentation section or put a reference beside the relevant C4 diagram.

3. C4 Diagrams as Code: The VPasCode Workflow

While diagrams are visual, the best modern approach to managing them is “Diagrams as Code.” Visual Paradigm’s VPasCode allows you to write diagrams using text (PlantUML) which renders into images. This approach offers version control, collaborative editing, and the ability to automate updates.

The Practical Workflow

  1. Choose the Diagram and Scope: Decide what question it answers and which C4 view it supplements.
  2. Gather Authoritative Names: Use existing architecture and requirements as the source of truth.
  3. Draft the PlantUML: Write the code directly in VPasCode or ask its AI feature to create an initial draft.
  4. Render and Inspect: Check that the code is valid and that the rendered diagram is legible.
  5. Verify Meaning with the Team: Confirm that names, relationships, and flows reflect the actual design.
  6. Refine and Preserve: Keep the text with your documentation or version-controlled project files.

Example: C4 System Landscape

Here is how you might draft a System Landscape diagram using PlantUML syntax within VPasCode. This diagram shows multiple systems (Online Shop, Payment Provider, Identity, etc.) and their interactions.

@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

Example: C4 Dynamic Diagram

For a concise architectural interaction, a C4 Dynamic diagram is ideal. It shows how elements collaborate to complete a use case without getting bogged down in message timing details.

@startuml
!include https://static.visual-paradigm.com/web/resources/plantuml-stdlib/themes/vp.puml
skinparam {
  vpDiagramType CommunicationDiagram
  nodesep 80
}

<style>
object {
  MinimumWidth 80
}
</style>

left to right direction

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

Customer -[#blue]- Web : <color:blue>▶ 1: Submit checkout</color>\n<color:blue>◀ 8: Display checkout result</color>
Web -[#green]- Orders : <color:green>▶ 2: Create order</color>\n<color:green>◀ 7: Return checkout result</color>
Orders -[#orange]- Payments : <color:orange>▶ 3: Request authorization</color>\n<color:orange>◀ 5: Return authorization result</color>
Payments -[#red]- Provider : <color:red>▶ 4: Authorize payment</color>\n<color:red>◀ 5a: Authorization response</color>
Orders -[#purple]- DB : <color:purple>▶ 6: Save order</color>

@enduml

4. Advanced Supplementary Diagrams

When the standard C4 views are not enough, you can use standard UML diagrams to drill down into specific details. These should always be clearly labeled as supplementary to the main C4 model.

UML Sequence Diagrams

Use these when the reader needs to trace message order, request and response behavior, or synchronous interactions. They are perfect for explaining the “how” of a specific scenario.

@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

UML Activity Diagrams

These focus on workflow logic, steps, and decisions. They are useful for describing technical or business processes without implying that each activity is a software component.

@startuml
title Online Shop — Order Fulfilment Workflow

start
:Receive confirmed order;
:Reserve inventory;
if (Inventory available?) then (yes)
  :Request payment authorization;
  if (Payment approved?) then (yes)
    :Create fulfilment request;
    :Notify customer;
  else (no)
    :Mark payment failed;
    :Notify customer of payment issue;
  endif
else (no)
  :Mark order out of stock;
  :Notify customer of delay or cancellation;
endif
stop
@enduml

UML State Machine Diagrams

State machines model the lifecycle of one kind of entity. The transitions represent events or conditions that move the entity from one state to another. This is distinct from an activity diagram which might involve many participants.

@startuml
title Online Shop — Order Lifecycle

[*] --> PendingPayment : order created
PendingPayment --> Confirmed : payment approved
PendingPayment --> PaymentFailed : payment declined
PaymentFailed --> PendingPayment : payment retry accepted
PendingPayment --> Cancelled : cancellation accepted

Confirmed --> FulfilmentRequested : fulfilment started
FulfilmentRequested --> Shipped : carrier accepts parcel
Shipped --> Delivered : delivery confirmed

Confirmed --> Cancelled : cancellation accepted
Cancelled --> [*]
Delivered --> [*]
@enduml

UML Class Diagrams & ER Diagrams

Class diagrams show static structure (domain or code), while ER diagrams focus on persisted data. It is crucial to distinguish between a domain model and a database schema.

@startuml
title Online Shop — Order Domain Model

class Customer {
  customerId: UUID
  email: String
}

class Order {
  orderId: UUID
  status: OrderStatus
  createdAt: DateTime
  total: Money
}

class OrderLine {
  quantity: Integer
  unitPrice: Money
}

class Product {
  productId: UUID
  name: String
}

enum OrderStatus {
  PENDING_PAYMENT
  CONFIRMED
  PAYMENT_FAILED
  SHIPPED
  DELIVERED
  CANCELLED
}

Customer "1" -- "0..*" Order : places
Order "1" *-- "1..*" OrderLine : contains
OrderLine "*" --> "1" Product : refers to
Order --> OrderStatus
@enduml
@startuml
title Online Shop — Order Data Model

hide circle
skinparam linetype ortho

entity "CUSTOMER" as Customer {
  * customer_id : UUID <>
  --
  email : VARCHAR
}

entity "ORDERS" as Orders {
  * order_id : UUID <>
  --
  customer_id : UUID <>
  status : VARCHAR
  created_at : TIMESTAMP
}

entity "ORDER_LINE" as Line {
  * order_id : UUID <<PK, FK>>
  * line_no : INTEGER <>
  --
  product_id : UUID <>
  quantity : INTEGER
  unit_price : DECIMAL
}

entity "PRODUCT" as Product {
  * product_id : UUID <>
  --
  name : VARCHAR
}

Customer ||--o{ Orders : places
Orders ||--|{ Line : contains
Product ||--o{ Line : appears in
@enduml

5. Leveraging AI in VPasCode

Visual Paradigm’s VPasCode integrates AI assistance to help draft diagrams quickly. However, AI output should be treated as a starting point, not a final answer. The architecture team remains responsible for validating the model.

Effective AI Prompting Strategy:

  1. Be Specific: Specify the diagram type, scope, participants, and required branches.
  2. Bounded Scope: Explicitly state what behaviors must not be assumed (e.g., “Do not add retries or refunds unless specified”).
  3. Verify: Always review the generated code to ensure it matches the actual system design.

Example Prompt:

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.

6. Review Checklist

Before publishing a supplementary diagram, perform a final review to ensure it adds value and clarity:

  • 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?

By combining the structural clarity of the C4 Model with the flexibility of Diagrams as Code and the speed of AI assistance, Agile EA teams can create living documentation that truly supports their architecture.