I needed flowcharts and sequence diagrams as images inside an agent pipeline — the kind of thing you sketch in Mermaid because nobody wants to draw boxes by hand. The obvious answer was Puppeteer: spin up headless Chrome, render the diagram, screenshot it. That's what every tutorial says, so that's what I did first.
Then I looked at the deploy bill. Every container rebuild pulled ~300MB of browser and its dependencies. Cold starts went from milliseconds to several seconds. Memory spiked to the point where my smallest worker tier started getting OOM-killed mid-render. I was paying a browser tax on every single deployment just to turn text into a PNG.
So I replaced the whole stack with a single-purpose endpoint that takes Mermaid syntax and returns a base64 PNG or SVG — flowcharts, sequence diagrams, class diagrams, gantt charts, no local render stack to install. The lesson I keep re-learning: before reaching for the general-purpose tool, measure what it actually costs you per deploy. Sometimes "just use a headless browser" is the expensive option dressed up as the standard one. I packaged it as https://x402.freeq.one/tools/mermaid.html, and my cold starts went back to where they belong.
Top comments (0)