flowgraph-cli 0.3.0: infrastructure diagrams, README sync and saved diagrams

The command-line tool now draws diagrams from Compose, Kubernetes, Terraform and more, keeps README diagrams current in CI, and works with diagrams saved in your account.

News · · 3 min read

flowgraph-cli is Flowgraph Studio on the command line: it renders and checks Mermaid with the editor's themes and icons, and draws diagrams from a folder of source code. Version 0.3.0 adds three things. It reads the repository's configuration as well as its code, it keeps the diagrams in a README up to date from CI, and it works with diagrams saved in your Flowgraph Studio account.

npx flowgraph-cli@0.3.0 --help

Diagrams from the repository's configuration

flowgraph scan draws what a repository's configuration already describes, as From the repository's files does when you import a repository in the app. It needs no API key and makes no network request.

npx flowgraph-cli scan                              # lists what it found
npx flowgraph-cli scan --file docker-compose.yml    # prints that diagram's Mermaid
npx flowgraph-cli scan --only kubernetes --out docs/k8s.mmd
Diagram Drawn from
compose Docker Compose services, ports, volumes and networks
kubernetes Ingresses, Services, workloads and what they use
terraform Resources and modules, and the references between them
openapi Endpoints grouped by tag
pipeline GitHub Actions, GitLab CI, Bitbucket Pipelines and Azure Pipelines jobs
sql, prisma The data model, as an ER diagram
packages npm, pnpm and Yarn workspaces

The Mermaid is the app's own, byte for byte, so a diagram drawn here and one imported in the editor match. Infrastructure diagrams from Compose, Kubernetes and Terraform shows what each one includes and what it can't know.

A Kubernetes diagram drawn by flowgraph scan, open in the Flowgraph Studio editor: the shop Ingress routes / to the web Service and /api to the orders Service, each Service leads to its Deployment, and the orders and mail-worker Deployments use the orders-config ConfigMap and the db-credentials Secret
flowgraph scan --only kubernetes: Ingress routes, Services, Deployments and the configuration they use, from one manifest.

README diagrams that keep themselves current

flowgraph sync reads a flowgraph.yml that lists the diagrams you want, draws each one (from the code, the configuration, or your account), renders those that changed, and fills them into marked blocks in the README:

<!-- flowgraph:architecture -->
<!-- /flowgraph:architecture -->

With --push, it commits only its own files and pushes them to the branch CI is building, on GitHub Actions, GitLab CI, Bitbucket Pipelines or Azure Pipelines. With --check, it changes nothing and fails when a diagram is out of date, which suits a pull request. Your README's architecture diagram, redrawn on every push walks through it.

A few details that matter in CI:

  • Renders only what changed. .flowgraph-sync.json remembers a fingerprint of each image, so an unchanged diagram uses none of your monthly renders.
  • Mermaid blocks GitHub can draw. A diagram kept as Mermaid goes into the README with plain labels, because GitHub, GitLab and Azure DevOps draw Mermaid without Flowgraph's icons. Render it to SVG to keep them.
  • Careful with files. Sync only removes images and Mermaid files it wrote itself, only inside the repository, and never while a render is failing.
  • Never pushes a pull request's build. CI builds a merge of the request there, which belongs on neither branch, so --push refuses and points you to --check.

Diagrams saved in your account

On Pro and Pro Max, with a key that can read and change saved diagrams:

  • draw: saved puts a diagram you drew in the app into the README, rendered with its own theme. Run sync on a schedule and edits made in the editor reach the repository.
  • save-to: goes the other way: the diagram drawn from the code updates a saved one, keeping its title, theme and the positions you gave its nodes in Manual mode. Each change lands in the diagram's version history and shows as changed since its last review.
  • flowgraph diagrams lists your saved diagrams and their ids.

More in Diagrams you draw in Flowgraph Studio, now in your README.

Upgrading

Nothing that worked in 0.2 has changed. In CI, pin the new version:

- run: npx --yes flowgraph-cli@0.3.0 check docs

The full list of options is in the README on npm, and the setup on each Git host is in Keep README architecture diagrams up to date in CI.

More from the blog

Follow the blog by RSS