Skip to content

Deployment diagrams

The map says what the software is; a deployment diagram says where each part of it runs. In C4 (https://c4model.com/diagrams/deployment) it shows, for one environment (production, staging, a developer's machine), the deployment nodes (physical, virtual or containerised infrastructure, or an execution environment: a server, a VM, a Docker host, a Kubernetes cluster, a database server), nested as they are, the instances of the containers and software systems that run on them (×N when several copies run), the infrastructure nodes the traffic goes through (a load balancer, DNS, a firewall), and the relationships between them.

The explorer draws one per environment in its Deployment tab (Y), when the model has a deployment.

The example's Deployment view: the environment Local (Docker Compose), one Docker host drawn as a frame with a 3-D edge, and inside it the seven instances of the containers and data stores of the map (Web app, API service, Worker, minio-init, PostgreSQL, Redis, MinIO), each with the image and the port it runs with; arrows between them are the map's relationships, with their labels; the panel describes the environment

Reading the view

  • Deployment nodes are frames with a solid outline and a 3-D edge (system boundaries on the map stay dashed); their technology is in the header, and ×N with copies stacked behind when there are several.
  • Instances look like their box on the map, with its colour, icon and name, and say how they run there: the image, the runtime, the port. Infrastructure nodes are plain boxes with a dotted outline.
  • Arrows are the map's own relationships, lifted to the instances (an arrow from a component of the API to the database becomes an arrow between their instances), merged per pair as on the map; the relationships only the deployment has (a load balancer forwarding to the web servers) are in the accent colour.
  • Click a node or an instance: what is inside it, the frames around it and what it talks to stay bright. The panel shows where it runs, its technology, its relationships in this environment, the other environments it runs in and the file and line it comes from. Show on map (or a double-click) goes to its box on the map; on the map, a container's panel lists Deployed in, and each entry comes back here.
  • Mermaid: the bar's Mermaid button (or G) shows the environment as Mermaid C4Deployment, with a preview and downloads, ready for a README.
  • The view is in the URL: #view=deploy&env=local&dsel=api.

Writing it

The deployment section of model.js (the data model has every field):

deployment: {
  environments: [
    { id: 'local', name: 'Local (Docker Compose)',
      nodes: [
        { id: 'docker-host', name: 'Docker host', tech: 'Docker Engine · Docker Compose', path: 'docker-compose.yml', line: 1,
          containers: [
            { of: 'web', tech: 'nginx 1.27 image · port 3000 → 80', path: 'docker-compose.yml', line: 2 },
            { of: 'api', tech: 'python:3.12-slim · uvicorn · port 8000', path: 'docker-compose.yml', line: 9 },
            { of: 'postgres', tech: 'postgres:16-alpine · volume pgdata', path: 'docker-compose.yml', line: 33 }
          ] }
      ] }
  ]
}
  • of is the id of a container or data store of the map (containers), or of a software system (systems); instances is how many copies run there; tech how it runs there.
  • Nodes nest (nodes inside a node): an account, a region, a cluster, a namespace, a workload.
  • infra holds infrastructure nodes; relationships (per environment) only what the map does not already say.
  • Only from the repository's deployment files: docker-compose, Kubernetes manifests or Helm charts, Terraform, Dockerfiles, Procfiles, CI deploy jobs, platform configs (fly.toml, render.yaml). One environment per real target; no invented replicas, regions or load balancers. The skill does this when it builds the explorer, and Modelling with C4 says what is a node, an instance or an infrastructure node.
  • In the page, edit mode's drawer has a Deployment section (the section as JSON, checked when applied, undoable).
  • check-model.mjs validates it, checks every path and line with --root, and prints a DEPLOY line per environment, with the containers that no environment runs.

Elsewhere

  • RDF: c4:DeploymentEnvironment, c4:DeploymentNode, c4:ContainerInstance, c4:SoftwareSystemInstance, c4:InfrastructureNode and c4:DeploymentRelationship in the graph; a page built from the graph alone has the same deployment.
  • Mermaid: node model-to-mermaid.mjs model.js --deployment local writes one environment as C4Deployment; --all adds one diagram per environment.
  • Agents: get_deployment returns each environment's nodes, instances and relationships; show_deployment opens the view on an environment and selects an item or a box's instance.