PackageMap - a tool to build a map of your code

/img/packagemap-cover.png

PackageMap

I built https://packagemap.co to see how cohesive or coupled code was.

PackageMap is the next iteration of java-graphviz.

It builds on the same principles as java-graphviz. Namely that:

  1. Coupling is bad
  2. Cohesion is good
  3. The existing code review tools show you file content, but not how the files interact with each other.

https://upload.wikimedia.org/wikipedia/commons/0/09/CouplingVsCohesion.svg#center

Code review is hard

I do a bunch of code review, particularly in github. The code review UI is great, but I found that I was only reviewing the content of the files.

I was missing how those files fit together. I found it hard to see from a file-tree, in an IDE or in Github code review, how the types are used across an application.

As the applications I reviewed got larger, I wanted to check if the code was being packaged by domain — to be cohesive. I wanted to check that the code that is related to each other is in the same package, and that there were few cross-package imports.

To solve the problems I had with code review, and to see how code fits together, I built https://packagemap.co

Packagemap is made of two parts

  1. A java parser (hopefully other languages to come) that builds an AST of your code, to work out which classes are using which other classes. The parser runs on your machine, so the source files stay on your machine.
  2. The https://packagemap.co site. On the site you can filter and explore the “maps” (directed graphs of the code’s imports). You can filter and explore maps by prefix, like “com.example.package” or by wildcard “*.package.MyClass”

The tech

Server side

  1. Go
  2. SQLite database using LiteFS

Client side

  1. VueJS 3
  2. Bulma.io CSS framework

Deployment

  1. Fly.io