Infrastructure diagrams from Compose, Kubernetes and Terraform, kept current in CI

flowgraph scan draws diagrams from the configuration you already have, and flowgraph sync keeps them in your README. What each one shows, and what it can't know.

News · · 2 min read

Most repositories already describe their infrastructure: a Compose file for local development, Kubernetes manifests for the cluster, Terraform for the cloud. Those files are precise, reviewed and kept current, because the system breaks when they aren't. They're just hard to read as a picture.

flowgraph scan turns them into one, on your machine or in CI, and flowgraph sync keeps the picture in your README.

A Terraform diagram drawn by flowgraph scan, open in the Flowgraph Studio editor in the Blueprint CAD theme: a load balancer, listener and target group, an ECS cluster, service and task definition, an SQS queue, a Postgres database and its subnet group, a private subnet and the VPC, with arrows wherever one resource refers to another
Eleven Terraform resources from one file, drawn with an arrow wherever one refers to another.

What it draws

From You get
Docker Compose A node for each service with an icon from its image and its published ports. depends_on and links are arrows, named volumes are cylinders, and networks are groups.
Kubernetes manifests Ingresses and their routes to Services, Services to the workloads they select, and the ConfigMaps, Secrets (names only, never values) and volume claims each workload uses.
Terraform Each folder of .tf files, with a node for each resource and module and an arrow wherever one refers to another.
OpenAPI The endpoints, grouped by tag, with a badge for each method.
CI pipelines GitHub Actions, GitLab CI, Bitbucket Pipelines and Azure Pipelines: triggers, jobs and the order they run in.
SQL and Prisma The data model as an ER diagram, from a schema or from the migrations replayed in order.

Run it in a checkout to see what it finds:

npx flowgraph-cli@0.3.0 scan
npx flowgraph-cli@0.3.0 scan --only kubernetes --out docs/k8s.mmd

It needs no API key and makes no network request, and the same files always give the same diagram, byte for byte what the app's repository import draws.

Keep it in the README

List the diagrams in flowgraph.yml, mark where each goes in the README, and run flowgraph sync in CI after every push:

diagrams:
  services: compose
  cluster: kubernetes
  cloud:
    draw: terraform
    folder: infra

When someone adds a service or a resource, the next push redraws that diagram and commits it. When nothing changed, nothing is rendered or committed.

What a configuration diagram can't know

These diagrams show what the files declare, which isn't always what runs:

  • Compose often describes local development. A production setup may look different.
  • A call over HTTP without a depends_on line has no arrow. The configuration doesn't mention it, so neither does the diagram.
  • Terraform is drawn from the code, not the state. The diagram shows your .tf files, not what exists in your cloud account today.
  • Kustomize overlays and Helm charts aren't drawn. Plain manifests are.

That makes them a reliable "what we declared" view. For the "why", pair them with a diagram you draw by hand, which sync can keep in the README too: see Diagrams you draw in Flowgraph Studio, now in your README.

The full setup for GitHub, GitLab, Bitbucket and Azure DevOps is in Keep README architecture diagrams up to date in CI.

More from the blog

Follow the blog by RSS