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
  • Show numbers of referrer

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
  • Filter by package name etc.

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
  • Highlight nodes and edges responsive to user interaction

Metho invocation diagram

Getting Started

Settings

project/plugins.sbt

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

project/zugen.properties

domainPackages=domain                       # Package name which represent domain
domainObjectExcludePatterns=".+Repository"  # Regex patterns to exclude classes from domain relation diagram
methodInvocationRootPackage=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
empty documentsToGenerate=domain-object-table,domain-relation-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.

addCompilerPlugin("org.scalameta" %% "semanticdb-scalac" % "4.3.17" 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).

Thanks

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