[[verification]]
= Verifying Application Module Structure
:page-section-summary-toc: 1

We can verify whether our code arrangement adheres to the intended constraints by calling the `….verify()` method on our `ApplicationModules` instance:

[tabs]
======
Java::
+
[source, java, role="primary"]
----
ApplicationModules.of(Application.class).verify();
----
Kotlin::
+
[source, kotlin, role="secondary"]
----
ApplicationModules.of(Application::class.java).verify()
----
======
The verification includes the following rules:

* _No cycles on the application module level_ -- the dependencies between modules have to form a directed acyclic graph.
* _Efferent module access via API packages only_ -- all references to types that reside in application module internal packages are rejected.
See xref:fundamentals.adoc#modules.advanced[Advanced Application Modules] for details.
Dependencies into internals of xref:fundamentals.adoc#modules.advanced.open[Open Application Modules] are allowed.
* _Explicitly allowed application module dependencies only_ (optional) -- an application module can optionally define allowed dependencies via  `@ApplicationModule(allowedDependencies = …)`.
If those are configured, dependencies to other application modules are rejected.
See xref:fundamentals.adoc#modules.explicit-dependencies[Explicit Application Module Dependencies] and xref:fundamentals.adoc#modules.named-interfaces[Named Interfaces] for details.

Spring Modulith optionally integrates with the jMolecules ArchUnit library and, if present, automatically triggers its Domain-Driven Design and architectural verification rules described https://github.com/xmolecules/jmolecules-integrations/tree/main/jmolecules-archunit[here].
