apex-python-diagrams
Skill220 starsChanged 2 months agoMITView on GitHub
**UTILITY SKILL** — Python diagram generation for Azure architectures, WAF/cost/compliance charts, ERDs, swimlanes, timelines, and wireframes. WHEN: 'architecture diagram', 'WAF bar chart', 'cost chart', 'ERD', 'swimlane', 'timeline', 'wireframe'. DO NOT USE FOR: inline Mermaid diagrams (apex-mermaid).
- Installs packages
In this repository40 other files it gives its agents.
- AGENTS.mdAGENTS.md
- .github/copilot-instructions.mdCopilot instructions
- apex-agent-authoringSkill
- apex-azure-adrSkill
- apex-azure-artifactsSkill
- apex-azure-bicep-patternsSkill
- apex-azure-cloud-migrateSkill
- apex-azure-complianceSkill
- apex-azure-computeSkill
- apex-azure-cost-optimizationSkill
- apex-azure-defaultsSkill
- apex-azure-deploySkill
- apex-azure-diagnosticsSkill
- apex-azure-governance-discoverySkill
- apex-azure-kubernetesSkill
- apex-azure-kustoSkill
- apex-azure-prepareSkill
- apex-azure-quotasSkill
- apex-azure-rbacSkill
- apex-azure-reliabilitySkill
- apex-azure-resourcesSkill
- apex-azure-storageSkill
- apex-azure-upgradeSkill
- apex-azure-validateSkill
- apex-context-managementSkill
- apex-debug-log-exportSkill
- apex-entra-app-registrationSkill
- apex-github-operationsSkill
- apex-golden-principlesSkill
- apex-iac-commonSkill
- apex-mermaidSkill
- apex-microsoft-docsSkill
- apex-rfi-rfpSkill
- apex-terraform-patternsSkill
- apex-terraform-search-importSkill
- apex-terraform-testSkill
- apex-unslopSkill
- apex-vendor-promptingSkill
- apex-workflow-engineSkill
- apex-workflow-startSkill
The file
We split this skill into the rules it gives an agent
7 rules. About 0 are common, 1 is distinctive, and 6 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
6
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 30
Every diagram generator emits both .svg and .png siblings — the .svg is the editable vector master (selectable text, embedded official …
- Distinctive: line 76
Inspect scope & choose pattern: Read the architecture/plan specification for exact titles, resource names, CIDRs, boundaries, and …
- Very specific: line 120
Keep service cards compact (1–2 lines, h=44..84) with concise titles ("Blob Storage", "Azure OpenAI", "snet-pe / Private endpoints").
- Very specific: line 123
Keep a 20px+ gap between sibling boxes, leave dedicated routing corridors for orthogonal connectors (M...H...V...), and use Unicode → …
- Very specific: line 131
Non-Azure shapes: No official Azure icon exists for a generic browser, laptop, folder, or Microsoft Graph — use clean labelled box()/card() …
- Very specific: line 141
DON'T: Call plt.savefig(...), Diagram(..., outformat=...), or dot.render(...) directly · Shrink font sizes below 12px to cram text · Route …
- Very specific: line 145
Does NOT: produce inline Mermaid diagrams (apex-mermaid) · generate Bicep/Terraform · create ADRs (apex-azure-adr) · deploy resources.
≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Python Diagrams & Charts (dlib SVG/PNG + matplotlib)
Skill for authoring faithful, brand-consistent Azure architecture diagrams as
editable 1920×1080 SVG masters plus 3840×2160 (4K) PNG renders using
scripts/dlib.py and the bundled official Microsoft Azure
Public Service Icons v23 (assets/), alongside matplotlib for quantitative
WAF/cost/compliance charts via scripts/diagram_io.py.
Prerequisites
pip install cairosvg matplotlib pillow diagrams graphviz && apt-get install -y graphvizRouting Guide
Every diagram generator emits both .svg and .png siblings — the .svg is
the editable vector master (selectable text, embedded official Azure SVG <symbol>
icons) and the .png is the 3840×2160 raster render.
| Diagram type | Engine | Helper / API | Output |
| Azure architecture, hub-spoke routing, private DNS | dlib (scripts/dlib.py) | from dlib import *; reset(); add(...); finish(...) | .py + .svg + .png (4K) |
| Identity, RBAC, Key Vault & telemetry flows | dlib (scripts/dlib.py) | from dlib import *; reset(); add(...); finish(...) | .py + .svg + .png (4K) |
| Subscription vending, cutover & pipeline swimlanes | dlib (scripts/dlib.py) | from dlib import *; reset(); add(...); finish(...) | .py + .svg + .png (4K) |
| WAF bar charts | matplotlib | save_figure from scripts/diagram_io.py | .py + .png + .svg |
| Cost donut / projection charts | matplotlib | save_figure from scripts/diagram_io.py | .py + .png + .svg |
| Compliance gap & Gantt timeline charts | matplotlib | save_figure from scripts/diagram_io.py | .py + .png + .svg |
| Entity-relationship diagrams (ERD) | dlib or graphviz | dlib.finish or render_graphviz (diagram_io.py) | .py + .png + .svg |
| UI wireframes | SVG / graphviz | create_wireframe_svg (multi_diagram_generator.py) | .py + .svg (+ .png via CairoSVG) |
Required Outputs (Workflow Integration)
For the standalone assessment profile, assets/03-des-diagram.{py,png,svg} is mandatory
before final bundle acceptance. Diagram generation uses authorized evidence and validated analysis,
not an intermediate Architecture approval. Render all observed resource families inside their
Subscription/RG/VNet containers, encode observed versus declared/unverified edges visually via
the compact legend (capping caveat boxes at <= 10% of canvas height), and never portray a
recommendation or unverified control as deployed. For assessment-bundle-v3 (visual_charts: true),
03-Architect also runs python3 tools/scripts/render-assessment-charts.py --project-dir agent-output/{project}
during analysis to produce assets/02-waf-posture.{png,svg}, assets/03-cost-trends.{png,svg},
and assets/03-cost-drivers.{png,svg} from _meta/waf-scores.json and contracts/03-cost-management.json,
embedding the SVGs inline in 02-architecture-assessment.md and 03-cost-management-report.md.
| Step | Python diagram & chart files |
| 2 | 02-waf-scores.py/.png/.svg (matplotlib via save_figure) |
| 3 | 03-des-diagram.py/.png/.svg (dlib), 03-des-cost-distribution.py/.png/.svg, 03-des-cost-projection.py/.png/.svg |
| 4 | 04-dependency-diagram.py/.png/.svg (dlib), 04-runtime-diagram.py/.png/.svg (dlib) |
| 7 | 07-ab-diagram.py/.png/.svg (dlib), 07-ab-cost-*.py/.png/.svg, 07-ab-compliance-gaps.py/.png/.svg |
Suffix rules: -des for design (Step 3), -ab for as-built (Step 7).
Architecture Diagram Workflow (dlib.py)
Draw the approved specification faithfully; never redesign or invent unapproved services.
Choosing the Right Style: AAC Technical Architecture vs. Executive Overview Slide
- AAC Technical Architecture (default for
03-des-diagram,04-runtime-diagram,07-ab-diagram): Use bare official Azure icons (tile()), neutral containment boundaries (zone()forregion,sub,rg,vnet,subnet,onprem), thin dark orthogonal connectors with numbered flow badges (flow()), and a matchingdataflow_key(). This aligns with Microsoft Azure Architecture Center (AAC) and Well-Architected Framework diagramming standards. - Executive / Bid Overview Slide (for RFI/RFP briefings and capability overviews): Use horizontal
card()tiles, semantic tintedsub()/rg()frames,arr()connectors, and a bottom 5-stagechevron()summary bar (gen02pattern).
- Inspect scope & choose pattern: Read the architecture/plan specification for exact titles, resource names, CIDRs, boundaries, and connectors. Consult
references/common-patterns.mdfor the closest template (AAC hub-spoke + observability with numbered dataflows, executive overview, private DNS, identities/telemetry, or swimlanes). - Author
.pyusing AAC primitives (or semantic topology spec):import sys from pathlib import Path sys.path.insert(0, str(Path(".github/skills/apex-python-diagrams/scripts").resolve())) from dlib import * # noqa: F403 reset() add(zone(40, 80, 1840, 820, "Azure Region: Sweden Central", kind="region", zone_id="reg-swc")) add(zone(70, 130, 520, 740, "Hub VNet", kind="vnet", subtitle="10.0.0.0/16", zone_id="vnet-hub", parent_id="reg-swc")) add(tile(200, 260, "fw", "Azure Firewall", node_id="fw-hub", parent_id="vnet-hub")) add(tile(440, 260, "dnsresolver", "DNS Private Resolver", node_id="dns-hub", parent_id="vnet-hub")) add(flow([(260, 260), (380, 260)], step=1, style="private", source_id="fw-hub", target_id="dns-hub")) add(dataflow_key(40, 920, 1840, [(1, "Hub firewall proxies private DNS resolution.")])) finish("agent-output/{project}/04-runtime-diagram", "Runtime Architecture & Private Connectivity", style="aac") - Run & check overflow warnings: Execute
python3 agent-output/{project}/<name>.py.dlib.t()printsWARN overflow:lines whenever estimated text width exceedsmw. Fix every warning by wrapping text or widening the container — never shrink text below12px.tile()andzone()enforcestrict=Trueexact icon matching so invalid icon keys fail immediately with suggestions. - Inspect the rendered PNG & SVG: View the rendered
.pngto verify zero overlapping labels, uncrossed arrows, and clean visual hierarchy. Note: if theviewtool caches by path, copy the PNG to a unique preview filename, inspect it, and remove the temporary preview afterward.
Canvas, Palette & Boundary Rules (dlib.py)
- Canvas: SVG
width="3840" height="2160" viewBox="0 0 1920 1080", explicit white background (#FFFFFF), fontSegoe UI, Arial, sans-serif. Title top-centre at(960, 56)(40pxbold navy#0B1F3A); footer bottom-centre at(960, 1058)(18px#4A5A6A, defaults to"APEX"). - Semantic Colours:
- Shared platform (
BL/BLF): Stroke#0078D4, fills#E6F1FB/#F5FAFF - Workload (
TL/TLF): Stroke#008272, fills#E3F4F1/#F2FAF8 - Legacy / management (
SL/GRF): Stroke#5B6B7B, fill#EEF2F6 - Migration / notes / policy / exceptions (
AM/AMB/AMF): Stroke#D18B00/#F2A900on fill#FFF6DD - Identity (
PU/PUF): Stroke#7B3FA0, fill#F3ECF8
- Shared platform (
- Distinct Boundaries (containment = boundary, relationship = arrow):
- Tenant:
tenant(x=30, y=80, w=1860, h=940, name="Microsoft Entra tenant")— heavy navy solid border (NAVY,sw=3,rx=14) +tenicon - Management group: Filled rounded box with
mgicon - Subscription:
sub(x, y, w, h, name, col, fill, badgetxt, bw)— solid2.5pxborder +subicon + top-right scope badge - Resource group:
rg(x, y, w, h, name, col)— dashed1.8pxborder (stroke-dasharray="7 4") +rgicon - VNet / Subnet: Solid box inside RG with
vnet/subneticon and CIDR block in the header
- Tenant:
- Semantic Connectors (
arr(d, kind=...),vbracket(...),legend(...),chevron(...)):net(solid blue#0078D4): network/request trafficid(dashed purple#7B3FA0): identity, RBAC, token/secret authorizationdns(dotted teal#008272): private DNS resolutiontel(dashed slate#5B6B7B): diagnostics and OpenTelemetry/Log Analyticsmig(solid amber#D18B00): replication / migration cutover pathoff(dashed grey#8A98A8): disabled / decommissioned path
- Typography & Anti-Crowding (
gen02/gen08/gen09Visual Standard):- Body
16–22px, headers20–26px, badges15pxbold, nothing below~12px. - Keep service cards compact (
1–2lines,h=44..84) with concise titles ("Blob Storage","Azure OpenAI","snet-pe / Private endpoints"). Never pack 3–4 lines of spec-sheet prose into wide full-width text blocks. - Group stacked Private Endpoint or VNet-integrated targets with
vbracket(x, y1, y2)and label connectors directly with inlinechip()/chip2()pills. - Anchor end-to-end overview diagrams with an outer
tenant()frame, a top-left visuallegend(60, 172, ...)listing only used connector kinds, and a bottom 5-stagechevron()bar + summarychip(). - Keep a
20px+gap between sibling boxes, leave dedicated routing corridors for orthogonal connectors (M...H...V...), and use Unicode→(\u2192) rather than ASCII->in text labels.
- Body
Official Azure SVG Icons (assets/)
All 705 official Microsoft Azure Public Service Icons (v23) plus assets/github.svg (gh) are vendored offline under assets/.
- Curated short keys (
dlib.P):ten,mg,sub,rg,pol,bud,arc,rsv,bvault,vnet,subnet,fw,fwp,waf,dns,bas,nat,peer,rt,pe,pip,nsg,afd,agw,lb,vpngw,er,vm,disk,app,asp,func,swa,aks,acr,aci,aca,signalr,sqlmi,sqls,sqldb,arcsql,cosmos,postgres,mysql,redis,blob,st,cont,queue,apim,sb,evg,evh,logic,adf,databricks,kv,mi,user,entra,appreg,entapp,mon,law,ai,openai,foundry,search,cog,ml,code,cli,dev, plusgh(GitHub). - Full v23 auto-lookup: Any of the 705 v23 icons can also be referenced by service slug (e.g.,
"event-hubs","front-door-and-cdn-profiles") viadlib.resolve_icon_path(k). - Gradient ID Namespacing: Azure SVG icons share internal gradient/clip IDs (
id="a",url(#a)).dlib.symbols()embeds only used icons as<symbol id="ic-{k}">and prefixes every internalid,url(#...), andhref="#..."with{k}-. Never inline raw SVG icon files without this prefixing. - Non-Azure shapes: No official Azure icon exists for a generic browser, laptop, folder, or Microsoft Graph — use clean labelled
box()/card()containers or thefolder()glyph; never invent lookalike icons.
Quantitative Charts & Legacy Helpers (diagram_io.py)
For quantitative charts (matplotlib), import save_figure from scripts/diagram_io.py so every chart emits .png + .svg siblings (DPI 150). See references/python-charts.md and references/waf-cost-charts.md. Legacy diagrams (diagram_kwargs + embed_svg_images) and graphviz (render_graphviz) helpers remain in diagram_io.py for backward compatibility.
Rules
DO: Use scripts/dlib.py (finish or diagram_io.render_dlib) for architecture, network, DNS, identity, cutover, and swimlane diagrams · Use save_figure from scripts/diagram_io.py for WAF/cost/compliance matplotlib charts · Fix all WARN overflow: hints before finishing · Keep orthogonal connectors (M...H...V...) in routing corridors · Escape <, >, & in SVG text · Verify both .svg and .png outputs exist and are non-empty.
DON'T: Call plt.savefig(...), Diagram(..., outformat=...), or dot.render(...) directly · Shrink font sizes below 12px to cram text · Route arrows across unrelated cards or text labels · Include real tenant/subscription/object IDs or credentials · Use Mermaid for rendered PNG/SVG deliverables.
Scope Exclusions
Does NOT: produce inline Mermaid diagrams (apex-mermaid) · generate Bicep/Terraform · create ADRs (apex-azure-adr) · deploy resources.
Scripts
scripts/dlib.py (primary AAC + overview SVG & 4K PNG Azure diagram engine) ·
scripts/topology_render.py (semantic *.topology.json → ELK auto-layout → AAC SVG + PNG; invoked via diagram_io.render_topology() inside the standard .py wrapper) ·
scripts/diagram_io.py (shared PNG+SVG output helper: render_dlib, render_topology, save_figure, diagram_kwargs, render_graphviz, embed_svg_images) ·
scripts/generate_diagram.py (interactive template generator) ·
scripts/multi_diagram_generator.py (ERD, swimlane, timeline, wireframe helpers) ·
scripts/ascii_to_diagram.py (ASCII art → diagram conversion) ·
scripts/verify_installation.py (prerequisites & dlib/v23 icon check)
Reference Index
| File | Content |
references/common-patterns.md | Ready-to-use dlib.py Azure architecture templates (hub-spoke, vending, DNS, identity, cutover, swimlanes) |
references/azure-components.md | Curated dlib.P icon keys and full 705-icon Azure v23 component catalog |
references/python-charts.md | Chart execution, dlib & matplotlib design tokens, output standards |
references/waf-cost-charts.md | WAF pillar bar, cost donut & projection matplotlib chart implementations |
references/business-process-flows.md | Workflow and swimlane diagram patterns |
references/entity-relationship-diagrams.md | Database ERD patterns |
references/integration-services.md | Integration service diagram patterns |
references/migration-patterns.md | Migration and cutover architecture patterns |
references/sequence-auth-flows.md | Authentication and identity flow patterns |
references/timeline-gantt-diagrams.md | Project timeline and Gantt diagrams |
references/ui-wireframe-diagrams.md | UI mockup and wireframe patterns |
references/iac-to-diagram.md | Generate diagrams from Bicep/Terraform/ARM templates |
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

