Architecture testing for Rust

ArchUnitRust

Write architecture policies as regular Rust tests. ArchUnitRust discovers the containing Cargo project, analyzes production targets, and provides file, layer, slice, metric, diagram, and graph APIs with explicit failure boundaries.

Git previewRust 1.85+MIT

Cargo

cargo add --dev --git https://github.com/LukasNiessen/ArchUnitRust archunit
tests/architecture.rs
use archunit::{assert_passes, project_files};

#[test]
fn api_does_not_reach_database() {
    let rule = project_files()
        .in_path("src/api/**")
        .should_not()
        .depend_on_files()
        .in_path("src/database/**");

    assert_passes!(rule);
}

Capabilities

What ArchUnitRust brings to the test suite.

The family shares a recognizable architecture vocabulary while each implementation stays honest about its language, toolchain, and maturity.

01

Cargo workspace discovery

02

File, layer, and captured-slice policies

03

Rust-native metrics and graph reports

04

PlantUML conformance and export

05

Structured violations and Checkable rules

06

Compiled README examples and doctests

Current maturity

Git preview

Usable directly from Git and under active development. It is not yet published on crates.io.

LanguageRust
Release0.0.1 from Git
RuntimeRust 1.85+
LicenseMIT

Where it fits

Put boundaries next to the code they protect.

Common starting points for ArchUnitRust include the following project shapes.

Cargo workspacesCLI toolsRust servicesSystems projects

Make the first boundary executable.

Add one meaningful rule, run it with the existing tests, and grow the architecture suite as the system reveals where it needs protection.

Start with ArchUnitRust ↗