Code2UML: Agentic LLMs with context engineering for scalable software visualization
This paper introduces Code2UML, an agentic LLM system featuring a deterministic context engineering layer that enables scalable, high-quality automated UML diagram generation from large-scale source code repositories while maintaining stable performance across varying project sizes and programming languages.
Original paper licensed under CC BY 4.0 (http://creativecommons.org/licenses/by/4.0/). This is an AI-generated explanation of the paper below. It is not written or endorsed by the authors. For technical accuracy, refer to the original paper. Read full disclaimer
Imagine you have a massive library of books (a software codebase) and you want to create a simple map (a UML diagram) showing how the rooms connect, where the exits are, and how people move between them.
The problem is that the library is so huge that if you try to describe the entire thing to a single expert (an AI) at once, they get overwhelmed, start making things up, or simply stop halfway through. This is the "context limit" problem the paper addresses.
The authors, Code2U, built a smart team of AI assistants to solve this. Instead of asking one giant AI to do everything, they created a hierarchy of five specialized agents (think of them as a construction crew with specific jobs) and a clever data compression system.
Here is how their system works, broken down into simple concepts:
1. The "Context Engineering" Filter (The Librarian)
Before the AI team even looks at the code, a special tool acts like a super-fast librarian.
- The Problem: The full library of code is too big to fit in the AI's "working memory" (its context window).
- The Solution: This tool doesn't use AI to decide what to keep. Instead, it uses strict, pre-written rules (deterministic logic) to quickly scan the code and create a customized "snapshot" for the specific map you want to draw.
- The Analogy: Imagine you need a map of a city's subway system. The librarian doesn't ask the AI, "What's important?" Instead, the librarian instantly throws away all the street names, building addresses, and park details, keeping only the subway stations and tracks. This snapshot is tiny, fits perfectly in the AI's memory, and happens in milliseconds without needing any AI brainpower.
2. The Five-Agent Crew
Once the librarian creates the right snapshot, a team of five specialized AI agents takes over. They work together like a well-oiled machine:
- The Planner (The Architect): Looks at the snapshot and decides, "Okay, we need to break this big project into smaller chunks. Let's make three separate maps for the different departments."
- The Analyzer (The Detective): For each chunk, this agent reads the specific files and summarizes the key interactions (who talks to whom). It ignores the noise and focuses on the signal.
- The Diagram Agent (The Artist): This agent takes the summary and actually draws the map (writing the code for the diagram).
- The Corrector (The Editor): The artist might make small mistakes (like a typo in the map legend). This agent reads the finished map, checks it against the rules, and fixes any errors instantly.
- The Dependency Analyzer (The Supply Chain Manager): This agent looks outside the main code to see what external tools or libraries the project uses, ensuring the map includes those connections too.
3. The Results: What Did They Find?
The team tested this system on 12 different open-source software projects (ranging from tiny apps to massive systems) written in four different languages (Java, Python, JavaScript, PHP). They tried to generate 7 different types of maps (like class diagrams, flowcharts, and deployment maps).
Here is what happened:
- High Accuracy: The maps were almost always syntactically correct (about 91.5% were perfect right away; for some types like "Component" and "Deployment" maps, it was 100%).
- Smart Summaries: The system didn't try to list every single piece of code (which would make the map unreadable). Instead, it focused on the most important parts. It captured about 31% of the code entities, but those were the right ones.
- Consistency: It worked just as well on a small project with 30 lines of code as it did on a giant project with over 4,500 lines. The quality didn't drop as the project got bigger.
- No Hallucinations: The maps rarely invented fake connections between code parts. If the map said two things were connected, they actually were.
4. Why This Matters
The paper argues that previous attempts to use AI for this failed because they tried to feed the entire codebase to the AI at once.
- Old Way: "Here is the whole library, please draw a map." (Result: The AI gets confused and makes mistakes).
- Code2U Way: "Here is a tiny, perfectly filtered snapshot of just what you need for this specific map. Now, please draw it." (Result: A clean, accurate, and valid map).
Summary
The paper introduces a system that automates the creation of software blueprints. It succeeds by not trying to be a "one-size-fits-all" genius, but by acting as a specialized team that first compresses the data intelligently and then collaborates to draw accurate, valid diagrams. It proves that you can generate high-quality software maps for massive codebases without the AI getting overwhelmed.
Drowning in papers in your field?
Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.