SVG Architecture Diagram
by @wujiaming88
Create professional, publication-quality technical architecture diagrams using pure SVG in HTML, then screenshot via Playwright. Produces crisp, pixel-perfec...
clawhub install svg-architecture-diagram๐ About This Skill
name: svg-architecture-diagram description: >- Create professional, publication-quality technical architecture diagrams using pure SVG in HTML, then screenshot via Playwright. Produces crisp, pixel-perfect diagrams with precise connection lines, color-coded modules, and clear text at any resolution. Use when: (1) user asks for a system architecture diagram, (2) user wants a technical component diagram or flow chart, (3) user needs a data flow or pipeline visualization, (4) any diagram requiring accurate text labels and precise connecting lines. Triggers: "architecture diagram", "ๆถๆๅพ", "ๆๆฏๆถๆ", "system diagram", "component diagram", "flow diagram", "ๆฐๆฎๆตๅพ", "ๆจกๅๅพ", "draw architecture", "็ปๆถๆๅพ", "technical diagram". Prefer this over AI image generation for any diagram with text labels.
SVG Architecture Diagram
Create professional technical architecture diagrams using pure SVG, rendered to high-res PNG via Playwright.
Why SVG (not CSS positioning or AI image generation)
| Approach | Lines/Arrows | Text Quality | Precision |
|----------|-------------|-------------|-----------|
| SVG (this skill) | โ
Perfect: , , | โ
Crisp at any size | โ
Pixel-perfect |
| CSS absolute positioning | โ Hacky: borders, pseudo-elements | โ
OK | โ Hard to align |
| AI image generation | โ No control | โ Garbled text | โ No precision |
Quick Start
Step 1: Plan the diagram
Identify:
Step 2: Create the HTML file
Write a single HTML file with an inline SVG. Standard canvas: 1600ร1000px.
Step 3: Build the diagram using these SVG patterns
Filled header card (module title):
๐ Module Name
Outlined detail card (sub-component):
Component Title
Description line 1
Metadata / specs
Connection line (with arrow):
Curved connection (L-shape or bend):
Dashed feedback line:
Connection label:
label text
Step 4: Screenshot with Playwright
from playwright.sync_api import sync_playwright
with sync_playwright() as p:
browser = p.chromium.launch()
page = browser.new_page(
viewport={"width": 1600, "height": 1000},
device_scale_factor=4, # 4x ultra-high res (default)
)
page.goto("file:///path/to/diagram.html", wait_until="networkidle")
page.wait_for_timeout(1500)
page.screenshot(path="diagram.png", full_page=True)
browser.close()
Or use the bundled script: scripts/screenshot.py
Design System
See references/design-system.md for the complete color palette, card styles, arrow markers, and text sizing rules.
Critical Rules (prevent common issues)
Text Overflow Prevention
1. Max characters per line at font-size 11px โ 7px/char: - 300px container โ max 37 chars - 340px container โ max 43 chars - 440px container โ max 57 chars 2. Long text โ split into multiple elements with Y offset +15px each
3. Always leave 20px padding on each side of text inside cards
4. Test at 1x scale before generating final 4x screenshotConnection Line Rules
1. Never use CSS for connections โ always SVG or
2. One per color โ define in , reference with marker-end
3. Straight lines when possible; use L-segments for bends
4. Avoid crossing lines โ rearrange layout if lines would cross
5. Label every connection โ brief verb/noun near the midpoint
6. โ ๏ธ Minimum 20px gap between vertically stacked cards โ Arrow markers are 8px long. If the gap between cards is less than 20px, the arrow will completely cover the line, making it look like "arrow only, no line". Use card height 34px + gap 22px = 56px per step.
7. Connection line length must be at least 17px โ This ensures 9px visible line + 8px arrow marker. Example: card bottom at y=324, next card top at y=346, line from y1=324 to y2=343 (19px).
8. Never make line length < marker size (8px) โ The line will be invisible.Layout Rules
1. Top-to-bottom primary flow (input at top, output at bottom/right) 2. Left-right symmetry when possible 3. Group related modules vertically (e.g., memory layers stacked) 4. Minimum 20px gap between vertically stacked cards (see Connection Line Rules) 5. Color-code by function โ see design system for standard palette 6. Include a legend (bottom-right corner) explaining colors and line types 7. Include a title (top center) and source attribution (bottom center)Font Rules
1. Font family:font-family="Inter, 'PingFang SC', 'Microsoft YaHei', sans-serif" โ set on root or first
2. Load Inter via Google Fonts in block
3. Chinese text: use PingFang SC / Microsoft YaHei fallback
4. Font sizes: titles 13-14px, descriptions 10-11px, metadata 9-10pxExamples
Two complete working examples are included:
references/example-hermes.html โ Hermes Agent architecture (6 modules, medium complexity)references/example-openclaw.html โ OpenClaw platform architecture (12 modules, high complexity, demonstrates proper vertical card spacing for Agent Loop steps)Delivery
Output MEDIA: for inline delivery, or openclaw message send --channel telegram --target for Telegram.
If PNG exceeds ~1MB for Telegram delivery, convert to JPEG (quality=95):
from PIL import Image
img = Image.open("diagram.png")
img.save("diagram.jpg", "JPEG", quality=95, optimize=True)
Default is 4x (6400ร4000px for 1600ร1000 canvas). Always use maximum resolution.
๐ก Examples
Two complete working examples are included:
references/example-hermes.html โ Hermes Agent architecture (6 modules, medium complexity)references/example-openclaw.html โ OpenClaw platform architecture (12 modules, high complexity, demonstrates proper vertical card spacing for Agent Loop steps)