npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@de-otio/diagram-drc

v0.1.5

Published

Design Rule Check engine for auto-generated diagrams

Readme

diagram-drc

Design Rule Check engine for auto-generated diagrams.

Just as IC layout tools run DRC to catch spacing violations and routing issues in silicon, diagram-drc runs quality checks on graph layouts and can auto-fix violations.

Features

  • Check mode — detect layout quality issues without modifying the diagram
  • Fix mode — automatically resolve violations (crossing minimization, spacing, etc.)
  • Pluggable rules — built-in rules for common issues, easy to add your own
  • Format-agnostic core — works with any graph representation
  • draw.io renderer — render layouts to mxGraph XML (draw.io format)
  • Dagre layout — built-in wrapper for the Dagre directed graph layout engine

Quick start

npm install diagram-drc
import { createEngine, builtinRules, dagreLayout, renderMxGraph } from 'diagram-drc';

// Define your graph
const spec = {
  nodes: [
    { id: 'a', label: 'Service A', width: 48, height: 48 },
    { id: 'b', label: 'Service B', width: 48, height: 48 },
    { id: 'c', label: 'Database',  width: 48, height: 48 },
  ],
  edges: [
    { id: 'e1', source: 'a', target: 'c' },
    { id: 'e2', source: 'b', target: 'c' },
  ],
  groups: [
    { id: 'g1', label: 'Backend', children: ['a', 'b'] },
    { id: 'g2', label: 'Data',    children: ['c'] },
  ],
};

// Layout with Dagre
const layout = dagreLayout(spec);

// Run DRC — check for issues
const engine = createEngine({ rules: builtinRules() });
const report = engine.check(layout, spec);
console.log(report.passed ? 'All checks passed' : `${report.violations.length} violation(s)`);

// Or fix issues automatically
const { layout: fixed, report: fixReport } = engine.fix(layout, spec);

// Render to draw.io
const xml = renderMxGraph(fixed, spec, { title: 'Architecture' });

Built-in rules

| Rule | Description | |------|-------------| | crossing-minimization | Reorders sibling nodes within groups to minimize edge crossings | | spacing | Ensures minimum distance between node bounding boxes |

Writing custom rules

import type { LayoutRule, LayoutResult, GraphSpec, Violation } from 'diagram-drc';

const myRule: LayoutRule = {
  id: 'my-custom-rule',
  description: 'Check something specific to my diagrams',
  severity: 'warning',
  check(layout, spec) {
    // Return violations found
    return [];
  },
  fix(layout, spec) {
    // Return corrected layout
    return layout;
  },
};

engine.addRule(myRule);

API

Engine

  • createEngine(options?) — create a DRC engine
  • engine.check(layout, spec) — detect violations (read-only)
  • engine.fix(layout, spec) — fix violations and report remaining issues
  • engine.addRule(rule) — add a rule (chainable)

Layout

  • dagreLayout(spec, options?) — run Dagre layout on a graph

Render

  • renderMxGraph(layout, spec, options?) — render to draw.io mxGraph XML

License

MIT