AI Coding Tools Tested: Generating Architecture Diagrams in Practice
This article examines why turning requirements documents into architecture and module diagrams is harder to automate than writing code, and how to make it reliable with AI coding tools. It covers adding vision capability to a text-only model, a four-stage plan-first workflow, converting subjective style preferences into verifiable constraints, separate checklists for functional module diagrams and system architecture diagrams, common failure modes, and practical tips for making the process a repeatable team asset.
1. The Problem: Why Diagramming Is Harder to Automate Than Coding
When teams evaluate AI coding tools, they often use a single yardstick: can it produce runnable code? But in real engineering collaboration, another frequent and time-consuming task is equally worth automating: converting an existing requirements document or feature module document into a system architecture diagram or functional module diagram with consistent styling and clear hierarchy.
This task is difficult for three reasons.
First, it is a multimodal task. The input includes both structured text (documents, API lists, data tables) and visual references (the team’s existing diagram templates and color guidelines). A text-only model cannot understand instructions like “follow the style of this diagram.”
Second, there is no single correct answer. Code can be judged by compilation and tests, but diagrams involve subjective dimensions such as layout, whitespace, connector routing, and color contrast, which require reusable evaluation criteria.
Third, it is sensitive to context length. A medium-sized requirements document plus several reference images can easily exceed a single context window, so a phased strategy of “analyze first, plan next, then execute” is needed to stay in control.
One clarification: in early experiments, the low success rate of “gacha-style” one-shot attempts was mostly not a model capability issue. The task was thrown at the model all at once, and the constraints were not expressed in a structured way. Breaking the process into stages makes a noticeable difference in stability.
2. Prerequisites: Giving a Text Model the Ability to “See”
If the model you are using only accepts text input, then “reference the colors and layout of this image” cannot be done directly. A common industry approach is to attach a vision-understanding extension to the coding tool, converting images into textual descriptions that the model can reason over.
In related practice at Baidu AI Cloud, this capability is typically implemented by combining a model service with a tool-call extension: the main model handles planning and code/text generation, while the vision-understanding service handles image parsing, with the two connected through tool calls. The configuration concept can be abstracted as follows (field names should follow the documentation of the platform you use; do not copy this verbatim):
{"command": "npx","args": ["-y", "<vision-extension-package-name>"],"env": {"API_KEY": "<your-access-key>","MODE": "VISION"},"type": "stdio"}
After configuration, always run a connectivity check: verify in the session that the extension loaded successfully, then upload a simple image and ask the model to describe its elements and colors. If this step fails, every subsequent “draw in this style” instruction will degrade into generation from nothing.
Security note: access keys should be injected through environment variables or a local secret manager. Do not write them into configuration files inside the project and commit them to the code repository. For team collaboration, use a key strategy that supports rotation and auditing.
3. Workflow Design: Use Plan Mode Instead of One-Shot Generation
Stable output depends on a stable process. The recommended approach splits the task into four stages and has the tool proceed by producing a plan first and then executing it.
- Style extraction. Provide an existing team diagram as a reference and ask the model to output a structured style description rather than drawing immediately. You can require it to answer with fixed fields:
Output JSON only, no explanation:{"layout": "which of layered/radial/grid, and number of levels","palette": ["primary", "secondary", "background"],"shape": {"module": "rounded rectangle/rectangle", "group": "dashed box/filled block"},"connector": "straight/elbow/arrow style","typography": "font size hierarchy and weight"}
Document parsing. Have the model extract an entity list and relationships from the requirements document, forming a “module—responsibility—dependency” triple table. The output of this step should be quick for a human to review.
Plan generation. Based on the style description and entity list, produce an execution plan: canvas size, section order, connection rules, and rendering method.
Execution and self-check. After generating the diagram, ask the model to verify it item by item against the JSON from step 1 and list the deviations.
In terminal-based tools that support image pasting, the paste shortcut is usually Alt + v (on Windows), which determines whether the reference image can be reliably brought into context. If the tool does not support it, save the image as a file first and reference the path in the session.
4. Prompts and Constraints: Turning Subjective Aesthetics into Verifiable Rules
“Make it look nicer” is not an executable instruction. An executable version breaks aesthetics down into constraints:
- Hierarchy constraints: no more than three levels; modules on the same level have the same size; spacing is a multiple of 24px.
- Naming constraints: module names use the original terms from the document, with no synonym substitution, to avoid ambiguity during review.
- Connector constraints: cross-level dependencies use arrows; same-level calls use straight lines; connectors do not cross module boundaries.
- Color constraints: the primary color is for core services, the secondary color for supporting components, and the background stays low-saturation; contrast between body text and background is at least 4.5:1.
- Output constraints: prefer a version-controllable textual diagram definition (such as a description language like Mermaid or PlantUML); bitmaps are only for preview.
The last point is especially important. A textual diagram definition can go through code review and be committed along with requirement changes, whereas an exported image cannot be meaningfully diffed.
flowchart TBsubgraph Access LayerA[Access and Routing]endsubgraph Service LayerB[Business Services]C[Domain Services]endsubgraph Support LayerD[(Object Storage)]E[Message Queue]F[Logging and Monitoring]endA --> B --> CB --> DC --> EB --> F
5. Verification: Functional Module Diagrams vs. System Architecture Diagrams
The most common cause of rework in practice is conflating the two diagram types. They focus on different things:
- A functional module diagram answers “what capabilities the system has.” It emphasizes the completeness and non-overlap of functional decomposition, is usually layered by business domain, and does not show deployment or data flow.
- A system architecture diagram answers “how the system runs.” It emphasizes components, protocols, data flows, deployment boundaries, and non-functional attributes (availability, scalability, security zones).
The checklists should therefore be separate. For a functional module diagram, check: whether every requirement item is placed, whether responsibilities overlap, and whether naming matches the document. For a system architecture diagram, check: whether the protocol and direction of each connector are clear, whether there is a direct connection across security zones, whether single points of failure are marked, and whether external dependencies appear in pairs (primary and fallback paths).
A practical approach is to have the model output both the “diagram” and a “deviation note”: which requirement items failed to map to modules, which connectors lack protocol labels, and which module responsibility boundaries are vague. This deviation note is often more valuable than the diagram itself, because it points directly to gaps in the document.
6. Common Failure Modes and Tuning
- The reference image is not actually read: this shows up as completely random colors and layout. Go back to the connectivity check and confirm the vision extension is enabled.
- Layout drift: modules keep multiplying and hierarchy gets out of control. Fix the canvas size and level limit in the prompt, and require the entity list to be output before drawing.
- Terminology gets rewritten: the model tends to “polish” names. Explicitly require verbatim use of document terms, and do a string comparison during self-check.
- Messy connectors: require an adjacency list (source, target, protocol) first, then render from it, instead of thinking while drawing.
- Context overflow: for long documents, produce a segmented summary first and keep the “module—responsibility—dependency” table as the compressed intermediate state.
7. Recommendations
Turning this process into a team asset pays off far beyond a single generation: put the style description JSON, prompt templates, and checklists into the repository so any member can reproduce the same visual standard; review the textual diagram definition in the same change as the requirements document, so architecture drift surfaces during review rather than after release. If cloud resources are involved, use generic category names for components such as storage, queues, container platforms, logging, and monitoring in the diagram, to make cross-vendor migration and cost evaluation easier.
Overall, success is determined not by the model brand but by whether the task is structured: first give the tool the ability to read images, then break aesthetics into constraints, and finally carry the result in a versionable textual artifact. With these three points in place, producing a usable architecture diagram in a single conversation is not luck, but a repeatable engineering capability.
