Visualize the architecture of your Java app in IntelliJ IDEA, in 2 ¹/₂ minutes

AppMap is an open source IntelliJ IDEA plugin which helps you improve your code by showing you how it behaves, feature by feature, as you work. It does this by automatically generating interactive maps of architecture and code behavior right in your ed…


This content originally appeared on DEV Community and was authored by Kevin Gilpin

AppMap is an open source IntelliJ IDEA plugin which helps you improve your code by showing you how it behaves, feature by feature, as you work. It does this by automatically generating interactive maps of architecture and code behavior right in your editor.

This 2 ¹/₂ minute video shows how to install the AppMap plugin, how to configure it to map your Java code, and how to navigate your code using the interactive diagrams.

It uses the Spring Pet Clinic as an example program.

Here are the step-by-step instructions that are demonstrated in the video, or you can follow the Quickstart for IntelliJ written instructions.

How it works

How AppMap works

AppMap works by recording code execution paths of your app and visualizing them in interactive diagrams directly in your code editor. A good way to create AppMaps is by recording unit, functional or integration test cases. The Pet Clinic project uses JUnit tests, which will be a source of AppMaps in this demo.

Install the AppMap plugin

00:12 Installing AppMap from the JetBrains Marketplace takes only a moment: 

  • Open the IntelliJ IDEA preferences
  • Select Plugins, click on the Marketplace tab and search for AppMap
  • Click on the Install button, then click on Restart IDE.

AppMap in Marketplace

When the IDE restarts, the AppMap plugin is installed and ready for viewing AppMaps.

Configure AppMap for the Pet Clinic recording

The AppMap framework uses a file called appmap.yml to determine which code to map. 

00:20 Create a new file appmap.yml in the root folder of your project. You should add all the Java packages of your project. Here is an example for the Pet Clinic application that is used in this demo:

name: PetClinic
packages:
  - path: org.springframework.samples.petclinic

Add Java recording agent to Maven configuration

To get a recording, run the tests with an AppMap maven plugin that sets up the JVM for AppMap recording. The popular jacoco code coverage tool uses a similar approach in Maven projects.

00:54 Add the AppMap plugin to the build/plugins section of the POM:

      <!-- AppMap agent, default parameters -->
      <plugin>
        <groupId>com.appland</groupId>
        <artifactId>appmap-maven-plugin</artifactId>
        <executions>
          <execution>
            <phase>process-test-classes</phase>
            <goals>
              <goal>prepare-agent</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

Record AppMaps from tests

01:10 When you run the Maven test phase, the AppMap recording agent will record AppMaps from the tests and save them in the $buildDir/appmap folder of the project, one AppMap per each recorded test case.

$ mvnw test

Open a generated AppMap in IntelliJ IDEA

01:17 Open the AppMaps view - click on the AppMaps tab in the UI. Or, press CTRL or COMMAND + SHIFT + A, then type "AppMaps" in the search box and pick the `AppMaps View" from the list.

Select an AppMap from the list of all AppMaps found in the project folders, or search for an AppMap with a specific phrase in its name, for example "create owner".

Double click on an AppMap in the list, an interactive diagram viewer opens.

AppMap Dependency Map

Interact with the AppMap diagram

01:25 Discover how the Pet Clinic application works in the AppMap diagrams. 

  • Start with the big picture of your software design and view all code components in the Dependency Map - Web Service endpoints, Java packages/classes/functions and SQL commands and their inter-dependencies
  • Navigate to sources of classes and functions directly from the diagrams so you don't have to look for them manually
  • Drill down the execution details of code and SQL in the execution Trace.

Dependency Map

01:45 Or, you can use a bottom-up approach. Let's say you want to know what code modifies data in the database. 

  • Start with a SQL command of interest - like an INSERT
  • View how it's connected to other calls in the Trace, then backtrack to its calling component and open its source file 
  • See how it is connected to other code and Web Service endpoints.

AppMap screenshot in IntelliJ

Learn more about AppMap

This is only a small demonstration of the AppMap capabilities. For more information, step-by-step instructions and practical how-tos, check out the AppMap documentation.

Acknowledgements

Thanks to Petr and Dan for all their hard work on this video!


This content originally appeared on DEV Community and was authored by Kevin Gilpin


Print Share Comment Cite Upload Translate Updates
APA

Kevin Gilpin | Sciencx (2021-05-13T12:50:56+00:00) Visualize the architecture of your Java app in IntelliJ IDEA, in 2 ¹/₂ minutes. Retrieved from https://www.scien.cx/2021/05/13/visualize-the-architecture-of-your-java-app-in-intellij-idea-in-2-%c2%b9-%e2%82%82-minutes/

MLA
" » Visualize the architecture of your Java app in IntelliJ IDEA, in 2 ¹/₂ minutes." Kevin Gilpin | Sciencx - Thursday May 13, 2021, https://www.scien.cx/2021/05/13/visualize-the-architecture-of-your-java-app-in-intellij-idea-in-2-%c2%b9-%e2%82%82-minutes/
HARVARD
Kevin Gilpin | Sciencx Thursday May 13, 2021 » Visualize the architecture of your Java app in IntelliJ IDEA, in 2 ¹/₂ minutes., viewed ,<https://www.scien.cx/2021/05/13/visualize-the-architecture-of-your-java-app-in-intellij-idea-in-2-%c2%b9-%e2%82%82-minutes/>
VANCOUVER
Kevin Gilpin | Sciencx - » Visualize the architecture of your Java app in IntelliJ IDEA, in 2 ¹/₂ minutes. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/05/13/visualize-the-architecture-of-your-java-app-in-intellij-idea-in-2-%c2%b9-%e2%82%82-minutes/
CHICAGO
" » Visualize the architecture of your Java app in IntelliJ IDEA, in 2 ¹/₂ minutes." Kevin Gilpin | Sciencx - Accessed . https://www.scien.cx/2021/05/13/visualize-the-architecture-of-your-java-app-in-intellij-idea-in-2-%c2%b9-%e2%82%82-minutes/
IEEE
" » Visualize the architecture of your Java app in IntelliJ IDEA, in 2 ¹/₂ minutes." Kevin Gilpin | Sciencx [Online]. Available: https://www.scien.cx/2021/05/13/visualize-the-architecture-of-your-java-app-in-intellij-idea-in-2-%c2%b9-%e2%82%82-minutes/. [Accessed: ]
rf:citation
» Visualize the architecture of your Java app in IntelliJ IDEA, in 2 ¹/₂ minutes | Kevin Gilpin | Sciencx | https://www.scien.cx/2021/05/13/visualize-the-architecture-of-your-java-app-in-intellij-idea-in-2-%c2%b9-%e2%82%82-minutes/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.