deniz.in

Markets

Weather

Loading weather

· via Hacker News – Front Page (native)

Terrastruct open-sources its TALA diagram autolayout algorithm under MPL-2.0

Terrastruct has open-sourced TALA, its orthogonal autolayout engine built for software architecture diagrams, under MPL-2.0. It ships with D2 v0.9.0 and supports pinned node coordinates aimed at agentic diagram generation.

Terrastruct open-sources its TALA diagram autolayout algorithm under MPL-2.0

Terrastruct releases TALA under MPL-2.0

Terrastruct has open-sourced TALA, its automatic diagram layout engine, under the Mozilla Public License 2.0, the same license used for the D2 diagram-as-code language. According to the announcement on the D2 blog, which reached the front page of Hacker News, the algorithm ships bundled with D2 v0.9.0 and can be enabled with the --layout=tala flag. It is also available in the D2 browser playground, which the post says runs entirely client-side.

An orthogonal engine for architecture diagrams

TALA — Terrastruct's AutoLayout Algorithm — was built for software architecture diagrams rather than generic graphs. The D2 blog describes it as an orthogonal layout engine at its core: edges turn at right angles and nodes occupy two dimensions, closer to the way systems get sketched on a whiteboard. That is a deliberate contrast with the DAG-oriented engines D2 also ships, Dagre and ELK, which lay graphs out so they extend in one direction.

The implementation mixes techniques borrowed from graph-drawing research papers — cited in the source code — with original work. Instead of optimising a single metric, it evaluates candidate layouts against several notions of what the team calls aesthetic, including symmetry, median distance, flow and clustering similar nodes together. To make the comparison concrete, the post shows TALA-rendered diagrams next to Dagre and ELK output for public D2 files found on GitHub. The author notes these were not hand-picked, and some readers may prefer the non-TALA layout in individual cases.

Pinned coordinates, including for AI agents

TALA's most distinctive property is that node positions and sizes can be customised: coordinates can be locked in while the engine routes edges around them. The blog highlights this for agentic use cases, where language models can place elements reasonably well in two-dimensional space but still fumble routing — a job TALA takes over.

A hybrid mode goes further, mixing nodes with explicit coordinates and nodes left entirely to the layout engine. Example diagrams in the post pin a small group of nodes into a deliberate arrangement — printing stations held in a fixed line, motor assemblies fixed to the corners of a chassis — while everything else is placed automatically. Several of these positioning examples were AI-generated.

The tradeoffs

The announcement is unusually direct about where TALA falls short:

  • Non-determinism across edits. The algorithm searches using randomised seeds — three by default — and keeps the highest-scoring result. Identical seeds and input always reproduce the same diagram, but adding a single node can reshuffle the whole layout. Dagre and ELK instead absorb a new node with minimal disruption, which the author sometimes prefers.
  • Weaker on long flow graphs. For long, DAG-style diagrams the author often still reaches for Dagre or ELK.
  • Runtime. TALA can take longer on large diagrams, with runtime growing nonlinearly; comparative benchmarks are published in the d2lang/d2-benchmarks repository on GitHub.

Getting it

TALA requires no separate install for D2 users: it comes with D2 v0.9.0 and is selected via --layout=tala. The playground on the D2 site runs it in the browser. The post credits Gavin Nishizawa for broad contributions across TALA and Júlio César Batista for work on hierarchy algorithms, and says the team expects community improvements now that the code is open.

Why it matters

Automatic layout is a quietly difficult problem, and most diagramming tools depend on the same small set of academic engines. An orthogonal, aesthetics-driven engine released under a permissive license gives the wider tooling ecosystem a genuinely different option — including for AI agents that generate diagrams but cannot route edges reliably. Just as valuable is the candour: documented weaknesses on incremental edits, long DAGs and large inputs, backed by public benchmarks, let potential adopters judge fit before committing. With MPL-2.0 in place, the interesting follow-on is whether other tools embed TALA directly.

  • #open-source
  • #diagramming
  • #d2
  • #graph-layout
  • #developer-tools

Related posts