Over the last few days I played with tool-based architecture validation, to give colleagues a basic introduction to the whole topic.

I tested ArchUnit and jqAssistant and skipped anything, that isn’t fit to be included into a build pipeline.

Just for completeness: There are other well-known tools like Structure101 or Sotograph commercially available, for deeper analysis of a given architecture.


This framework comes with a really nice fluent API, which allows you to easily create your own testcases and after a bit of initial try/error, it is pretty clear how to roll.

For example, this rule checks, if methods in the package named test are public:

static final ArchRule checkPlacement =

Overall, this API is quite powerful and there quite a few plugins to enhance the impressive set. So in other words, it is always a good idea to check, if someone already solved the problem for you.

So besides simple stuff like the above, architects are probably more interested in rules, that enforce a given layout or rather architecture.

One of the better known architecture - the layered architecture - can be checked nicely:

private final JavaClasses classes = new ClassFileImporter().importPackages("org.subforge");

public void testLayeredArch() {

            .mayOnlyBeAccessedByLayers("Application", "Service", "Repository")

These rules define different layers and specify the allowed interaction between each other.


In comparison to ArchUnit, this framework uses a different approach and can be broken down into three step/components:


The combination of both scans the given source tree, analyzed the types, relations and so on and stores all learnings into the graph database.

Graph database (Neo4j)

Once data is in the database, it can be queried e.g. via fancy frontends like Neo4j browser.

Query/Constraint checker

And lastly, the selected query language (Cypher is the default here) can be used to describe either queries to get infos, to formalize concepts or constraints.

Concepts are kind of light rules, that can be violated without problem and can be cross referenced in other concepts or constraints, which always have a severity.


I don’t want to dive depper into the syntax of Cypher, but a base examples looks like this:

    t, t2

This asks the database for any type named t, that depends on another type named t2.