jjbuchan / docs

0 stars 0 forks source link

How to generate project module diagrams in IntelliJ to see dependencies #15

Open jjbuchan opened 3 years ago

jjbuchan commented 3 years ago

Across all of the libs and apps in a microservice architecture there is a dependency tree lurking. Some are more obvious dependencies (like model and common), but others are more subtle due to client API and DTOs.

With the bundle (all apps in one repo) workspace open in IntelliJ, it is possible to generate a diagram that shows the dependencies and arranges them in a convenient hierarchical view. The hierarchical view works well for driving merge/build order of the dependencies.

First, right-click on one of the module directories of interest and select "Diagrams > Show Diagram..."

image

Then, select "Project Modules":

image

Before going further, change the layout to "Hierarchic Group Layout" by right clicking anywhere in the whitespace area of the diagram and selecting that layout type from the "Layout" submenu:

image

With that layout, the deepest dependencies are in the top row, next deepest in the second row, and so on. When merging/building changes that span several modules, work through the merges/builds in row-order.

When the diagram is first generated, it will include the project-level dependencies of the initial module. You can always have the diagram compute more module dependencies by pressing the space key and starting to type the desired module name to add.

To share the diagram as a PNG, you can use the "Export to Image File" action in the toolbar:

image