Skip to content
Tech Atlas, home
Search
Esc
  • All roadmapsBrowse every learning path
  • ExploreFind a technology area
  • ProjectsGuided projects and builds
  • My AtlasYour learning dashboard
Lesson 1 of 6 · Concept · 20 min · revision 1

Abstractions first: people, systems, containers, components

Learn the small vocabulary of the C4 model (person, software system, container, component and code), decide what each box in a real system is before you draw it, and write those decisions down as a model that a tool can check.

Contentsand lesson path

On this page

  1. Why it matters
  2. Four abstractions, plus code
  3. Cases that trip people up
  4. Writing the abstractions down as a model
  5. Check your understanding
  6. Apply it
  7. Review prompt

Lessons of C4 & Architecture Documentation

  1. Abstractions first: people, systems, containers, components Concept · 20 min
  2. Diagramming a ride-booking system at three zoom levels Worked example · 25 min
  3. Deployment and dynamic views, and where UML still helps Concept · 20 min
  4. Diagrams as code in a docs-as-code workflow Lab · 25 min
  5. Deciding what to document and for whom Concept · 15 min
  6. Diagram review check Knowledge check · 6 questions

What you will learn

  • Draw C4 system context, container and component diagrams with consistent notation, legends and scope.

01. Why it matters

Ask five engineers to draw the system they work on and you usually get five different pictures. One box is labelled "backend", another "business logic". Some arrows have labels and some do not. Colours mean something to the person who drew them and nothing to anyone else. One diagram mixes a whole database server with a single Python class. Each picture made sense in the meeting where it was drawn, but a new team member cannot learn much from it a month later.

The C4 model, created by Simon Brown, tackles this by agreeing on the words before the pictures. It gives you a small, fixed set of abstractions (kinds of thing that can appear in a diagram) and a few diagram types that zoom in on them, much like a map app that goes from country to city to street. The name comes from the four core diagrams: system context, container, component and code.

C4 does not prescribe shapes or colours: it is notation independent. A box can be a rectangle, a cylinder or an icon. What C4 does insist on is that every element has a clear type, so that a reader always knows whether they are looking at a whole system, one running application or a part inside it. Getting those types right is most of the work, and it is what this lesson is about.

02. Four abstractions, plus code

C4 describes the static structure of software with these building blocks, from the outside in:

  • A person is a human who uses the software: a role such as Patient or Receptionist, not a named individual in most diagrams.
  • A software system is the highest level: something that delivers value to its users. It covers the system you are describing and the other systems it depends on, such as a payment provider. A useful test from the C4 site: a software system is something one team builds, owns and can see inside. Product domains, business capabilities and squads are usually not software systems.
  • A container is an application or a data store that must be running for the system to work. Examples: a server-side web application, a single-page app running in the browser, a mobile app, a batch job, a serverless function, a database schema, an object-storage bucket. The word has nothing to do with Docker: a container is a runtime boundary around code that executes or data that is stored, however you package it.
  • A component is a group of related functionality behind a well-defined interface, inside one container. Components are not deployed separately; all components of a container run in the same process.
  • Code means the classes, functions and tables that make up a component. Teams rarely draw this level by hand, because an IDE can show it on demand.

Each level is made of the one below it. A software system is one or more containers, a container holds components, and a component is implemented by code. The four core diagrams follow the same order. A system context diagram shows your system as one box with its people and neighbouring systems. A container diagram opens that box. A component diagram opens one container. A code diagram opens one component. The C4 site recommends context and container diagrams for every team and treats the other two as optional: draw them only where they add value.

03. Cases that trip people up

Most arguments about C4 diagrams are really arguments about one of these cases. Deciding them explicitly, once, keeps every diagram consistent.

  • A web app with a JavaScript front end. A server that renders HTML pages is one container. A single-page app that runs in the browser and calls an API is a second container, even if the same server sends its files, because it runs in a separate process and talks to the server over the network.
  • Libraries, packages and modules. A JAR file, a Python package or a shared library organises code; it does not run on its own. It is not a container, and it shows up inside the containers that use it.
  • Managed services. You do not run the cloud provider's object storage or database service, but you do own the bucket or schema you created and the data in it. The C4 site recommends drawing them as containers of your system.
  • Microservices. It depends on who owns them. If one team owns all the services, each service is a group of containers (often an API and its database schema) inside one software system. If each service has its own team, each one becomes a software system in its own right, and the other teams' services appear as external systems.
  • Message brokers. Drawing the broker as one box in the middle hides who is coupled to whom. The C4 site suggests treating each queue or topic as a container (a data store for messages), or putting the queue name on the arrow between producer and consumer.

04. Writing the abstractions down as a model

A drawing tool only knows boxes and lines, so it cannot tell you that you put a class next to a database server. A modelling tool keeps one model of the elements and their relationships, and each diagram is a view that selects part of it. Structurizr DSL is a popular text format for this. (DSL means domain-specific language: a small language made for one job.) The file below describes a clinic's appointment system. Nesting shows the hierarchy: components sit inside a container, and containers inside the software system. Each relationship reads as a sentence, with the technology last.

Structurizr DSL · clinic/workspace.dsl
workspace "Clinic" "The four C4 abstractions, using a clinic as the example." {

    model {
        patient = person "Patient" "Books, moves and cancels visits."
        reception = person "Receptionist" "Runs the day's schedule."

        clinic = softwareSystem "Appointment System" "Books visits, sends reminders." {
            site = container "Booking website" {
                description "Server-rendered pages for patients and staff."
                technology "Python 3.12, Django"
                slots = component "Slot finder" "Finds free slots." "Python module"
                bookings = component "Booking views" "Handles bookings." "Django views"
            }
            job = container "Reminder job" {
                description "Texts every patient the day before a visit."
                technology "Python 3.12, cron"
            }
            db = container "Appointments database" {
                description "Doctors, slots and bookings."
                technology "PostgreSQL 18 schema"
            }
        }
        sms = softwareSystem "SMS gateway" "Delivers text messages." "External"

        patient -> bookings "Books visits with" "HTTPS"
        reception -> bookings "Manages the schedule with" "HTTPS"
        bookings -> slots "Asks for free slots" "Python call"
        slots -> db "Reads slots from" "SQL over TCP"
        bookings -> db "Writes bookings to" "SQL over TCP"
        job -> db "Reads tomorrow's visits from" "SQL over TCP"
        job -> sms "Sends reminders through" "JSON/HTTPS"
    }

    views {
        systemContext clinic "ClinicContext" {
            include *
        }
        container clinic "ClinicContainers" {
            include *
        }
        component site "WebsiteComponents" {
            include *
        }
    }
}
Terminal (install Structurizr as shown in the lab, lesson 4)
java -jar "$STRUCTURIZR_WAR" validate -workspace workspace.dsl && echo valid
java -jar "$STRUCTURIZR_WAR" list -workspace workspace.dsl
Expected output (validate)
valid
Expected output (list)
 - Person://Patient
 - Person://Receptionist
 - SoftwareSystem://Appointment System
   - Container://Appointment System.Appointments database
   - Container://Appointment System.Booking website
     - Component://Appointment System.Booking website.Booking views
     - Component://Appointment System.Booking website.Slot finder
   - Container://Appointment System.Reminder job
 - SoftwareSystem://SMS gateway

The list command prints every element with its type, indented by level. That is the abstraction hierarchy written out: two people, the system in scope with three containers, two components inside the website, and one external system. Notice the decisions behind it. The website renders its pages on the server, so it is one container. The reminder job runs on its own schedule, so it is a separate container even though it is written in the same language. The database schema is a container because the system cannot work without it running.

The model also protects the zoom levels. Add the line include db to the context view and run validate again: it fails with The element "db" can not be added to this type of view, followed by the line number. A context view may show people and software systems only, so the tool stops you from mixing levels before anyone reads the diagram. If you want to see the pictures now, paste the file into the free Structurizr playground at playground.structurizr.com; the lessons themselves never depend on images.

05. Check your understanding

Practice check · 3 questions

Choosing the right abstraction

Decide what each piece of a ride-booking system is in C4 terms.

Q1. A support console is a React single-page app. Its built files are served by the same FastAPI process that runs the Booking API, and in the browser the app calls that API with JSON. How many containers do these make on the container diagram?
Q2. A `pricing` Python package is imported by both the Booking API and the dispatch worker. It has its own repository and version number. Where does it belong in the C4 model?
Q3. Your team created a bucket in a cloud object-storage service to keep ride receipts as PDF files. The cloud provider runs the storage service itself. How should the bucket appear?
Practice only: not graded, not saved, not evidence.

06. Apply it

This is the first step of the skill project: a model of a system you work on, kept as code, with context, container, component and deployment views, checked in CI and linked from an architecture README.

  1. List the people (roles) who use your system and the external systems it talks to.
  2. List the containers. For each one, write one sentence that answers "what must be running for this to work?" and note its main technology.
  3. Settle the tricky cases from this lesson for your system: front ends, shared libraries, managed services, services owned by other teams, queues and topics. Write each decision down in one line, so the next person does not reopen it.
  4. Turn the lists into a first workspace.dsl with a context view and a container view, and run validate and list on it.

07. Review prompt

Without looking back: name the C4 abstractions from the outside in and give one example of each from a system you know. Explain why a container is not the same as a Docker container. Then say how you would draw a message queue, a shared library and a microservice owned by another team, and why.

References

Your progress

Reading state

Sign in to save that you finished reading this lesson.

Sign in to mark reading complete

Prove this skill

6 questions · about 5 minutes · scored automatically. Marking a lesson as read never demonstrates a skill.
Take the skill check