Architecture Diagrams Move to HTML and CSS, Theming Comes Free
Ten architecture diagrams rebuilt from image files into pure HTML+CSS: diffable, searchable, and theme-aware through CSS custom properties.
TL;DR
After dark mode migration, ten diagram images couldn't be diffed or searched, since PNGs are binary and SVG exports rewrite element order. Converting formats didn't help; the real issue was rendering structured data as images, so the diagrams were rebuilt as HTML and CSS using custom properties for theming. PDFs keep vector art; spatial swimlanes remain images with alt text.
Every color token in the manual had been moved over to dark mode. One grep command ran to make sure nothing was missed, and it came back with ten image file references: one cluster map, three entity-relationship diagrams, one runtime topology, one module map, two message flows, one infrastructure topology, and one release flow. Those ten files were untouched by any theme change in the stylesheet.
Re-exporting ten images is not a big job. The problem appeared when I tried to review the result through a diff.
Ten images that cannot be diffed
To git, PNG files stop at being binary; the diff shows a single "Binary files differ" line. SVG files are text, but the export tool rewrites the whole element order on every export, so a diff that should contain a color change instead contains hundreds of lines moving position. There is no way to prove that the only change was color.
The second complaint comes up even more often in review: text inside the diagram is not selectable. Entity names, column types, cardinality labels, all locked as pixels or paths. Portal search cannot find order_items because the word never exists in the DOM. If one diagram misspells a column name, fixing it means opening an image editor, not a text editor.
The wrong guess: switch formats
The first guess was simple and wrong: PNG was the root cause, and converting everything to SVG would solve theme and diff at once. It did not. Text inside exported SVGs is still redrawn paths, and their colors are still hex values rewritten on every export. After a few re-exports it became clear that the format was not the problem; the problem was the decision to render structured data as an image at all.
Those ten diagrams fundamentally hold the same things: cards, relations, sequences, and frames. The structure already exists in the data. An image file is just one possible render of that structure, and that render was the only one being stored.
Structure moves to the DOM, theming comes free
So everything was rebuilt as HTML and CSS. Entities became cards with primary-key dots, relations became chips with cardinality labels, flows became numbered lists, hosts became framed boxes with labeled separators. All plain text: selectable, searchable, and its diff only shows the lines that actually changed.
The part that makes this decision hold is CSS custom properties. One value is defined in one place and referenced in many, and custom properties follow the cascade so they are inherited by all descendant elements [1]. Change the value at the theme scope, and every diagram follows without a single image file being re-exported.
/* Warna tema didefinisikan sekali, diwariskan ke seluruh diagram */
:root {
--card-bg: #f7f7f8;
--key-dot: #b45309;
}
[data-theme="gelap"] {
--card-bg: #16181d;
--key-dot: #fbbf24;
}
/* Kartu entitas hanya membaca variabel, tidak pernah menulis warna tetap */
.entitas {
background: var(--card-bg);
border-inline-start: 3px solid var(--key-dot);
}
The print variant keeps @media print to disable interactions and lock sizes, while the user's color scheme preference is respected through a media query [2].
Two render paths and the boundary of the decision
The official PDF path was always meant to keep the original vector art, so the generator received a dual-render flag: door pages serve the DOM version, the PDF path keeps the vector original. One data source, two renders.
Some diagrams were left alone too. SOP swimlane diagrams remain images, because their meaning lives in lines crossing lanes and the length of paths between columns; that is not something cards and chips can express without losing the meaning. For the images that remain, alt text stays mandatory, because browsers do not always display images and the alt text is what replaces them [3].
The verification is concrete. Zero SVG img tags remain in the three architecture door pages, there is no horizontal overflow, and the light-theme visual check is clean.
The opinion is firm: a diagram whose content is cards, relations, and sequences has no reason to be an image file. Image files are only right for diagrams whose meaning truly lives in shape and space. Text-rich architecture diagrams belong in the DOM, because that is where they can be searched, diffed, and themed at zero export cost.
Sources
[1] MDN, Using CSS custom properties, accessed 2026-11-09.
[2] MDN, the @media at-rule, accessed 2026-11-09.
[3] MDN, the img element, accessed 2026-11-09.