todokr / zugen

An architecture diagram generator for Scala project.

Version Matrix

Zugen

Build Status Maven Central

日本語版

An architecture diagram generator for Scala project.

Documents to be generated

These following screenshots are generated in the example Scala project.

Domain object table

A table of domain objects under the specified packages.
This is useful as a glossary of domain terms.

  • List package, class/trait name, scaladoc and file path
  • Jump to GitHub source

Domain object table

Domain relation diagram

A diagram which indicates relation among domain objects.

  • Show class/trait name with its alias in scaladoc
  • Show inheritance relations
  • Show properties
  • Highlight references which is bound to outside of domain package in red
  • Show argument names of constructors as labels on edges
  • Jump to GitHub source

Domain relation diagram

Method Invocation Diagram

A diagram which shows method invocation chain.

  • Show project-internal method invocations
  • Show invocations of external libraries
  • Jump to GitHub source

Method invocation diagram

Getting Started

Settings

project/plugins.sbt

addSbtPlugin("io.github.todokr" % "sbt-zugen" % "2020.11.1")

project/zugen.properties

domainPackages=example.domain                   # Package name which represent domain
domainObjectExcludePatterns=".+Repository"      # Regex patterns to exclude classes from domain relation diagram
methodInvocationRootPackage=example.controllers # The root package of method invocation diagram
keys
key description available values default example
documentsToGenerate Document types to generate.
If empty, generates all kind of documents.
domain-object-table
domain-relation-diagram
method-invocation-diagram
empty documentsToGenerate=domain-object-table,domain-relation-diagram,method-invocation-diagram
domainPackages Package names which represent domain. comma separated string empty domainPackages=app1.domain,app2.domain
domainObjectExcludePatterns Regex patterns to exclude classes from domain relation diagram. comma separated string empty domainObjectExcludePatterns=".+Repository"
methodInvocationRootPackage The root package of method invocation diagram string empty methodInvocationRootPackage=controller
documentPath Directory to output documents string target/zugen-docs documentPath=docs
githubBaseUrl The base URL of source code in GitHub repository string empty githubBaseUrl=https://github.com/todokr/zugen/blob/trunk/src/sbt-test/sbt-zugen/application/

build.sbt

Zugen loads source code information from SemanticDB. There are 2 ways to enable SemanticDB file generation.

Using sbt option

From 1.13, sbt supports SemanticDB generation.

ThisBuild / semanticdbEnabled := true
ThisBuild / semanticdbVersion := "4.4.27"
scalacOptions ++= Seq("-Yrangepos", "-P:semanticdb:text:on")
Using compiler plugin
addCompilerPlugin("org.scalameta" %% "semanticdb-scalac" % "4.4.27" cross CrossVersion.full)
scalacOptions ++= Seq("-Yrangepos", "-P:semanticdb:text:on")

Run

$ sbt zugen

Then, zugen diagrams are generated under the directory specified with documentPath setting (default is target/zugen-docs).

If any question you have, please feel free to contact me on Twitter.

Thanks

Zugen is inspired by JIG, which is a document generator for Java project and its philosophy.