“A sequence diagram shows process interactions arranged in time sequence in the field of software engineering. It depicts the processes involved and the sequence of messages exchanged between the processes needed to carry out the functionality.“1
However, like all forms of documentation, a sequence diagram is only useful when it’s current and accurate. So AppMap gives you the ability to instantly generate sequence diagrams of any recorded program. A generated sequence diagram is accurate and easy to produce, and it can be re-created on demand.
You can use AppMap to generate and compare sequence diagrams from your code editor, or you can use the CLI tools. Sequence diagrams can be generated as SVG images, or in popular text formats like PlantUML so that you can edit and share the diagrams however you prefer.
Any AppMap can be exported as a sequence diagram. By default, the entire AppMap is represented in the diagram. The following conventions apply:
Download the PlantUML JAR file from https://plantuml.com/download
Configure the file location:
Right-click on an AppMap, or run the command AppMap: Generate Sequence Diagram
Sequence Diagram support is not yet available in JetBrains IDEs. You can use the AppMap CLI to generate sequence diagrams - see the next section for details.
sequence-diagram
You can generate sequence diagrams using the AppMap CLI command sequence-diagram
.
An example:
$ npx @appland/appmap@latest sequence-diagram --format plantuml tmp/appmap/minitest/Following_followers_page.appmap.json
When two AppMaps are similar, it can be useful to represent them as sequence diagrams and then compare them. This is most useful:
Sequence diagram comparisons can be attached to GitHub Pull Requests to make it easier for reviewers to better understand changes in code.
sequence-diagram-diff
For example, compare two similarly named AppMaps:
$ npx @appland/appmap@latest sequence-diagram-diff --format plantuml Following_followers_page.appmap.json Followers_following_page.appmap.json
For example, compare two versions of the same AppMap:
$ npx @appland/appmap@latest sequence-diagram-diff --format plantuml tmp/v1/Following_followers_page.appmap.json tmp/v2/Following_followers_page.appmap.json
e.g. tools that accept Mermaid or PlantUML syntax
AppMap can generate sequence diagrams in the PlantUML format, a textual format which is portable and easy to modify. So you can touch up the generated diagrams, and copy-paste the diagram text into a wide variety of tools that support the PlantUML format, such as Atlassian Confluence.
There are two ways to generate a PlantUML sequence diagram:
sequence-diagram
command with the option --format plantuml
<name>.sequence.uml
file.You can copy the file contents directly into other tools, or you can customize it first like. If you are going to edit the PlantUML file, be sure and save it as a new file first.
npx @appland/appmap@latest sequence-diagram appmap
Generate a sequence diagram for an AppMap
Positionals:
appmap [string] [required]
Options:
--version Show version number [boolean]
-v, --verbose Run with verbose logging [boolean]
--help Show help [boolean]
-d, --directory program working directory [string]
--output-dir directory in which to save the sequence diagrams
--format output format
[choices: "plantuml", "json"] [default: "plantuml"]
--exclude code objects to exclude from the diagram
npx @appland/appmap@latest sequence-diagram-diff base-diagram head-diagram
Diff sequence diagrams that are represented as JSON
Positionals:
base-diagram base diagram file or directory to compare [required]
head-diagram head diagram file or directory to compare [required]
Options:
--version Show version number [boolean]
-v, --verbose Run with verbose logging [boolean]
--help Show help [boolean]
-d, --directory program working directory [string]
--output-dir directory in which to save the sequence diagrams
[default: "."]
--format output format
[choices: "plantuml", "json"] [default: "plantuml"]