Skip to content

Latest commit

Β 

History

252 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Konture Logo

🧬 Konture: Kotlin Architecture Testing Guardrails

GitHub Pages Gradle Plugin Portal Maven Central Kotlin Gradle Code Coverage Build Status

Konture is a stack- and build-tool agnostic Kotlin architecture testing library for Android, Kotlin Multiplatform (KMP), and JVM backend projects. It combines real project structure (captured directly from your project's build graph) with AST-based static analysis and a premium, architecture-agnostic Fluent Lambda DSL to enforce boundaries on any test framework.


πŸ›‘οΈ The problem

In multi-module, multi-layer projects, architecture erodes through small shortcuts. For example, a feature module might declare a "sideways" dependency on a sibling feature.

Prohibited sideways dependency between feature modules

Konture helps developers analyze project structure and enforce architectural rules and boundaries directly inside the test suite.


πŸ”‘ Key Capabilities

  • πŸ“¦ Platform & Stack Agnostic: Works seamlessly across Android, Kotlin Multiplatform (KMP), and Kotlin backend projects (Spring Boot, Ktor, etc.).
  • πŸ“ Architecture Agnostic: Set constraints for any design pattern (Clean, Layered, MVVM, Hexagonal, DDD) without layout restrictions.
  • πŸ› οΈ Build Tool Agnostic: Engineered to support multiple build systems, with deep, native support for Gradle and Maven environments.
  • πŸ§ͺ Test Framework Agnostic: Runs as a pure JVM library, compatible with JUnit 4, JUnit 5, JUnit 6, Kotest, TestBalloon, or any other runner.
  • ✍️ Fluent Lambda DSL: Write expressive, readable assertions for module dependencies, package isolation, interface adherence, and naming conventions.
  • πŸ€– AI-Agent Friendly: Includes dedicated prompts and custom skills for autonomous integration and code generation:

πŸš€ Getting Started

Tip

πŸ€– Automated Setup: Save time by using our πŸ€– integrate-konture prompt/skill to let an AI assistant automatically configure your Gradle project and generate tests. See the AI Prompts Catalog for details.

Installation

Gradle

  1. Apply the plugin in your root settings.gradle.kts:
plugins {
    id("io.github.baole.konture") version "1.0.1"
}
  1. Add the dependency in your test module's build.gradle.kts (e.g. konture-test/build.gradle.kts):
plugins {
    kotlin("jvm")
}

dependencies {
    testImplementation("io.github.baole:konture:1.0.1")
}

Important

We recommend running your architectural guards in a dedicated test module, such as :konture-test (see our sample module).

Note

For alternative Gradle plugin setup formats, refer to the Gradle Plugin Portal.

Maven

  1. Add the Konture Maven Plugin to your dedicated test module's pom.xml (e.g., konture-test/pom.xml):
<plugin>
    <groupId>io.github.baole.konture</groupId>
    <artifactId>konture-maven-plugin</artifactId>
    <version>1.0.1</version>
    <executions>
        <execution>
            <phase>process-test-resources</phase>
            <goals>
                <goal>generate-layout</goal>
            </goals>
        </execution>
    </executions>
</plugin>
  1. Add the dependency to the same module's pom.xml:
<dependency>
    <groupId>io.github.baole</groupId>
    <artifactId>konture</artifactId>
    <version>1.0.1</version>
    <scope>test</scope>
</dependency>

Write Your First Guardrail

Create a unit test to enforce architectural boundaries and conventions. Since Konture is completely architecture-agnostic, you can configure guardrails that match your codebase's custom patterns:

import io.github.baole.konture.architecture
import org.junit.jupiter.api.Test

class ArchitectureGuardrails {

    @Test
    fun `domain layer should be completely isolated from data and UI layers`() {
        architecture {
            // 🎯 Select modules via wildcard pattern matching
            modules {
                that().haveNameMatching(":core:domain**")
                should().mustNotDependOn(":core:data**")
                andShould().mustNotDependOn(":feature:**")
            }
        }
    }

    @Test
    fun `repositories inside domain must be declared as interfaces`() {
        architecture {
            // 🎯 Select classes inside domain package
            classes {
                that().inPackage("..domain..")
                that().nameEndsWith("Repository")
                should().beInterfaces()
            }
        }
    }
}

πŸ“– Documentation

Visit our official GitHub Pages Documentation Site or explore the resources directly:

🀝 Contributing

We welcome all contributions! Please check our Contribution Guidelines (or the online Contributing Guide) for local setup, build commands, and PR workflows.

Thanks to all our amazing contributors!

Profile images of all the contributors

πŸ“„ License

This project is licensed under the Apache License, Version 2.0.

About

Define, enforce, and automate architecture rules run as fast, lightweight Kotlin unit tests. Fully supports Kotlin Multiplatform (KMP), Android, and Server-Side (Ktor, Spring).

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

36 stars

Watchers

1 watching

Forks

Releases

Used by

Contributors

Languages