[tutorial] Taikai Introduction (based on ArchUnit)

Note: This page is an AI-generated (gpt-5-mini-2025-08-07) translation from Traditional Chinese and may contain minor inaccuracies.

📌 Introduction

Taikai is a Java architecture-checking tool based on ArchUnit. It provides pre-built rules to check code architecture, supports creating shared Rules Profile for reuse across multiple projects, and automatically verifies via unit tests whether code meets architectural requirements.

🚀 Introducing Taikai

Taikai is a Java code architecture-checking library that can be used to inspect dependencies and layering between packages and classes, check for cyclic dependencies, and more. Taikai is based on ArchUnit, provides rules commonly needed by popular frameworks, and offers Rules Profile so architecture rules can be reused. The Rules currently provided include:

  • Java Rules
  • Logging Rules
  • Test Rules
  • Spring Rules
  • Quarkus Rules

Implementation

There are two types of repositories in total:

  1. shared-architecture-rules that defines common rules (Rules Profile)
  2. A repo for developing services

Shared Architecture Rules

  • A simple Rule has been implemented and can be found in shared-architecture-rules-0.1.0-SNAPSHOT
  • It imposes simple restrictions, such as disallowing the use of Deprecated APIs and ensuring a Method’s params do not exceed 5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
package com.hsiangjenli;

import com.enofex.taikai.configures.Customizer;
import com.enofex.taikai.java.JavaConfigurer;

public final class ArchitectureRules {

static int MAX_METHOD_PARAMETERS = 5;

// Basic Java Rules
public static final Customizer<JavaConfigurer> BASE_JAVA_RULES =
java -> {
java.noUsageOfDeprecatedAPIs().methodsShouldNotExceedMaxParameters(MAX_METHOD_PARAMETERS);
};
}

Checking rules within the repo

Implementation details can be found at quarkus-demo-architecture-rules

Setting up pom.xml

Because the shared Architecture Rules are only on GitHub and not published to Maven, remember to use jitpack, and make sure the tag of shared-architecture-rules matches the one on GitHub

1
2
3
4
5
6
7
8
9
10
11
12
13
14
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>

<dependencies>
<dependency>
<groupId>com.github.hsiangjenli</groupId>
<artifactId>shared-architecture-rules</artifactId>
<version>0.1.0-SNAPSHOT</version>
</dependency>
</dependencies>

Example: code that violates the rules

1
2
3
4
5
6
7
// ManyParameters.java

package com.hsiangjenli;

public class ManyParameters {
public static void main(String a, String b, String c, String d, String e, String f) {}
}

Test the Architecture

1
2
3
4
5
6
7
8
9
10
11
12
13
14
// ArchitectureTest.java

package com.hsiangjenli;

import com.enofex.taikai.Taikai;
import org.junit.jupiter.api.Test;

public class ArchitectureTest {

@Test
void shouldValidateJavaRules() {
Taikai.builder().namespace("com.hsiangjenli").java(ArchitectureRules.BASE_JAVA_RULES).build().checkAll();
}
}
1
mvn test

You can see the test fails because the method in ManyParameters has parameters exceeding the maximum value 5 set in ArchitectureRules.BASE_JAVA_RULES.

image

🔁 Key takeaways

  • Taikai is a Java architecture-checking tool based on ArchUnit, providing pre-built rules for frameworks like Java, Spring, and Quarkus
  • Supports reusable Rules Profile so a shared rule set can be created and used across multiple projects
  • Runs checks via unit tests; when rules are violated the tests fail, ensuring code conforms to architectural requirements

🔗 References

  • DeepWiki

[tutorial] Taikai Introduction (based on ArchUnit)

https://hsiangjenli.github.io/blog/tutorial-taikai-based-on-archunit.en/

Author

Hsiang-Jen Li & DeepWiki

Posted on

2026-03-18

Updated on

2026-03-18

Licensed under