AI Code Reverse creates UML class diagrams and sequence diagrams from your source code, using an AI service you choose. Use it to understand code you inherited, trace how a request flows through it, or document it. For use cases with prompts and videos, see AI Modeling in Astah.
AI Code Reverse at work: class diagrams from a project, then a sequence diagram from one method. Edited to shorten waiting time.
Overview
Supported products
AI Code Reverse works with these products, version 11 and later:
JavaClasses, interfaces, enums, annotations and generics
C#.NET Framework, .NET Core and .NET 5 and later
PythonPython 3 classes, decorators and type annotations
TypeScriptInterfaces, generics and decorators
GoStructs, interfaces and method receivers
C++Classes, templates and namespaces
Also supported:
JavaScript
Kotlin
Swift
PHP
Ruby
Rust
Supported AI services
OpenAI
Anthropic Claude
Google Gemini
OpenAI-compatible services
API key required
Astah has no built-in AI. To use AI Code Reverse, you need your own API key from a supported AI service, and the AI provider bills you for usage. Large code bases use more tokens and cost more. See Set up AI Code Reverse.
When to use it
Understand an existing system: get an overview of the classes and their relationships when you join a project or take over code.
Debug and analyze issues: see the call order of a bug that spans several methods, or check whether the code still matches the design.
Plan a new feature: see which classes work together and where a method is called before you change it.
Privacy and limitations
Your source code is sent from your computer to the AI service you choose. Change Vision does not receive it. Check the AI service’s terms and data policies before you use it.
AI-generated diagrams may be incomplete or inaccurate. Review them before you use them, and back up your project first.
Set up the AI service once before you use AI Code Reverse.
Choose [Tools] > [AI Code Reverse].
In the AI Code Reverse dialog, click Option.
Choose or add a configuration.Current Configuration lists ready-made settings for supported AI services. Choose one, or enter the following and click Add.
Configuration Name: any name. Add works only after you enter a name.
Model Name: the model to use, exactly as your AI service names it in its API documentation.
Test the connection. Click Test Connection to check the settings.
Click OK to save.
Before you start
AI Code Reverse reads a lot of code at once. These steps help you get clear diagrams and avoid running out of memory.
Start small. Begin with one package, module or method in one language, check the result, then widen the scope.
Process large code bases in parts. Choose sub-directories or modules instead of the whole solution.
Save after each part. Save your .asta file after each successful run.
Refine your prompt step by step. Adjust the User Prompt based on the result and run again.
Increase the memory for large projects
In the Astah installation folder, open astah-pro.l4j.ini (Astah Professional) or astah-uml.l4j.ini (Astah UML).
Change -Xmx1024m to a higher value, for example -Xmx4096m.
Restart Astah.
Generate a class diagram
Choose [Tools] > [AI Code Reverse].
In Target Directory, choose the folder with your source code. Turn on Include Subdirectories if needed.
In Target Diagram Type, select Class Diagram.
Set the options:
Auto create class diagram: creates one class diagram per package or namespace, named after it. For large projects, turn it off and create diagrams afterward.
Show full class details: shows attributes and operations in the diagrams.
User Prompt: tells the AI what to include or leave out. See the example below.
Click OK. The AI analyzes the code and adds the classes, attributes, operations and relationships to your model.
Example User Prompt:
Create a class diagram for the library package. Show the classes with their
attributes, operations and relationships, including interfaces and
inheritance. Do not create classes for built-in types such as str, date or
list, and do not show constructors such as __init__.
This video has been edited to shorten waiting time. Generation time and results vary depending on the AI service and model you use.
How fields are modeled
As attributes:
primitive types, strings and enums
collections of value types, for example List<String> or Map<String, Integer>
As associations:
user-defined types
collections and arrays of user-defined types
Generate a sequence diagram
Choose [Tools] > [AI Code Reverse].
In Target Directory, choose the folder with your source code. Turn on Include Subdirectories if needed.
In Target Diagram Type, select Sequence Diagram.
Set the options:
Max Call Hierarchy Depth: how many levels of calls to show. A smaller value keeps the diagram easier to read.
Entry Methods (optional): the method to start from, for example OrderService.processOrder. Leave it empty to let the AI choose. See Entry methods.
User Prompt: tells the AI what to show or leave out. See the example below.
Click OK. The AI follows the calls in the code and creates the sequence diagram.
Example Entry Methods and User Prompt:
Entry Methods:
LibraryService.borrow_book(str, str, date)
User Prompt:
Create a sequence diagram for LibraryService.borrow_book(). Show the main successful flow:
find the member and the book, check can_borrow() and is_available(), create the Loan and
send the confirmation. Label every message and show return values as reply messages.
This video has been edited to shorten waiting time. Generation time and results vary depending on the AI service and model you use.
Tip
Run it first with Entry Methods empty to see where the AI starts. Then enter a specific method to focus on the flow you need.
Entry methods
If you leave Entry Methods empty, the AI chooses a starting point, such as:
web framework entry points, for example Spring Boot @RestController, Flask @app.route or Express app.get()
public API methods
key business logic methods
unit or integration test methods
Calls across languages
The AI can follow calls across languages, for example Java to Python to Go, and show them in one sequence diagram. Keep all the related code inside the Target Directory.
Troubleshooting
Select an issue to see how to fix it.
Results for a multi-language project are inaccurate