An AI tool for diagram generation: Experiences with multi-agent architectures#
A tool was developed that generates technical diagrams from text descriptions. What makes it special is that a multi-stage validation pipeline automatically checks and corrects the generated code.
The result is a practical tool that supports 12 different diagram types and makes it possible to implement the majority of requests directly.
What was the goal?#
A tool for diagram creation#
To develop a tool that generates diagrams from natural language descriptions. The tool should support different diagram types (e.g., flowcharts, sequence diagrams, class diagrams).
At the same time, the project should serve as a learning environment for experimenting with multi-agent architectures and investigating how the reliability of AI-generated code can be improved.
What can the tool do?#
The four main functions#
- Create 12 different diagram types (e.g., flowcharts, sequence diagrams, class diagrams)
- Automatically check and repair code through multi-stage validation
- Live editor with undo function for manual adjustments
- Template library with 40+ templates for common scenarios
The technical basis#
The tool comprises 13,000 lines of code in 27 Python files. The interface combines chat, data entry, code editor, and diagram gallery.
How was it developed?#
Short sessions instead of marathon programming#
Development took place in short sessions. 10-15 minutes daily, spread over two weeks.
The five development phases#
The process ran in five phases:
- Phase 1 (90 minutes): Architecture planning with AI
- Phase 2 (30 minutes): Implementing basic components
- Phase 3 (30-45 minutes): Integrating automatic code validation
- Phase 4 (30-45 minutes): Expand error correction strategies
- Phase 5 (30-45 minutes): Integrate complete syntax reference
The result in numbers#
Total effort: Approximately 6 hours of pure development time.
Result: A functional tool that appears to generate approximately 19 out of 20 diagrams correctly in initial tests.
Why did it work so well?#
The key: Investment in planning#
The investment in preparation seems to have paid off.
The 90-minute architecture discussion at the beginning probably prevented many problems later on. Instead of starting to program right away, we first clarified: Which components are needed? How should they work together? Which patterns make sense?
Faster development through clarity#
This clarity clearly accelerated development. Each phase could be completed with a large iteration because the direction was clear.
Important findings#
1. Specialized agents can create structure#
Three separate components were built: one for chat interaction, one for code generation, and one for validation. Each has a clear task.
This separation seems to help the AI focus on one thing. The validation agent only has to check and correct, not also understand what the user wants.
2. Complete syntax references seem crucial#
The biggest leap in quality came in phase 5. The complete diagram syntax was built into the system – every rule, every format, every exception.
Code quality increased noticeably. The AI finally had all the information it needed to produce correct code. According to a rough estimate, the success rate improved from around 70% to 95%.
3. Subsequent correction remains difficult#
Automatic repair works in many cases, but it is not perfect. If the AI generates faulty code, a second AI instance can fix many errors.
However, some cases require template fallbacks or manual correction. Prevention through good references seems to be more effective than subsequent repair.
What can others learn from this?#
Practical recommendations from the project#
- Invest time in architecture planning – thorough preparation can reduce subsequent error correction
- Provide the AI with complete references – partial information could lead to errors
- Incorporate validation loops – automatic checking can catch many errors
- Work in short sessions – short daily sessions may be more effective than long marathons
- Plan for multiple correction attempts – the first repair does not always work
Conclusion#
The three key messages#
✔ Systematic validation can make AI-generated diagrams significantly more reliable
✔ Multi-agent structures can help organize complex AI projects
✔ Complete syntax references seem more important than clever correction algorithms
This is part of a series on AI-assisted software development. The focus is on what can be learned from such projects – not just on the results.