System Modeling

Purpose

System modeling is the practice of creating abstract representations of a software system to communicate its structure, behaviour and constraints.

Models enable engineers to reason about architecture at different levels of detail, discuss trade-offs, and document decisions in a shared visual language.

This guide covers the C4 model for structural diagrams and event modeling for designing event-driven systems.

Background

Software systems are complex. No single diagram can capture every aspect of a system.

Different audiences need different views:

AudienceNeeds
StakeholdersSystem context, boundaries, external
integrations.
EngineersComponent structure, interactions, data flow.
New team membersHigh-level orientation, key concepts.
OperationsDeployment topology, infrastructure.

Using a consistent modeling approach ensures that diagrams across the organization use the same conventions and are understandable by everyone.

The C4 Model

The C4 model provides a hierarchical approach to visualizing software architecture at four levels.

Level 1: System Context

Shows the system being built, its users and the external systems it integrates with.

Purpose: Provide a high-level overview for everyone from stakeholders to developers.

[Customer] ──→ [Order Management System] ←── [Payment Gateway]
                                    ↓
                              [Notification Service]

Recommended for: Every system. This is the starting point for any architecture discussion.

Level 2: Container

Shows the high-level technology choices and how responsibilities are distributed across containers (applications, services, databases).

A container is a separately runnable or deployable unit.

[Web App] ──→ [API Service] ──→ [Database]
                ↓
           [Background Worker] ──→ [Queue]

Recommended for: Every system. Essential for understanding deployment boundaries and technology choices.

Level 3: Component

Shows the major structural components inside a container and their interactions.

Components are the building blocks within a container (modules, controllers, services, repositories).

[OrderController] ──→ [OrderService] ──→ [OrderRepository] ──→ [Database]
                         ↓
                   [PaymentService] ──→ [PaymentGateway]

Recommended for: Complex containers. Useful for onboarding and design reviews.

Level 4: Code

Shows the implementation details of a specific component.

Typically represented as a class diagram, entity relationship diagram or detailed design document.

Recommended for: Critical or complex components where implementation detail matters.

Diagram Standards

All C4 diagrams should follow these conventions:

Event Modeling

Event modeling is a collaborative technique for designing systems driven by events and commands.

It is particularly useful for:

Core Concepts

ConceptMeaning
EventSomething that has happened in the past. Immutable.
Examples: OrderPlaced, PaymentReceived, InvoiceSent.
CommandAn intention to perform an action. May be rejected.
Examples: PlaceOrder, ProcessPayment, SendInvoice.
AggregateA cluster of domain objects treated as a unit.
Ensures consistency within its boundary.

Workshop Format

Event modeling is typically done as a collaborative workshop with domain experts and engineers.

  1. Big Picture: Identify business events across the domain. Place events on a timeline from left to right.
  2. Process Level: Add commands, actors and read models for each workflow.
  3. Design Level: Define aggregates, commands, events and constraints for each bounded context.

Artefacts

The workshop produces:

Choosing the Right Model

SituationRecommended Approach
New system, need to communicateC4 Level 1-2: Context and Container
overall architecturediagrams
Complex component, need detailC4 Level 3-4: Component and Code
Designing an event-driven systemEvent modeling workshop
Exploring a new domainEvent modeling big picture
Documenting existing architectureC4 Level 1-3: Reverse-engineer diagrams
Defining service boundariesEvent modeling or DDD context mapping

Keeping Models Current

Outdated diagrams are worse than no diagrams because they actively mislead.

A diagram that is 80% accurate and up to date is more valuable than a diagram that is 100% accurate but six months out of date.

AI Integration

AI assistants can help with system modeling by:

When asking AI for modeling assistance, provide:

Related Documents