Skip to content
Back to portfolio

Personal Project · 2026 - Present

Schematic-inator — Discord D2 Diagram Bot

A self-hosted Discord bot that renders D2 diagram scripts into PNGs, triggered via slash command or a right-click message action on any fenced code block. D2 compiles and lays out diagrams entirely locally, so the bot has no dependency on any third-party rendering service being up.

Go
Discord
Docker

How it works

  • Two ways to trigger a render: a /schematicinator slash command (inline script or an attached .d2 file) or right-click → Apps on any message with a fenced D2 code block.

  • Fully local rendering pipeline — D2 compiles and lays out the diagram in pure Go, then the SVG is rasterized to PNG by shelling out to resvg, a ~3MB static binary, instead of bundling headless Chromium for D2's own PNG export.

  • Stateless by design: no database, no persisted scripts or images — everything lives in memory for the duration of a single render (20s timeout) and is discarded after the reply is sent.

  • Deployed on Fly.io as a single persistent-gateway machine; the README documents why it must always deploy with --ha=false, since two machines on one bot token means duplicate replies to the same command.

  • In-character error and success messages (Phineas and Ferb's Dr. Doofenshmirtz) picked at random, with D2 compile errors surfaced verbatim so users can fix their own syntax.