---
title: "C4 Diagram: One Application Across Context, Container and Component Views"
description: "Follow one room-booking application through C4 context, container and component views, with editable sources, consistent boundaries and corrected mistakes."
url: "https://animatediagram.com/blog/c4-diagram"
updated: "2026-11-29"
published: "2026-11-29"
author: "Diagram Studio Editorial"
keywords:
  - "c4 diagram"
  - "editable c4 diagram templates"
  - "c4 diagram examples"
image: "https://animatediagram.com/blog/c4-diagram/cover-editorial.webp"
agent:
  instructions: "Search every Animated Diagrams page (guides, tools, pricing, policies) with keywords or a natural-language question instead of crawling. Results are Markdown with a link to each page and to its Markdown version."
  endpoint: "https://animatediagram.com/.well-known/search?q={query}"
  method: GET
  documentation: "https://animatediagram.com/agents.md"
---
# C4 Diagram: One Application Across Context, Container and Component Views

*Diagrams & workflows · Published 2026-11-29 · Updated 2026-11-29 · Diagram Studio Editorial · 14 min read*

Follow one room-booking application through C4 context, container and component views, with editable sources, consistent boundaries and corrected mistakes.

## Direct answer

A C4 diagram describes software architecture at one of four levels: context, containers, components or code. A context view shows one system and its neighbors; a container view opens that system into applications and data stores; a component view opens one container into internal building blocks. Keep names, responsibilities and boundaries consistent between views.

## Key takeaways

- Name one scope and one question for each C4 view.
- Keep the same application and element identities as the views zoom in.
- Separate structural relationships from runtime sequence and deployment topology.

## Choose the right C4 diagram level

The C4 model describes architecture at four levels: system context, containers, components and code. A C4 diagram is one view at one of those levels. Start by naming the scope and the question; adding more boxes is not the same as increasing useful detail.

This guide follows one fictional application, RoomBook, through three views. Context shows its users and neighboring systems. Containers show its applications and data store. Components open only its Booking API. Stable names and responsibilities make it possible to check whether the zoomed-in views still describe the same design.

**Use the smallest useful set of views.**

| Level | Question | Boundary in this guide |
| --- | --- | --- |
| 1. System context | Who uses the system, and what does it depend on? | RoomBook as one software system |
| 2. Container | Which applications and data stores implement it? | RoomBook decomposed into four containers |
| 3. Component | Which modules collaborate inside one container? | Booking API only |
| 4. Code | How is a component implemented? | Omitted; create only when it answers a specific question |

The [official C4 context guidance](https://c4model.com/diagrams/system-context) centers a software system and its directly related people and systems. The [container guidance](https://c4model.com/diagrams/container) then decomposes that system into applications and data stores. The [component guidance](https://c4model.com/diagrams/component) narrows scope to a single container; it recommends creating that detail when it adds value.

## The application and assumptions stay the same in every view

RoomBook lets employees reserve a meeting room for a fixed 30-minute slot. Employees sign in through an existing workplace identity system. A successful booking records the reservation and queues a confirmation email. The application owns its web app, API, worker and database; identity and email delivery are operated outside that ownership boundary.

- Employees reserve one room for one fixed 30-minute slot.
- Workplace Identity and Email Delivery are separately operated software systems.
- The application owns the Web app, Booking API, Booking database and Notification worker.
- A database uniqueness constraint on (room_id, slot_start) rejects concurrent duplicate reservations.
- The booking and outbox records are written in one shared database transaction.
- Outbox delivery is at least once; duplicate emails remain possible unless the email provider supports a suitable deduplication contract.

These are design choices for the worked example, not capabilities attributed to a real product. The fixed-slot rule matters: a uniqueness constraint can prevent two reservations for the same room and slot. A system allowing arbitrary overlapping time intervals would need a different availability constraint.

[Download the complete editable C4 model as JSON](https://animatediagram.com/blog/c4-diagram/roombook-c4-model.json). Each view below also includes Mermaid source. The JSON preserves shared element identities and assumptions; Mermaid provides a straightforward editable rendering of each separate level.

## 1. System context: RoomBook and its neighbors

At context level, treat RoomBook as one software system. The employee, workplace identity system and email delivery system sit outside it. A database, API controller or browser framework would answer a different question, so none belongs inside the RoomBook box at this level.

![RoomBook system context with employee, workplace identity and email delivery as external neighbors.](https://animatediagram.com/blog/c4-diagram/context.svg)

*One system is the focus; internal technology stays behind the boundary.*

**Labels and directions for the context view.**

| Arrow | From | To | Relationship |
| --- | --- | --- | --- |
| 1 | Employee | RoomBook | Finds rooms and manages reservations |
| 2 | RoomBook | Workplace Identity | Uses employee identity and signing keys |
| 3 | RoomBook | Email Delivery | Requests confirmation delivery |

The employee interacts with RoomBook to find rooms and manage reservations. RoomBook depends on workplace identity and sends confirmation requests to email delivery. The exact HTTPS routes and data schema are intentionally deferred until the container view.

A common modeling error is to call everything hosted by a cloud vendor “external”. Ownership of the application architecture and provider ownership are different boundaries. In this example, the team owns the booking data model and its use, so the managed database appears as a RoomBook container in the next view.

[Editable view JSON](https://animatediagram.com/blog/c4-diagram/context.json) · [Mermaid diagram source](https://animatediagram.com/blog/c4-diagram/context.mmd) · [SVG drawing](https://animatediagram.com/blog/c4-diagram/context.svg)

## 2. Containers: four parts inside RoomBook

Open the RoomBook system boundary and show four containers: a browser web app, a Booking API, a PostgreSQL database and a notification worker. In C4, “container” means an application or data store; it does not mean a Docker image. A single machine could host several of these containers, and one container could have several runtime instances.

![RoomBook system boundary contains web app, Booking API, database and notification worker; identity and email services remain outside.](https://animatediagram.com/blog/c4-diagram/container.svg)

*The software system contains four application or data-store containers.*

**Labels and directions for the container view.**

| Arrow | From | To | Relationship |
| --- | --- | --- | --- |
| 1 | Employee | Web app | Uses [HTTPS] |
| 2 | Web app | Workplace Identity | Signs in [OIDC / HTTPS] |
| 3 | Web app | Booking API | Requests rooms and bookings [JSON / HTTPS] |
| 4 | Booking API | Workplace Identity | Fetches signing keys [JWKS / HTTPS] |
| 5 | Booking API | Booking database | Reads rooms; commits booking + outbox [SQL / TLS] |
| 6 | Notification worker | Booking database | Claims outbox; records delivery [SQL / TLS] |
| 7 | Notification worker | Email Delivery | Submits confirmation [HTTPS API] |

The web app signs the employee in and sends authenticated requests to the API. The API checks access and commits a reservation plus an outbox record. The worker polls the outbox and calls the email service. The database is shared deliberately here; a team choosing independent service data ownership would draw a different design.

The arrows describe dependencies or requests in one direction. For example, “worker claims outbox rows” points from worker to database; it does not mean that the database initiates a push. A response body is part of the request exchange rather than a reason to use an unlabeled double-headed arrow.

This view does not specify replicas, network subnets, failover or where the worker is hosted. Those are deployment questions. Keep a production deployment view separate so a staging topology does not silently change what the application containers mean.

[Editable view JSON](https://animatediagram.com/blog/c4-diagram/container.json) · [Mermaid diagram source](https://animatediagram.com/blog/c4-diagram/container.mmd) · [SVG drawing](https://animatediagram.com/blog/c4-diagram/container.svg)

## 3. Components: open the Booking API only

Now open the Booking API container only. Its five components are Python modules in the same deployed API application: BookingController, AccessPolicy, BookingService, BookingRepository and OutboxWriter. They are implementation groupings, not five independently deployed services.

![The Booking API boundary contains controller, access policy, booking service, repository and outbox writer; web app, identity and database are supporting neighbors.](https://animatediagram.com/blog/c4-diagram/component.svg)

*Only the Booking API is decomposed; its five modules share one runtime and one transaction contract.*

**Labels and directions for the component view.**

| Arrow | From | To | Relationship |
| --- | --- | --- | --- |
| 1 | Web app | BookingController | POST /bookings [JSON / HTTPS] |
| 2 | BookingController | AccessPolicy | Checks identity and room permission [in-process] |
| 3 | AccessPolicy | Workplace Identity | Refreshes signing keys [JWKS / HTTPS] |
| 4 | BookingController | BookingService | Requests reservation [in-process] |
| 5 | BookingService | BookingRepository | Reads and writes within shared transaction [in-process] |
| 6 | BookingService | OutboxWriter | Adds notification within shared transaction [in-process] |
| 7 | BookingRepository | Booking database | Reads slots; inserts booking [SQL / TLS] |
| 8 | OutboxWriter | Booking database | Inserts outbox record [SQL / TLS] |

BookingController handles HTTP input and response mapping. AccessPolicy validates the employee identity and permission to book the room. BookingService coordinates the transaction. BookingRepository reads room state and writes the reservation; OutboxWriter records the pending confirmation within that same database transaction.

The web app, identity system and database remain visible as supporting neighbors because they connect directly to these components. The notification worker is outside the API and has no direct component call here, so it is not added merely to repeat the entire container diagram.

“Same transaction” is an architectural requirement, not something an arrow guarantees. The service passes one shared unit of work to the repository and outbox writer. If those components commit independently, the design can create a booking without its queued notification, contradicting the assumption we started with.

[Editable view JSON](https://animatediagram.com/blog/c4-diagram/component.json) · [Mermaid diagram source](https://animatediagram.com/blog/c4-diagram/component.mmd) · [SVG drawing](https://animatediagram.com/blog/c4-diagram/component.svg)

## Trace one booking across the three levels

A static C4 view explains structure. The following request trace explains behavior without turning the static arrows into a misleading execution sequence.

1. The employee uses the web app and signs in with Workplace Identity. The web app receives the credentials required by the chosen OIDC flow.
2. The web app sends a booking request with a room, fixed slot and request key to BookingController over HTTPS.
3. BookingController asks AccessPolicy to validate the token and permission. Signing keys can be cached and refreshed from the identity system; this design does not require a live identity request for every booking.
4. BookingService begins one shared database transaction. BookingRepository inserts the reservation; the unique room-and-slot constraint rejects a conflicting concurrent insert.
5. OutboxWriter adds a pending confirmation in the same transaction. The transaction commits both records or neither. The API returns the recorded reservation.
6. The notification worker claims the pending outbox record, submits a message to Email Delivery and records the result. If delivery fails, the reservation remains valid while notification work is retried.

The trace exposes a useful distinction: booking success and email delivery success are different outcomes. A notification failure should not make the browser report that the room is still available. Conversely, a database conflict means the reservation did not succeed even if the employee saw availability a moment earlier.

**Failure behavior is a design contract to implement and verify.**

| Failure | Expected behavior in this example | Where the rule lives |
| --- | --- | --- |
| Invalid or unauthorized token | Reject without creating a reservation | AccessPolicy and controller response mapping |
| Two employees book the same slot | One reservation commits; conflicting request receives a conflict result | Database constraint and BookingService error mapping |
| Browser times out after commit | Look up the recorded result by request key before creating another reservation | API idempotency behavior and persistence |
| Email provider is unavailable | Keep booking; retry the pending outbox message | Notification worker |
| Worker crashes after sending but before marking delivered | Retry may send a duplicate unless a delivery deduplication contract prevents it | Worker and email provider integration |

A request key alone does not create idempotency. Bind it to the authenticated employee and request payload, store the outcome durably and define what a replay returns. The example names that requirement; its diagrams are not proof that a codebase implements it.

## Correct the boundary mistakes before adding detail

**Each correction preserves one level of abstraction.**

| Incorrect example | Why it is wrong for this view | Correct version |
| --- | --- | --- |
| Context: Employee → API → PostgreSQL | Internal containers are exposed where RoomBook should be one system | Employee → RoomBook, with identity and email as neighbors |
| Container: controller, service, repository and database | Three in-process modules are mixed with a data-store container | Show Booking API as one application; expand its modules in the component view |
| Component: Web app, API, worker and database all expanded together | The view decomposes several containers at once | Expand Booking API only; keep directly connected neighbors as supporting elements |
| Component: separate boxes imply separate services | The reader may infer independent deployment or networking | Label Python modules and in-process relationships explicitly |
| Any level: unlabeled double-headed arrows | Direction and relationship meaning cannot be inspected | Use one directed arrow per stated relationship |
| Container: production replica counts replace responsibilities | Deployment and static decomposition become entangled | Keep responsibilities here and put environment topology in a deployment view |

A supporting database on the component view is valid; decomposing that database into tables beside Python modules would change the scope. The issue is the role of the element in the view, not a blanket rule that no neighboring element can come from another level.

The [official notation guidance](https://c4model.com/diagrams/notation) asks for explicit element types, responsibilities, technologies, labeled directional relationships and a diagram key. It also makes clear that C4 does not mandate one drawing notation or color palette. The cream and purple diagrams here follow those semantics with their own visual style.

## Edit the model and test consistency

1. Rename a shared entity in all views. RoomBook, Booking API and Booking database should keep one meaning as you zoom.
2. Change the boundary before moving a box. If identity becomes part of your owned application, update the context and container assumptions together.
3. Keep container technologies on container and component views. Do not make a new deployment instance look like a new application responsibility.
4. For each component, ask which single container contains it. If the answer is unclear, the view may be mixing levels.
5. Read each arrow as a sentence from source to destination. Put the protocol on inter-process relationships and avoid using visual direction to imply an undocumented timing rule.
6. Walk one success and one failure through the set. If the trace depends on a missing participant, add it at the appropriate level or state the omitted scope.

The downloads are source material for this worked example. Open Mermaid in a compatible editor to modify each diagram; edit the JSON to preserve the complete model and assumptions. A syntax-valid diagram can still describe the wrong architecture, so review responsibilities and boundaries with the people who build and operate the system.

If your next task is to explain a particular request rather than the static architecture, use a separate [sequence diagram](https://animatediagram.com/blog/how-to-animate-a-sequence-diagram). Preserve the C4 views as the stable map and let the request trace answer the timing question.

Use the views to review a proposed change before implementing it. If confirmation delivery moves into the API process, remove the worker container, add the responsibility to an API component, and revisit the failure trace: an email timeout now affects the request path. A boundary change that appears in only one view leaves readers with two incompatible descriptions of the system.

## Sources

- [System context diagram](https://c4model.com/diagrams/system-context) — C4 model. System-level scope and directly connected users and systems.
- [Container diagram](https://c4model.com/diagrams/container) — C4 model. Applications and data stores; deployment is a separate view.
- [Component diagram](https://c4model.com/diagrams/component) — C4 model. Decomposition of one container and relevant supporting elements.
- [Notation](https://c4model.com/diagrams/notation) — C4 model. Self-describing types, technologies, relationship labels and key.

## Keep reading

- [How to animate a sequence diagram in Diagram Studio](https://animatediagram.com/blog/how-to-animate-a-sequence-diagram)
- [Swimlane Diagram: 8 Examples Showing Handoffs, Loops and Approvals](https://animatediagram.com/blog/swimlane-diagram)
