An AI Agent Skill and programmatic Python engine for AI assistants (Antigravity IDE, Gemini, etc.) to author, inspect, audit, and batch-generate native, fully editable Wondershare EdrawMax (
.eddx) diagrams from declarative JSON specifications.
This repository is packaged as a ready-to-use AI Agent Skill (defined in SKILL.md). It empowers AI agents to generate professional, native EdrawMax diagrams automatically without needing manual GUI interaction.
- Natural Language β Native
.eddx: When a user requests a Data Flow Diagram (DFD), Use Case diagram, or Activity diagram, the AI agent authors a JSON spec and compiles it directly into an.eddxfile. - Conversion & Batch Generation: Converts text diagrams (Mermaid, PlantUML, Visio
.vsdx) into native EdrawMax diagrams for SRS documents, theses, or system design specifications. - Template-Based XML cloning: The AI agent never has to write raw XML geometry; the engine clones real shapes directly from live reference
.eddxtemplates.
Drawing dozens of software architecture or systems analysis diagrams manually in EdrawMax is slow, and modifying them later (e.g., updating a process name or rerouting flows) is tedious.
This skill treats diagrams as declarative code. Diagrams are written as structured JSON specifications that can be version-controlled with Git, validated, and programmatically compiled in seconds into native .eddx files.
- No hardcoded XML geometry: Instead of manually building complex SVG/XML geometry, this tool uses reference
.eddxtemplate files as live shape libraries. Shape XML elements are cloned directly from EdrawMax itself, preserving original formatting, control points, formulas (F), and shape numbers. - True Connector Glue: Connectors are bound to shape connection points (
CPoints) and indexed in the internal<Connects>table. When you open the generated.eddxfile in EdrawMax, arrows move dynamically with shapes when dragged. - Smart Orthogonal Router: An integrated A* + simple-path routing engine navigates connectors around shapes, handles line jumping (bridges), prevents overlap, and aligns flow labels with clean text clipping.
- Multiple Layout Modes: Dedicated auto-layout engines (Radial for DFDs, Swimlane for Activity diagrams, Usecase layouts, Column grids) or manual
x,ycoordinate overrides.
| Diagram Type | Spec / Template Key | Layout Engine | Supported Elements |
|---|---|---|---|
| Data Flow Diagram (DFD) | dfd |
radial |
Processes (Gane-Sarson P1), Data Stores (D1), External Entities (E1), Sister Entities (P3:), System Boundaries, Duplicated Satellites |
| Use Case Diagram | usecase |
usecase |
Actors, Use Cases, System Boundaries, Associations, Extend / Include relations |
| Activity Diagram | activity |
swimlane |
Start/End States, Actions/States, Decision Diamonds, Vertical Swimlanes |
.
βββ SKILL.md # Antigravity AI Agent Skill definition
βββ README.md # Project documentation (this file)
βββ scripts/
β βββ eddx_gen.py # Core Generator: JSON Spec β Native .eddx
β βββ router.py # Orthogonal A* Router & lane collision solver
β βββ eddx_audit.py # Quantitative layout quality auditor (intersections, collisions)
β βββ eddx_preview.py # Fast SVG rendering engine for quick visual inspection
β βββ uml_audit.py # Pre-generation validator against UML 2.5 rules
β βββ eddx_inspect.py # Reverse-engineering tool for extracting shapes from .eddx
β βββ progress.py # Build metrics & tracking helper
βββ assets/
β βββ templates/ # Live .eddx template files & default JSON specs
β βββ dfd.eddx / dfd.json
β βββ usecase.eddx / usecase.json
β βββ activity.eddx / activity.json
βββ references/
βββ eddx-format.md # Reverse-engineered structure of the .eddx ZIP/XML format
βββ dfd.md # Gane & Sarson DFD rules, level balancing, & guidelines
- Python 3.8+
- Dependencies: Standard Python library only (
xml.etree.ElementTree,zipfile,json,math,heapq,argparse). No third-party package installation required for core.eddxgeneration!
Run eddx_gen.py providing a JSON spec file and your target .eddx output path:
python scripts/eddx_gen.py path/to/spec.json -o output.eddxOptionally specify a custom template descriptor:
python scripts/eddx_gen.py path/to/spec.json -o output.eddx -t assets/templates/dfd.jsonCheck your diagram layout visually without opening EdrawMax:
python scripts/eddx_preview.py output.eddx -o preview.svgEvaluate layout quality metrics (collisions, overlapping lines, label intersections, elbow counts):
python scripts/eddx_audit.py output.eddxEnsure your specification complies with UML 2.5 standards before generating:
python scripts/uml_audit.py path/to/spec.jsonHere is an example specification for a Data Flow Diagram (DFD Level 1):
{
"diagram": "dfd",
"title": "A-P3 β Questionnaire Processing & Estimation",
"layout": {
"mode": "radial",
"margin": 90,
"col_gap": 215,
"row_gap": 70,
"duplicate": {
"min_degree": 3,
"types": ["store", "external"]
}
},
"nodes": [
{"id": "E1", "type": "external", "num": "A-E1", "label": "Applicant"},
{"id": "P1", "type": "process", "num": "A-P3.1", "label": "Display Questionnaire Step"},
{"id": "P2", "type": "process", "num": "A-P3.2", "label": "Calculate Cost Estimate"},
{"id": "D5", "type": "store", "num": "A-D5", "label": "Question Bank"},
{"id": "N1", "type": "entity", "label": "A-P4: Billing & Collection"},
{"id": "BND", "type": "boundary", "label": "A-P3 Boundary", "members": ["P1", "P2"]}
],
"flows": [
{"from": "E1", "to": "P1", "label": "Project & Building Details"},
{"from": "D5", "to": "P1", "label": "Questions List"},
{"from": "P1", "to": "P2", "label": "Responses Data"},
{"from": "P2", "to": "N1", "label": "Approved Estimate"}
]
}diagram: Template type (dfd,usecase,activity).nodes: List of diagram elements.id: Internal unique key for connecting flows (not displayed).num: Element identifier tag (e.g. process numberA-P3.1).label: Main display text (supports UTF-8, Arabic, English, multi-line).x,y(optional): Manual absolute coordinates if auto-layout is not desired.
flows/edges: Connectors between node IDs.from/to: Source and target node IDs.label(optional): Connector label text.bidir:truefor bidirectional arrows.no_jump:trueto skip line-bridge curves on intersection.
In DFDs, processing flows primarily between processes while external entities and data stores connect to one or two processes. The radial layout engine:
- Places the process chain linearly along the central axis (horizontal or vertical based on diagram aspect ratio).
- Distributes external entities and data stores around an enclosing ellipse directly opposite the processes they serve.
- Automatically snaps satellite items adjacent to their main process, reducing line crossings dramatically (observed reduction from 166 to 27 intersections on complex enterprise DFDs).
- Evaluates candidate paths (L-shaped, Z-shaped, and A* grid paths) using a cost function balancing:
$$\text{Cost} = \text{Intersections} \times C_{\text{cross}} + \text{Turns} \times C_{\text{turn}} + \text{Overlays} \times \infty + \text{Length}$$ - Detour Limiter: Prevents unrealistic 1000px detours around minor intersections.
-
Label Clipping: Renders text blocks with explicit white background fill masks (
BkColor="#ffffff") to cleanly clip flow lines behind labels.
Rather than scaling down text to unreadable small fonts to force A4 compliance, eddx_gen.py maintains optimal 1:1 readable font sizes and configures native .eddx PrintSetup with FittoSheet="TRUE". This ensures the diagram exports cleanly to a single A4 PDF page without compromising editing readability in EdrawMax.
To add a new diagram type (e.g., Sequence Diagram or ERD):
- Create a representative diagram in EdrawMax and save it as
assets/templates/your_type.eddx. - Run
eddx_inspect.pyto extract shape definitions and CPoints:python scripts/eddx_inspect.py assets/templates/your_type.eddx
- Create a corresponding template JSON descriptor (
assets/templates/your_type.json) mapping node types to shape IDs.
For full technical specifications of the .eddx file format (ZIP archive layout, formula syntax, transform properties, ConPoints, and <Connects> tables), see references/eddx-format.md.
- EDDX Format Specification β Reverse-engineered XML & ZIP structure details.
- DFD Gane & Sarson Rules β Conventions, balancing rules, and level decomposition standards.
- Antigravity Skill Definition β Detailed AI instructions for
edrawmax-diagrams.
MIT / Open Source β feel free to use, extend, and integrate into your documentation pipelines.