Instructions
Generate a draw.io (.drawio) XML file representing an AWS architecture diagram.
Layout
- Left-to-right flow for data/request path
- UI/Frontend on the LEFT (users access from left side)
- Data sources / external systems on the RIGHT
- Use horizontal lanes for parallel paths (top lane, bottom lane)
- Minimum 220px horizontal spacing between icons (to leave room for edge labels)
- Minimum 250px vertical spacing between lanes (so vertical edges don't crowd)
- Secondary/auxiliary services (monitoring, DLQ, error paths) go BELOW the main flow with 280px+ vertical gap
Canvas
- Large canvas:
pageWidth="2400" pageHeight="1400" minimum
- Set
dx="2800" dy="1600" for proper viewport
- Always include a title block as the first element after the background:
<mxCell value="<b>Diagram Title</b><br>Author | Date | Version" style="text;html=1;align=left;verticalAlign=top;whiteSpace=wrap;rounded=0;fontSize=14;spacing=8;" vertex="1" parent="1">
<mxGeometry x="40" y="30" width="420" height="60" as="geometry" />
</mxCell>
Icon Style
- Icons are from draw.io's built-in
mxgraph.aws4 stencil library — the official AWS Architecture Icons (https://aws.amazon.com/architecture/icons/, updated quarterly)
- Icon size: 78x78px for main services, 65x65px for secondary
- Use
sketch=0;outlineConnect=0; on all icons
- Use
strokeColor=#ffffff on all AWS service icons
- MUST include
fillColor — without it, icons render as invisible/white in PNG export
- Font size: 12px for labels
- Always include:
fontColor=#232F3E;verticalLabelPosition=bottom;verticalAlign=top;align=center;html=1;aspect=fixed;
fillColor by AWS service category:
| Category |
fillColor |
Services |
| Compute |
#ED7100 |
Lambda, EC2, ECS, EKS, Fargate |
| Networking |
#8C4FFF |
VPC, ELB, CloudFront, Route 53, API Gateway |
| Database |
#C925D1 |
RDS, DynamoDB, Aurora, ElastiCache |
| Storage |
#3F8624 |
S3, EFS, EBS |
| Security |
#DD344C |
IAM, Cognito, KMS, WAF |
| Integration |
#E7157B |
SQS, SNS, EventBridge, Step Functions |
| Analytics |
#8C4FFF |
Kinesis, Athena, Redshift |
| Management |
#E7157B |
CloudWatch, CloudTrail |
| AI/ML |
#01A88D |
Bedrock, SageMaker |
3D / Isometric Diagrams — use a different icon library
If the user asks for a 3D, isometric, or "AWS 3D" diagram, do NOT fake it by placing flat aws4 icons on hand-built platform/pedestal shapes. draw.io has a real, separate built-in library for this: mxgraph.aws3d.*.
- Load
references/aws-icons-3d.md before picking any icon — it has the verified shape table, style prefix, sizes, and the native isometricEdgeStyle edge templates.
- This library is a legacy pre-2019 icon set with much smaller coverage than
aws4 (no API Gateway, ECS/EKS/Fargate, Step Functions, EventBridge, SNS, Aurora, CloudWatch, IAM, etc.). Check the gap table in that reference file before assuming an icon exists, and flag substitutions to the user rather than guessing a stencil name.
- For generic hardware (clients, on-prem servers, racks, switches) with no AWS-specific icon, see
references/aws-icons-allied-telesis.md — a separate bundled isometric image library that fills that gap.
- These icons are already 3D on their own — arrange them in an ascending isometric staircase (diagonal offsets between nodes), don't add fake platforms underneath.
- Use
edgeStyle=isometricEdgeStyle (with endArrow=block override for reliable arrowheads) instead of orthogonalEdgeStyle for connectors.
Edge Style — CRITICAL FOR CLEAN DIAGRAMS
Base edge style (all edges):
edgeStyle=orthogonalEdgeStyle;rounded=1;orthogonalLoop=1;jettySize=auto;html=1;strokeWidth=2;exitX=1;exitY=0.5;exitDx=0;exitDy=0;entryX=0;entryY=0.5;entryDx=0;entryDy=0;
Rules for edge labels:
- Keep labels SHORT (1-2 words max). Use icon labels for detail, not edge labels.
- On horizontal edges: position label ABOVE the line using
verticalAlign=bottom; in the edge style
- On vertical edges: position label to the LEFT using
align=right; in the edge style
- Always add
labelBackgroundColor=#F5F5F5; so labels don't overlap lines
- For edges WITHOUT labels: omit the
value attribute entirely (don't use value="")
Edge label positioning (prevents overlap with icons):
<mxCell value="Label" style="edgeStyle=orthogonalEdgeStyle;rounded=1;orthogonalLoop=1;jettySize=auto;html=1;strokeWidth=2;labelBackgroundColor=#F5F5F5;fontSize=11;" edge="1" source="a" target="b" parent="1">
<mxGeometry relative="1" as="geometry" />
</mxCell>
For edges that go to services ABOVE or BELOW the main flow:
- Use explicit exit/entry points to control routing:
- Exit bottom:
exitX=0.5;exitY=1;exitDx=0;exitDy=0;
- Enter top:
entryX=0.5;entryY=0;entryDx=0;entryDy=0;
- Exit top:
exitX=0.5;exitY=0;exitDx=0;exitDy=0;
- Enter bottom:
entryX=0.5;entryY=1;entryDx=0;entryDy=0;
- This prevents draw.io from routing lines through other icons
Edge types:
- Solid black (
strokeWidth=2): primary data flow
- Dashed black (
strokeWidth=2;dashed=1;): optional/async path
- Dashed red (
strokeWidth=2;dashed=1;strokeColor=#DD344C;): error path
Edge attachment (CRITICAL — fixes "green cross" problem):
- Every edge MUST have both
source="<cell-id>" and target="<cell-id>" attributes referencing valid cell IDs
- NEVER create floating/unattached edges — all edges must be bound to shapes at both ends
- Always include
exitX/exitY and entryX/entryY to define exact connection points on the shape perimeter
- In draw.io, properly attached edges show a "blue dot" anchor; unattached edges show a "green cross"
- If an edge connects to a child inside a container, reference the child's ID directly (not the container)
- Cross-container edges: When source and target are in different containers, set the edge's
parent="1" (root layer) so draw.io can route it across boundaries
When NOT to label edges:
- If the flow is obvious from context (e.g., Lambda → DynamoDB doesn't need "Write")
- If the icon labels already explain the relationship
- Prefer fewer, more meaningful labels over labeling every edge
Visual Quality: straight arrows, no overlaps, professional layout
A diagram with correct icons but a messy layout still reads as unprofessional. Check every diagram against these rules before finishing — they're deliberately concrete/checkable, not vague "make it look nice" advice:
- Align nodes to a consistent axis so edges are single, straight segments. Keep the horizontal or vertical delta between adjacent nodes in a flow constant (same lane y-coordinate, same column spacing) so connecting edges render as one clean line instead of a dogleg.
- Align branch/secondary nodes on the exact same centerline as their parent. If a node branches off vertically (e.g. an auxiliary service below the main flow), its horizontal center must match its parent's horizontal center exactly — compute
child.x = parent.center_x - child.width/2, don't eyeball it. A few pixels of misalignment turns a "straight down" edge into a visibly crooked diagonal.
- One bend maximum per edge, ideally zero. If a computed edge path would need more than one bend to avoid an obstacle, the layout is wrong — move the node, don't add more bends to route around the problem.
- No edge may cross through an unrelated icon's bounding box. Before finalizing coordinates, check each edge's path against every icon's
(x, y, width, height) rectangle it isn't connected to. If it would cross one, move the node or add an explicit exit/entry point to route around it.
- No two edges may run on top of each other or visually merge. If two edges would travel the same corridor (e.g. two parallel flows between the same pair of lanes), offset them — different exit/entry points, or an explicit waypoint — so there's a visible gap between them.
- Minimize edge crossings overall. Order nodes in the direction the data actually flows so edges rarely need to cross each other. If a crossing is unavoidable (e.g. a feedback/response path), route it with a visible offset rather than letting it overlap another edge.
- Keep spacing consistent, not just "enough." Use the same minimum step size between every pair of adjacent nodes in a flow — a diagram where some gaps are 400px and others are 250px reads as sloppy even if nothing technically overlaps.
- Balance the composition on the canvas. Don't leave one half of the page dense and the other empty; size the canvas to the actual content plus a consistent margin.
- Self-check before finishing: after placing every coordinate, mentally trace each edge from source to target and verify (1) it doesn't cross any icon, (2) it doesn't overlap another edge, (3) it has at most one bend, (4) its endpoints are flush with the icons it connects. Fix the layout, not just the intent, if any check fails.
Two Icon Patterns — CRITICAL
Pattern 1: Service-level (resourceIcon frame)
- Style:
sketch=0;outlineConnect=0;fontColor=#232F3E;fillColor=<CATEGORY_COLOR>;strokeColor=#ffffff;dashed=0;verticalLabelPosition=bottom;verticalAlign=top;align=center;html=1;fontSize=12;fontStyle=0;aspect=fixed;shape=mxgraph.aws4.resourceIcon;resIcon=mxgraph.aws4.<name>
- MUST use
strokeColor=#ffffff — without it, the white glyph disappears
- MUST use
fillColor=<color> — without it, icon renders as white/invisible square in PNG export
- Size: 78x78
Pattern 2: Resource-level (standalone shape)
- Style:
sketch=0;outlineConnect=0;fontColor=#232F3E;fillColor=<CATEGORY_COLOR>;strokeColor=none;dashed=0;verticalLabelPosition=bottom;verticalAlign=top;align=center;html=1;fontSize=12;fontStyle=0;aspect=fixed;shape=mxgraph.aws4.<name>
- MUST use
strokeColor=none — using #ffffff breaks these
- MUST use
fillColor=<color> — same reason as above
- Size: 78x78 or 48x48
Confusing these patterns guarantees broken icons.
Icon Reference Files (load by category as needed)
references/aws-icons-compute.md — Lambda, EC2, ECS, EKS, Fargate
references/aws-icons-database.md — DynamoDB, RDS, Aurora, ElastiCache
references/aws-icons-integration.md — API Gateway, SQS, SNS, EventBridge, Step Functions
references/aws-icons-networking.md — CloudFront, Route 53, VPC, ELB
references/aws-icons-storage.md — S3, EFS, EBS, Glacier, Backup
references/aws-icons-security.md — IAM, Cognito, KMS, WAF, Shield
references/aws-icons-analytics-ml.md — Kinesis, Athena, Bedrock, SageMaker
references/aws-icons-common.md — Groups, general resources, edge styles, base template
references/aws-icons-3d.md — 3D/isometric diagrams: legacy aws3d icon library, coverage gaps, isometric edge style
references/aws-icons-allied-telesis.md — bonus isometric computer/server/network icons for 3D diagrams (fills aws3d gaps)
Always look up icons from reference files. Never guess icon names.
Fallback for unmapped services: If a service is NOT found in any reference file, use this generic AWS cloud icon with the service name as label:
sketch=0;outlineConnect=0;fontColor=#232F3E;fillColor=#232F3E;strokeColor=#ffffff;dashed=0;verticalLabelPosition=bottom;verticalAlign=top;align=center;html=1;fontSize=12;fontStyle=0;aspect=fixed;shape=mxgraph.aws4.resourceIcon;resIcon=mxgraph.aws4.general_AWScloud
Never render an unknown service as a plain colored rectangle with no label.
Group Boundaries
- AWS Cloud:
shape=mxgraph.aws4.group;grIcon=mxgraph.aws4.group_aws_cloud_alt;strokeColor=#232F3E;fillColor=none;container=1;dropTarget=1;
- Account:
shape=mxgraph.aws4.group;grIcon=mxgraph.aws4.group_account;strokeColor=#CD2264;fillColor=none;container=1;dropTarget=1;
- On-premise:
shape=mxgraph.aws4.group;grIcon=mxgraph.aws4.group_on_premise;strokeColor=#5A6C86;fillColor=none;container=1;dropTarget=1;
- VPC:
shape=mxgraph.aws4.group;grIcon=mxgraph.aws4.group_vpc2;strokeColor=#8C4FFF;fillColor=none;container=1;dropTarget=1;
- Subnet (public):
shape=mxgraph.aws4.group;grIcon=mxgraph.aws4.group_security_group;strokeColor=#7AA116;fillColor=none;container=1;dropTarget=1;
- Subnet (private):
shape=mxgraph.aws4.group;grIcon=mxgraph.aws4.group_security_group;strokeColor=#147EBA;fillColor=none;container=1;dropTarget=1;
- Logical groups: Simple dashed boxes:
whiteSpace=wrap;html=1;fillColor=none;dashed=1;dashPattern=8 8;container=1;dropTarget=1;
- NO colored backgrounds on group boxes — always
fillColor=none
Container nesting (CRITICAL for grouping):
- ALL boundary/group shapes MUST include
container=1;dropTarget=1; in their style
- Child cells inside a boundary MUST set
parent="<boundary-cell-id>" instead of parent="1"
- This ensures moving a boundary moves all its children together
- Example:
<mxCell id="vpc1" value="VPC" style="shape=mxgraph.aws4.group;grIcon=mxgraph.aws4.group_vpc2;strokeColor=#8C4FFF;fillColor=none;container=1;dropTarget=1;" vertex="1" parent="1">
<mxGeometry x="100" y="100" width="800" height="500" as="geometry" />
</mxCell>
<mxCell id="lambda1" value="Lambda" style="shape=mxgraph.aws4.resourceIcon;resIcon=mxgraph.aws4.lambda;strokeColor=#ffffff;" vertex="1" parent="vpc1">
<mxGeometry x="50" y="50" width="78" height="78" as="geometry" />
</mxCell>
Note: child geometry coordinates are relative to the parent container, not the canvas.
PNG Export Background Fix
Place a full-canvas rectangle as the FIRST element (lowest z-order):
<mxCell value="" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#F5F5F5;strokeColor=none;" vertex="1" parent="1">
<mxGeometry x="0" y="0" width="2400" height="1400" as="geometry" />
</mxCell>
This prevents black background on PNG export. Use strokeColor=none (not E0E0E0).
Multi-page Diagrams
For complex architectures, use multiple pages (tabs) in one .drawio file:
<mxfile>
<diagram id="overview" name="Overview">...</diagram>
<diagram id="networking" name="Networking Detail">...</diagram>
<diagram id="data-flow" name="Data Flow">...</diagram>
</mxfile>
- Page 1: High-level overview (service-level icons only)
- Page 2+: Detail views (resource-level icons, subnet layouts, etc.)
Edge Legend (optional, for complex diagrams)
Place below the title block if the diagram has multiple edge types:
- Solid line: primary data flow
- Dashed line: optional/async
- Red dashed: error path
File Splitting
Since draw.io XML can be large, split creation across multiple tool calls:
- Header + left side (frontend, delivery layer)
- Middle (processing lambdas, database)
- Right side (ingest, messaging, data sources)
- Bottom (optional/outbound flows) + close XML
Audience Mode
Before generating, assess the target audience:
- Technical: Use service names, protocol labels (HTTPS, gRPC), CIDR blocks, instance types
- Non-technical: Use action labels ("Store Data", "Send Notification"), hide implementation details, use numbered flow (① ② ③)
If unclear, ask: "Technical audience or executive/non-technical?"
Numbered Flow Edges (for non-technical mode)
Instead of technical labels, show flow order with circled numbers:
- Flow A: ① → ② → ③ → ④ (white circled numbers)
- Flow B: ❶ → ❷ → ❸ → ❹ (black circled numbers for second flow)
Use edge labels: value="①" with fontSize=14;fontStyle=1;labelBackgroundColor=#ffffff;
Companion Guide
After generating the .drawio file, also generate a markdown guide:
- Same filename with
.md extension (e.g., serverless-api.drawio + serverless-api.md)
- Contents: diagram title, flow description (numbered steps matching edge labels), service list with purpose, key design decisions
Two-Step Edit Approach
After generating the initial .drawio file:
- Export to PNG using the draw.io CLI (see Output section)
- Review the PNG visually — check for empty/broken icons, overlapping edges, misaligned labels
- Fix issues in the .drawio XML and re-export
This catches rendering problems (wrong stencil names, broken styles) that are invisible in raw XML.
Icon Name Gotchas — CRITICAL
draw.io stencil names do NOT always match current AWS service names. Services that were renamed keep their legacy stencil names:
| AWS Service Name |
draw.io resIcon name |
Why |
| Amazon OpenSearch Service |
elasticsearch_service |
Renamed from Elasticsearch in 2021; opensearch_service also works |
| Amazon EventBridge |
eventbridge |
Was CloudWatch Events |
| AWS Fargate |
fargate |
Correct |
| VPC Peering |
peering |
Resource-level: shape=mxgraph.aws4.peering;strokeColor=none — NOT vpc_peering or peering_connection (those render as blank squares) |
| Amazon MSK |
managed_streaming_for_kafka |
NOT msk (renders as blank square) |
| IAM Identity Center |
single_sign_on |
NOT iam_identity_center (renders as blank square) |
Rule: Always verify icon names from the reference files. If a service icon renders as an empty box, the stencil name is wrong. Check the draw.io source at src/main/webapp/js/diagramly/sidebar/Sidebar-AWS4.js for the canonical name (or Sidebar-AWS3D.js for the legacy 3D/isometric library, or Sidebar-AlliedTelesis.js for the generic hardware image library — note the 3D library's shape names are camelCase, e.g. dynamoDb not dynamodb).
Validation Step
After generating XML, mentally verify:
- Every
resIcon= value exists in the reference files
- Service-level icons have
strokeColor=#ffffff
- Resource-level icons have
strokeColor=none
- No XML comments present
- All cell IDs are unique
- Every edge has
<mxGeometry relative="1" as="geometry" />
- No icon uses a guessed stencil name — all verified against reference files
- Every edge has both
source and target attributes referencing valid cell IDs (no floating edges)
- All group/boundary shapes include
container=1;dropTarget=1; in their style
- Children inside boundaries use
parent="<boundary-id>" (not parent="1")
Output
- Save with descriptive filename ending in
.drawio
- Open with
open command (macOS) or xdg-open (Linux) after creation
- For PNG/SVG/PDF export, use draw.io CLI:
- macOS:
/Applications/draw.io.app/Contents/MacOS/draw.io -x -f png -e -b 10 -o output.drawio.png input.drawio
- Linux:
drawio -x -f png -e -b 10 -o output.drawio.png input.drawio
Flags: -x export, -f format, -e embed diagram XML, -b 10 border
- Exported files use double extension:
name.drawio.png (signals embedded XML, re-editable in draw.io)
XML Well-formedness (CRITICAL)
- NEVER include XML comments (
<!-- -->) — they cause parse errors
- Escape special characters in values:
& < > "
- Always use unique
id values for each mxCell
- Every edge MUST have
<mxGeometry relative="1" as="geometry" /> as child element
- Basic structure must include root cells
id="0" and id="1" (parent="0")
Official Reference
1---2name: aws-architecture-diagram3description: Generate AWS architecture diagrams in draw.io format. Activates when the user asks to create, generate, or build an architecture diagram, system diagram, or draw.io diagram for AWS services.4---5
6## Instructions
7
8Generate a draw.io (.drawio) XML file representing an AWS architecture diagram.
9
10### Layout
11- **Left-to-right flow** for data/request path
12- **UI/Frontend on the LEFT** (users access from left side)
13- **Data sources / external systems on the RIGHT**
14- Use horizontal lanes for parallel paths (top lane, bottom lane)
15- **Minimum 220px horizontal spacing** between icons (to leave room for edge labels)
16- **Minimum 250px vertical spacing** between lanes (so vertical edges don't crowd)
17- Secondary/auxiliary services (monitoring, DLQ, error paths) go BELOW the main flow with 280px+ vertical gap
18
19### Canvas
20- Large canvas: `pageWidth="2400" pageHeight="1400"` minimum
21- Set `dx="2800" dy="1600"` for proper viewport
22- Always include a title block as the first element after the background:
23```xml
24<mxCell value="<b>Diagram Title</b><br>Author | Date | Version" style="text;html=1;align=left;verticalAlign=top;whiteSpace=wrap;rounded=0;fontSize=14;spacing=8;" vertex="1" parent="1">
25 <mxGeometry x="40" y="30" width="420" height="60" as="geometry" />
26</mxCell>
27```
28
29### Icon Style
30- Icons are from draw.io's built-in `mxgraph.aws4` stencil library — the **official AWS Architecture Icons** (https://aws.amazon.com/architecture/icons/, updated quarterly)
31- Icon size: **78x78px** for main services, **65x65px** for secondary
32- Use `sketch=0;outlineConnect=0;` on all icons
33- Use `strokeColor=#ffffff` on all AWS service icons
34- **MUST include `fillColor`** — without it, icons render as invisible/white in PNG export
35- Font size: **12px** for labels
36- Always include: `fontColor=#232F3E;verticalLabelPosition=bottom;verticalAlign=top;align=center;html=1;aspect=fixed;`
37
38**fillColor by AWS service category:**
39| Category | fillColor | Services |
40|----------|-----------|----------|
41| Compute | `#ED7100` | Lambda, EC2, ECS, EKS, Fargate |
42| Networking | `#8C4FFF` | VPC, ELB, CloudFront, Route 53, API Gateway |
43| Database | `#C925D1` | RDS, DynamoDB, Aurora, ElastiCache |
44| Storage | `#3F8624` | S3, EFS, EBS |
45| Security | `#DD344C` | IAM, Cognito, KMS, WAF |
46| Integration | `#E7157B` | SQS, SNS, EventBridge, Step Functions |
47| Analytics | `#8C4FFF` | Kinesis, Athena, Redshift |
48| Management | `#E7157B` | CloudWatch, CloudTrail |
49| AI/ML | `#01A88D` | Bedrock, SageMaker |
50
51### 3D / Isometric Diagrams — use a different icon library
52If the user asks for a **3D**, **isometric**, or "AWS 3D" diagram, do NOT fake it by placing flat `aws4` icons on hand-built platform/pedestal shapes. draw.io has a real, separate built-in library for this: `mxgraph.aws3d.*`.
53- Load `references/aws-icons-3d.md` before picking any icon — it has the verified shape table, style prefix, sizes, and the native `isometricEdgeStyle` edge templates.
54- This library is a legacy pre-2019 icon set with **much smaller coverage** than `aws4` (no API Gateway, ECS/EKS/Fargate, Step Functions, EventBridge, SNS, Aurora, CloudWatch, IAM, etc.). Check the gap table in that reference file before assuming an icon exists, and flag substitutions to the user rather than guessing a stencil name.
55- For generic hardware (clients, on-prem servers, racks, switches) with no AWS-specific icon, see `references/aws-icons-allied-telesis.md` — a separate bundled isometric image library that fills that gap.
56- These icons are already 3D on their own — arrange them in an ascending isometric staircase (diagonal offsets between nodes), don't add fake platforms underneath.
57- Use `edgeStyle=isometricEdgeStyle` (with `endArrow=block` override for reliable arrowheads) instead of `orthogonalEdgeStyle` for connectors.
58
59### Edge Style — CRITICAL FOR CLEAN DIAGRAMS
60
61**Base edge style (all edges):**
62```
63edgeStyle=orthogonalEdgeStyle;rounded=1;orthogonalLoop=1;jettySize=auto;html=1;strokeWidth=2;exitX=1;exitY=0.5;exitDx=0;exitDy=0;entryX=0;entryY=0.5;entryDx=0;entryDy=0;
64```
65
66**Rules for edge labels:**
67- Keep labels SHORT (1-2 words max). Use icon labels for detail, not edge labels.
68- On horizontal edges: position label ABOVE the line using `verticalAlign=bottom;` in the edge style
69- On vertical edges: position label to the LEFT using `align=right;` in the edge style
70- Always add `labelBackgroundColor=#F5F5F5;` so labels don't overlap lines
71- For edges WITHOUT labels: omit the `value` attribute entirely (don't use `value=""`)
72
73**Edge label positioning (prevents overlap with icons):**
74```xml
75<mxCell value="Label" style="edgeStyle=orthogonalEdgeStyle;rounded=1;orthogonalLoop=1;jettySize=auto;html=1;strokeWidth=2;labelBackgroundColor=#F5F5F5;fontSize=11;" edge="1" source="a" target="b" parent="1">
76 <mxGeometry relative="1" as="geometry" />
77</mxCell>
78```
79
80**For edges that go to services ABOVE or BELOW the main flow:**
81- Use explicit exit/entry points to control routing:
82 - Exit bottom: `exitX=0.5;exitY=1;exitDx=0;exitDy=0;`
83 - Enter top: `entryX=0.5;entryY=0;entryDx=0;entryDy=0;`
84 - Exit top: `exitX=0.5;exitY=0;exitDx=0;exitDy=0;`
85 - Enter bottom: `entryX=0.5;entryY=1;entryDx=0;entryDy=0;`
86- This prevents draw.io from routing lines through other icons
87
88**Edge types:**
89- Solid black (`strokeWidth=2`): primary data flow
90- Dashed black (`strokeWidth=2;dashed=1;`): optional/async path
91- Dashed red (`strokeWidth=2;dashed=1;strokeColor=#DD344C;`): error path
92
93**Edge attachment (CRITICAL — fixes "green cross" problem):**
94- Every edge MUST have both `source="<cell-id>"` and `target="<cell-id>"` attributes referencing valid cell IDs
95- NEVER create floating/unattached edges — all edges must be bound to shapes at both ends
96- Always include `exitX/exitY` and `entryX/entryY` to define exact connection points on the shape perimeter
97- In draw.io, properly attached edges show a "blue dot" anchor; unattached edges show a "green cross"
98- If an edge connects to a child inside a container, reference the child's ID directly (not the container)
99- **Cross-container edges:** When source and target are in different containers, set the edge's `parent="1"` (root layer) so draw.io can route it across boundaries
100
101**When NOT to label edges:**
102- If the flow is obvious from context (e.g., Lambda → DynamoDB doesn't need "Write")
103- If the icon labels already explain the relationship
104- Prefer fewer, more meaningful labels over labeling every edge
105
106### Visual Quality: straight arrows, no overlaps, professional layout
107
108A diagram with correct icons but a messy layout still reads as unprofessional. Check every diagram against these rules before finishing — they're deliberately concrete/checkable, not vague "make it look nice" advice:
109
110- **Align nodes to a consistent axis so edges are single, straight segments.** Keep the horizontal or vertical delta between adjacent nodes in a flow constant (same lane y-coordinate, same column spacing) so connecting edges render as one clean line instead of a dogleg.
111- **Align branch/secondary nodes on the exact same centerline as their parent.** If a node branches off vertically (e.g. an auxiliary service below the main flow), its horizontal center must match its parent's horizontal center exactly — compute `child.x = parent.center_x - child.width/2`, don't eyeball it. A few pixels of misalignment turns a "straight down" edge into a visibly crooked diagonal.
112- **One bend maximum per edge, ideally zero.** If a computed edge path would need more than one bend to avoid an obstacle, the layout is wrong — move the node, don't add more bends to route around the problem.
113- **No edge may cross through an unrelated icon's bounding box.** Before finalizing coordinates, check each edge's path against every icon's `(x, y, width, height)` rectangle it isn't connected to. If it would cross one, move the node or add an explicit exit/entry point to route around it.
114- **No two edges may run on top of each other or visually merge.** If two edges would travel the same corridor (e.g. two parallel flows between the same pair of lanes), offset them — different exit/entry points, or an explicit waypoint — so there's a visible gap between them.
115- **Minimize edge crossings overall.** Order nodes in the direction the data actually flows so edges rarely need to cross each other. If a crossing is unavoidable (e.g. a feedback/response path), route it with a visible offset rather than letting it overlap another edge.
116- **Keep spacing consistent, not just "enough."** Use the same minimum step size between every pair of adjacent nodes in a flow — a diagram where some gaps are 400px and others are 250px reads as sloppy even if nothing technically overlaps.
117- **Balance the composition on the canvas.** Don't leave one half of the page dense and the other empty; size the canvas to the actual content plus a consistent margin.
118- **Self-check before finishing:** after placing every coordinate, mentally trace each edge from source to target and verify (1) it doesn't cross any icon, (2) it doesn't overlap another edge, (3) it has at most one bend, (4) its endpoints are flush with the icons it connects. Fix the layout, not just the intent, if any check fails.
119
120### Two Icon Patterns — CRITICAL
121
122**Pattern 1: Service-level (resourceIcon frame)**
123- Style: `sketch=0;outlineConnect=0;fontColor=#232F3E;fillColor=<CATEGORY_COLOR>;strokeColor=#ffffff;dashed=0;verticalLabelPosition=bottom;verticalAlign=top;align=center;html=1;fontSize=12;fontStyle=0;aspect=fixed;shape=mxgraph.aws4.resourceIcon;resIcon=mxgraph.aws4.<name>`
124- **MUST use `strokeColor=#ffffff`** — without it, the white glyph disappears
125- **MUST use `fillColor=<color>`** — without it, icon renders as white/invisible square in PNG export
126- Size: 78x78
127
128**Pattern 2: Resource-level (standalone shape)**
129- Style: `sketch=0;outlineConnect=0;fontColor=#232F3E;fillColor=<CATEGORY_COLOR>;strokeColor=none;dashed=0;verticalLabelPosition=bottom;verticalAlign=top;align=center;html=1;fontSize=12;fontStyle=0;aspect=fixed;shape=mxgraph.aws4.<name>`
130- **MUST use `strokeColor=none`** — using #ffffff breaks these
131- **MUST use `fillColor=<color>`** — same reason as above
132- Size: 78x78 or 48x48
133
134**Confusing these patterns guarantees broken icons.**
135
136### Icon Reference Files (load by category as needed)
137- `references/aws-icons-compute.md` — Lambda, EC2, ECS, EKS, Fargate
138- `references/aws-icons-database.md` — DynamoDB, RDS, Aurora, ElastiCache
139- `references/aws-icons-integration.md` — API Gateway, SQS, SNS, EventBridge, Step Functions
140- `references/aws-icons-networking.md` — CloudFront, Route 53, VPC, ELB
141- `references/aws-icons-storage.md` — S3, EFS, EBS, Glacier, Backup
142- `references/aws-icons-security.md` — IAM, Cognito, KMS, WAF, Shield
143- `references/aws-icons-analytics-ml.md` — Kinesis, Athena, Bedrock, SageMaker
144- `references/aws-icons-common.md` — Groups, general resources, edge styles, base template
145- `references/aws-icons-3d.md` — **3D/isometric diagrams**: legacy `aws3d` icon library, coverage gaps, isometric edge style
146- `references/aws-icons-allied-telesis.md` — bonus isometric computer/server/network icons for 3D diagrams (fills `aws3d` gaps)
147
148**Always look up icons from reference files. Never guess icon names.**
149
150**Fallback for unmapped services:** If a service is NOT found in any reference file, use this generic AWS cloud icon with the service name as label:
151```
152sketch=0;outlineConnect=0;fontColor=#232F3E;fillColor=#232F3E;strokeColor=#ffffff;dashed=0;verticalLabelPosition=bottom;verticalAlign=top;align=center;html=1;fontSize=12;fontStyle=0;aspect=fixed;shape=mxgraph.aws4.resourceIcon;resIcon=mxgraph.aws4.general_AWScloud
153```
154Never render an unknown service as a plain colored rectangle with no label.
155
156### Group Boundaries
157- **AWS Cloud:** `shape=mxgraph.aws4.group;grIcon=mxgraph.aws4.group_aws_cloud_alt;strokeColor=#232F3E;fillColor=none;container=1;dropTarget=1;`
158- **Account:** `shape=mxgraph.aws4.group;grIcon=mxgraph.aws4.group_account;strokeColor=#CD2264;fillColor=none;container=1;dropTarget=1;`
159- **On-premise:** `shape=mxgraph.aws4.group;grIcon=mxgraph.aws4.group_on_premise;strokeColor=#5A6C86;fillColor=none;container=1;dropTarget=1;`
160- **VPC:** `shape=mxgraph.aws4.group;grIcon=mxgraph.aws4.group_vpc2;strokeColor=#8C4FFF;fillColor=none;container=1;dropTarget=1;`
161- **Subnet (public):** `shape=mxgraph.aws4.group;grIcon=mxgraph.aws4.group_security_group;strokeColor=#7AA116;fillColor=none;container=1;dropTarget=1;`
162- **Subnet (private):** `shape=mxgraph.aws4.group;grIcon=mxgraph.aws4.group_security_group;strokeColor=#147EBA;fillColor=none;container=1;dropTarget=1;`
163- **Logical groups:** Simple dashed boxes: `whiteSpace=wrap;html=1;fillColor=none;dashed=1;dashPattern=8 8;container=1;dropTarget=1;`
164- **NO colored backgrounds** on group boxes — always `fillColor=none`
165
166**Container nesting (CRITICAL for grouping):**
167- ALL boundary/group shapes MUST include `container=1;dropTarget=1;` in their style
168- Child cells inside a boundary MUST set `parent="<boundary-cell-id>"` instead of `parent="1"`
169- This ensures moving a boundary moves all its children together
170- Example:
171```xml
172<mxCell id="vpc1" value="VPC" style="shape=mxgraph.aws4.group;grIcon=mxgraph.aws4.group_vpc2;strokeColor=#8C4FFF;fillColor=none;container=1;dropTarget=1;" vertex="1" parent="1">
173 <mxGeometry x="100" y="100" width="800" height="500" as="geometry" />
174</mxCell>
175<mxCell id="lambda1" value="Lambda" style="shape=mxgraph.aws4.resourceIcon;resIcon=mxgraph.aws4.lambda;strokeColor=#ffffff;" vertex="1" parent="vpc1">
176 <mxGeometry x="50" y="50" width="78" height="78" as="geometry" />
177</mxCell>
178```
179Note: child geometry coordinates are **relative to the parent container**, not the canvas.
180
181### PNG Export Background Fix
182Place a full-canvas rectangle as the FIRST element (lowest z-order):
183```xml
184<mxCell value="" style="rounded=0;whiteSpace=wrap;html=1;fillColor=#F5F5F5;strokeColor=none;" vertex="1" parent="1">
185 <mxGeometry x="0" y="0" width="2400" height="1400" as="geometry" />
186</mxCell>
187```
188This prevents black background on PNG export. Use `strokeColor=none` (not E0E0E0).
189
190### Multi-page Diagrams
191For complex architectures, use multiple pages (tabs) in one .drawio file:
192```xml
193<mxfile>
194 <diagram id="overview" name="Overview">...</diagram>
195 <diagram id="networking" name="Networking Detail">...</diagram>
196 <diagram id="data-flow" name="Data Flow">...</diagram>
197</mxfile>
198```
199- Page 1: High-level overview (service-level icons only)
200- Page 2+: Detail views (resource-level icons, subnet layouts, etc.)
201
202### Edge Legend (optional, for complex diagrams)
203Place below the title block if the diagram has multiple edge types:
204- Solid line: primary data flow
205- Dashed line: optional/async
206- Red dashed: error path
207
208### File Splitting
209Since draw.io XML can be large, split creation across multiple tool calls:
2101. Header + left side (frontend, delivery layer)
2112. Middle (processing lambdas, database)
2123. Right side (ingest, messaging, data sources)
2134. Bottom (optional/outbound flows) + close XML
214
215### Audience Mode
216Before generating, assess the target audience:
217- **Technical**: Use service names, protocol labels (HTTPS, gRPC), CIDR blocks, instance types
218- **Non-technical**: Use action labels ("Store Data", "Send Notification"), hide implementation details, use numbered flow (① ② ③)
219
220If unclear, ask: "Technical audience or executive/non-technical?"
221
222### Numbered Flow Edges (for non-technical mode)
223Instead of technical labels, show flow order with circled numbers:
224- Flow A: ① → ② → ③ → ④ (white circled numbers)
225- Flow B: ❶ → ❷ → ❸ → ❹ (black circled numbers for second flow)
226
227Use edge labels: `value="①"` with `fontSize=14;fontStyle=1;labelBackgroundColor=#ffffff;`
228
229### Companion Guide
230After generating the .drawio file, also generate a markdown guide:
231- Same filename with `.md` extension (e.g., `serverless-api.drawio` + `serverless-api.md`)
232- Contents: diagram title, flow description (numbered steps matching edge labels), service list with purpose, key design decisions
233
234### Two-Step Edit Approach
235After generating the initial .drawio file:
2361. **Export to PNG** using the draw.io CLI (see Output section)
2372. **Review the PNG** visually — check for empty/broken icons, overlapping edges, misaligned labels
2383. **Fix issues** in the .drawio XML and re-export
239
240This catches rendering problems (wrong stencil names, broken styles) that are invisible in raw XML.
241
242### Icon Name Gotchas — CRITICAL
243draw.io stencil names do NOT always match current AWS service names. Services that were renamed keep their legacy stencil names:
244
245| AWS Service Name | draw.io resIcon name | Why |
246|---|---|---|
247| Amazon OpenSearch Service | `elasticsearch_service` | Renamed from Elasticsearch in 2021; `opensearch_service` also works |
248| Amazon EventBridge | `eventbridge` | Was CloudWatch Events |
249| AWS Fargate | `fargate` | Correct |
250| VPC Peering | `peering` | Resource-level: `shape=mxgraph.aws4.peering;strokeColor=none` — NOT `vpc_peering` or `peering_connection` (those render as blank squares) |
251| Amazon MSK | `managed_streaming_for_kafka` | NOT `msk` (renders as blank square) |
252| IAM Identity Center | `single_sign_on` | NOT `iam_identity_center` (renders as blank square) |
253
254**Rule:** Always verify icon names from the reference files. If a service icon renders as an empty box, the stencil name is wrong. Check the draw.io source at `src/main/webapp/js/diagramly/sidebar/Sidebar-AWS4.js` for the canonical name (or `Sidebar-AWS3D.js` for the legacy 3D/isometric library, or `Sidebar-AlliedTelesis.js` for the generic hardware image library — note the 3D library's shape names are camelCase, e.g. `dynamoDb` not `dynamodb`).
255
256### Validation Step
257After generating XML, mentally verify:
2581. Every `resIcon=` value exists in the reference files
2592. Service-level icons have `strokeColor=#ffffff`
2603. Resource-level icons have `strokeColor=none`
2614. No XML comments present
2625. All cell IDs are unique
2636. Every edge has `<mxGeometry relative="1" as="geometry" />`
2647. No icon uses a guessed stencil name — all verified against reference files
2658. Every edge has both `source` and `target` attributes referencing valid cell IDs (no floating edges)
2669. All group/boundary shapes include `container=1;dropTarget=1;` in their style
26710. Children inside boundaries use `parent="<boundary-id>"` (not `parent="1"`)
268
269### Output
270- Save with descriptive filename ending in `.drawio`
271- Open with `open` command (macOS) or `xdg-open` (Linux) after creation
272- For PNG/SVG/PDF export, use draw.io CLI:
273 - macOS: `/Applications/draw.io.app/Contents/MacOS/draw.io -x -f png -e -b 10 -o output.drawio.png input.drawio`
274 - Linux: `drawio -x -f png -e -b 10 -o output.drawio.png input.drawio`
275 Flags: `-x` export, `-f` format, `-e` embed diagram XML, `-b 10` border
276- Exported files use double extension: `name.drawio.png` (signals embedded XML, re-editable in draw.io)
277
278### XML Well-formedness (CRITICAL)
279- **NEVER include XML comments (`<!-- -->`)** — they cause parse errors
280- Escape special characters in values: `&` `<` `>` `"`
281- Always use unique `id` values for each mxCell
282- Every edge MUST have `<mxGeometry relative="1" as="geometry" />` as child element
283- Basic structure must include root cells `id="0"` and `id="1"` (parent="0")
284
285### Official Reference
286- Full XML/style reference: https://raw.githubusercontent.com/jgraph/drawio-mcp/main/shared/xml-reference.md
287- Style properties: https://raw.githubusercontent.com/jgraph/drawio-mcp/main/shared/style-reference.md