DEV Community

crabcheng
crabcheng

Posted on Originally published at mryk123.cn

Draw.io Architecture Diagrams: Web, Desktop, or Self-Hosted? A Team's Real-World Breakdown

Here's a counterintuitive truth about architecture diagrams: the more "convenient" your diagramming tool feels, the harder the rework hits later.

I've watched too many people open draw.io's web version for the first time, drag a dozen boxes, connect them, export a PNG into Word, and call it done — then six months later the system gains two servers, nobody can modify that diagram, and the whole thing gets redrawn from scratch. The problem isn't incompetence. It's treating a diagram that needs long-term maintenance as a disposable screenshot.

This article isn't going to repeat "draw.io is free and great." It covers something narrower: how a 6-person backend team maintaining 14 diagrams across three departments chose between Draw.io's desktop, web, and self-hosted routes, how to turn diagrams into XML assets that live in Git, and which self-hosting parameters will trip you up.

What the Rework Revealed

Last September I was at a warehousing SaaS company in Hangzhou. Six backend devs and two ops engineers maintaining 14 diagrams: three main flows (orders, inventory, settlement) plus 11 subsystem interaction diagrams. Those diagrams lived in three places — someone's free online whiteboard, someone's Visio vsdx files, and boxes hand-drawn in PowerPoint.

My first task was explaining the "inventory deduction" flow to a new ops hire. I pulled three people and three diagrams together. The node names didn't even match: one said "库存服务" (Inventory Service), one said "inv-svc", one said "deduction module". Two hours of explanation, and the audience was more confused than before.

The constraints were real: no budget for commercial licenses, but diagrams had to be editable by multiple people, searchable, and versioned in a code repository. That's what brought Draw.io in — its files are essentially XML text, born for Git. But "suitable" doesn't mean "default is right." The differences between three install routes determine how smooth your next six months will be.

Attempt One: Everyone on the Web Version, Chaos Within a Week

The first plan was simplest: everyone opens diagrams.net, draws, hits "Save to device," downloads the .drawio file, and dumps it into a shared drive folder.

Looked fine. Fell apart in a week:

  • Two devs downloaded the same file, edited separately, uploaded back, overwrote each other. Both sets of changes gone.
  • Some people exported PNGs to the group chat, others saved .drawio files. Finding the "latest version" meant scrolling through chat history.
  • The web version stores drafts in browser-local storage. Someone switched computers, lost an afternoon of work.

The bottleneck wasn't Draw.io itself. It's that the web version delegates the "where do we store this" decision to each user. It defaults to browser-local storage, and the dialog offers "Device / OneDrive / Google Drive" — for teams in China, Google Drive is unreachable, so most people just save locally. The collaboration chain breaks at step one.

Here's the mechanism worth understanding: a .drawio file isn't an image. It's a compressed structural description. The web version stuffs it into IndexedDB; the desktop version writes to a local path you specify; the self-hosted version hands it to your server. Same diagram, three storage locations, three collaboration fates.

The Real Problem: Shared Drives Don't Solve Versioning

After the rework postmortem, I changed my evaluation criteria. The question isn't "which tool to draw with" — it's "who owns the diagram's version history."

We tried a compromise: everyone uses the web version, exports XML, manually commits to Git. Sounds very engineer-y. Failed again — the web version exports uncompressed XML (large, noisy diffs), while the desktop version defaults to compressed format. Same diagram, two completely different files in Git, and code review can't tell which line changed.

Then a trap nobody predicted: we almost went straight to self-hosting, and one environment variable stopped us.

The company had a spare intranet server, and ops wanted to deploy the self-hosted Draw.io to remove external dependencies. They spun up the docker image — the page loaded, but drawing threw errors immediately. Why: DRAWIO_BASE_URL wasn't configured, so frontend static assets and backend API addresses didn't match, and every save action returned 500. That parameter is one line in the README, but the symptom — "page opens, saving fails" — is easy to misdiagnose as a permissions issue. After fixing it you also need DRAWIO_SERVER_URL pointing to the backend. Two variables, two distinct jobs; miss either one and nothing works. Trust the official repo's README, not blog posts with old commands.

The Fix: Three Routes by Role, Not by Preference

We didn't standardize everyone onto one route. We split by role into three layers. This playbook has since been reused on two other projects and held up.

The critical move isn't installation — it's deciding who owns source files. We made one hard rule: any diagram going into docs, wiki, or the code repo must have its .drawio source committed to Git. PNG is an export artifact and never enters the repository. That rule turned "who changed which line" into a reviewable diff.

The desktop-version first-run path, in order:

  1. Define the file naming convention and commit location first (e.g., docs/diagrams/<domain>-<flow>.drawio), then start drawing;
  2. Desktop version opens the repo path directly — save in place, no "download then upload" detour;
  3. PNG/SVG exports happen only for external delivery, never committed back;
  4. Commit messages describe the change ("inventory diagram: add settlement gateway"), not "update".

Order matters: naming convention and commit location come before drawing. Do it backwards and you'll end up with "inventory-flow", "inventory-flow_new", and "inventory-flow_final" coexisting.

Three Diagram Techniques That Actually Matter

Once installed, a few techniques separate efficient teams from struggling ones — none of them emphasized in the docs:

Import shape libraries on demand, not all at once. The bottom-left "More shapes" panel lets you enable Cisco, AWS, Azure, Kubernetes icon sets. Our rule: cloud architecture diagrams enable only that cloud provider's set; internal service diagrams use basic flowchart shapes. Enable everything and you're scrolling through hundreds of icons to find "database," plus you risk mixing two visually-different icons for the same concept across one diagram.

Use Layers to separate logic from deployment. The layers panel (bottom-right) supports multiple layers. Our inventory diagram has two: the base layer holds business logic (services, queues, databases); the top layer holds deployment info (which datacenter, how many replicas). Viewers toggle what they need. Why it's worth it: product wants logic, ops wants deployment — one diagram, two views, instead of maintaining two diagrams. Layers exist in both web and desktop versions; it's not a paid feature.

Export SVG over PNG when pasting into wikis. For internal wikis or Confluence, export SVG — vector, scales cleanly, small files. For executives who won't edit anything, PNG with the "includes a copy of my diagram" option lets them tweak later. In practice, PNGs sent through WeChat get compressed into mush; SVG converted to PDF survives.

Once XML Is in Git, Diagrams Come Alive

The real unlock was treating diagrams as code assets. An uncompressed .drawio file looks like this:

<mxGraphModel>
  <root>
    <mxCell id="0"/>
    <mxCell id="1" parent="0"/>
    <mxCell id="svc-inv" value="Inventory Service" style="rounded=1;" vertex="1" parent="1">
      <mxGeometry x="120" y="80" width="120" height="60" as="geometry"/>
    </mxCell>
    <mxCell id="edge-1" edge="1" source="svc-inv" target="db-1" parent="1">
      <mxGeometry relative="1" as="geometry"/>
    </mxCell>
  </root>
</mxGraphModel>
Enter fullscreen mode Exit fullscreen mode

This is the mxGraph model — the serialization format of Draw.io's underlying graphics library. Every node is an mxCell with a unique id, a style for appearance, source/target for connections. Understanding this unlocks two things ordinary users can't do:

  • Bulk edits: renaming "Inventory Service" to "Inventory Center" across 14 diagrams becomes a script that walks every .drawio file and regex-replaces the value. Manual editing means opening 14 files.
  • Diagram-to-docsync: extract every mxCell's value to generate a node inventory table for API docs. Change the diagram, regenerate the table.

Know the boundary, though: fewer than 5 diagrams that barely change? Don't bother with XML. Desktop version + PNG export is the cheapest path. XML-in-Git pays off when diagrams are numerous, frequently edited, and multi-maintainer — our threshold was around 8 diagrams and 2+ maintainers. Below that, Git workflows are a tax on simplicity.

Self-Hosting: Two Parameters Decide Everything

The intranet deployment was the most technically interesting part of this project. We used the official jgraph/docker-drawio image. The core command looks roughly like this (check the official repo for current tags — don't copy someone's old blog command):

docker run -it --rm --name drawio \
  -p 8080:8080 -p 8443:8443 \
  -e DRAWIO_BASE_URL=http://<intranet-ip>:8080 \
  -e DRAWIO_SERVER_URL=http://<intranet-ip>:8080 \
  jgraph/drawio
Enter fullscreen mode Exit fullscreen mode

The two environment variables have distinct jobs — this is where most people trip:

  • DRAWIO_BASE_URL: tells the frontend "the address I'm being accessed at." Static assets, icons, and export endpoints are built from it. Wrong value: page loads, every icon is broken.
  • DRAWIO_SERVER_URL: tells the frontend "where the backend save service lives." Collaboration, versioning, and image upload go through it. Wrong value: you can draw, but saving errors out.

Our own failure: first deployment set only DRAWIO_BASE_URL, assuming one URL covered both. Result: drew a diagram, hit save, console full of 500s. Spent half an hour suspecting port mapping before discovering DRAWIO_SERVER_URL was missing and the frontend was hitting the wrong address. The lesson: container running ≠ feature working. After any deployment, walk the full path — new diagram → draw a box → save → refresh and see it. Homepage loading proves nothing.

The self-hosting tradeoff: it removes external dependencies and keeps data inside your network — right for teams with confidentiality requirements. The cost is running the server, upgrading images, configuring HTTPS yourself. A three-person team with non-sensitive diagrams shouldn't self-host; web or desktop plus Git is plenty. Don't spend ops effort on a diagramming tool.

The Outcome and a Reusable Checklist

After this round: 11 of 14 diagrams live in the repo's docs/diagrams/; product and operations edit via the web version and commit source files back; backend maintains theirs on desktop; the self-hosted instance serves read-only "authoritative" viewing for the whole team. When the new ops engineer onboarded, I handed him a repo link — 20 minutes to understand the inventory flow, versus the original two-hour confusion meeting.

Cost: desktop version is free, the self-hosted server was spare hardware, and the real investment was a few hours defining conventions plus half a day writing the XML batch-replace script. Worth it only if your diagrams change often.

The reusable checklist:

  • Fewer than 5 diagrams, rarely change → desktop version + PNG export, done;
  • Many diagrams, multiple editors, need traceability → .drawio in Git, PNG only flows out;
  • Sensitive diagrams + spare server → only then self-host, and configure both DRAWIO_BASE_URL and DRAWIO_SERVER_URL;
  • Avoid "Export as HTML" for embedding into internal systems — editing requires reverse-engineering the HTML, far worse than editing XML. Fine for a one-off demo; never for maintenance.

Top comments (0)