Dagre
Automatic layout engine for directed graphs in JavaScript
Repository Health
Technical Analysis
Dagre is a JavaScript library that computes the positions of nodes and edges for directed graphs, so you can render clean, readable diagrams on the client without hand-placing anything. You describe a graph as nodes and edges with sizes and labels, call a single layout function, and Dagre assigns x/y coordinates and edge routing points using a layered (Sugiyama-style) algorithm.
It is rendering-agnostic: Dagre only does the math, leaving you free to draw the result with SVG, Canvas, D3, React, or any other toolkit. This separation is why it underpins many higher-level diagramming tools and flowchart renderers across the ecosystem.
What You Get
- A single
layout(graph)call that assigns x/y coordinates to nodes and routing points to edges - Configurable layout direction (top-bottom, left-right), node/edge spacing, and ranking alignment
- A bundled
graphlibGraph data structure for building and querying the input graph - Support for compound (nested/cluster) graphs and edge labels that reserve their own space
- Rendering independence, so results can be drawn with SVG, Canvas, D3, or any framework
Common Use Cases
- Auto-laying out flowcharts, state machines, and process diagrams
- Visualizing dependency trees, build graphs, or data pipelines
- Powering interactive node-and-edge editors and diagramming apps
- Rendering DAGs such as workflow, org, or provenance graphs
Under The Hood
Architecture - Dagre’s layout() entry point (lib/layout.ts) builds an internal working graph and runs an ordered pipeline of transformation passes over it: makeSpaceForEdgeLabels, acyclic.run (breaks cycles), nestingGraph.run (for compound graphs), rank (assigns nodes to layers via lib/rank/network-simplex.ts), order (crossing minimization using barycenter and median heuristics under lib/order/), position (x-coordinate assignment via the Brandes-Köpf algorithm in lib/position/bk.ts), then edge normalization and denormalization, finally writing coordinates back onto the input graph. Each stage is a small focused module, making the classic Sugiyama layered-drawing method easy to follow end to end.
Tech Stack - Written in TypeScript and compiled with esbuild via build.ts into CJS, ESM, and type-declaration bundles. Its only runtime dependency is @dagrejs/graphlib (the sibling graph data-structure library), keeping the footprint small. Tooling includes Jest for tests, ESLint with typescript-eslint, and tsx for build/version scripts.
Code Quality - The repository carries an extensive test suite (~41 spec files under test/, mirroring the lib/ module layout, including targeted tests for ranking, ordering, and positioning) plus a benchmark harness. Modules are small and single-purpose, types are declared centrally in lib/types.ts, and the layered algorithm’s stages are individually covered, reflecting a mature, well-tested codebase.
API Design - The public surface is deliberately minimal: import dagre, build a Graph, set node/edge/graph labels, and call dagre.layout(g) to have coordinates written in place. This one-call ergonomics is a strength, though most configuration options and examples live in the project wiki rather than the terse in-repo README, which raises the initial discovery curve for newcomers.
Used by 47 apps in this directory
Refly
AI Development · Automation · No Code Platforms
Build deterministic, versioned agent skills from natural language—run them anywhere from Claude Code to Slack.
Rill
Analytics · Data Engineering
The fastest BI tool for humans and agents — define metrics, models, and dashboards as code and query them instantly on ClickHouse or DuckDB.
Skyvern
AI Agents · Automation
Skyvern (YC S2023) automates browser-based workflows by pairing LLMs with computer vision, letting agents click, fill, and extract data on sites they've never seen, without brittle XPath selectors that break on every layout change.
Supabase
Authentication · Databases · Developer Tools
The open-source Postgres development platform that replaces Firebase with authentication, real-time APIs, edge functions, storage, and vector embeddings — all built on PostgreSQL.
superglue
AI Agents · Data Engineering · Developer Tools
superglue is an AI-agent-driven integration engine that turns plain-English descriptions of enterprise systems into production-grade API tools, ERP/CRM connectors, and data pipelines — self-hosted or cloud, Y Combinator-backed (W25).
tabularis
Databases · Developer Tools
Open-source desktop SQL workspace with built-in PostgreSQL, MySQL, and SQLite drivers, SQL notebooks, a visual query builder, and a built-in MCP server for AI agents like Claude and Cursor.
TaskView
Productivity · Project Management
Self-hosted project and task management platform for software teams, with Kanban boards, sprints, time tracking, GitHub/GitLab integrations, and an MCP server for AI assistants.
Tracecat
AI Agents · Automation · Security
Open-source agentic security automation platform that runs AI agents and durable workflows at scale with sandboxed execution.
twenty
CRM
The open-source CRM you build, ship, and version like the rest of your stack — with customizable objects, AI agents, and a TypeScript SDK.