> For the complete documentation index, see [llms.txt](https://docs.konsist.lemonappdev.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.konsist.lemonappdev.com/samples/starter-test-snippets/architecture-test-snippets.md).

# Architecture Test Snippets

Snippets used to guard application architecture.

## 1. 4 Layer Architecture Has Correct Dependencies

```kotlin
@Test
fun `4 layer architecture has correct dependencies`() {
    Konsist
        .scopeFromProject()
        .assertArchitecture {
            val presentation = Layer("Presentation", "com.myapp.presentation..")
            val business = Layer("Business", "com.myapp.business..")
            val persistence = Layer("Persistence", "com.myapp.persistence..")
            val database = Layer("Database", "com.myapp.database..")

            presentation.dependsOn(business)
            business.dependsOn(persistence)
            persistence.dependsOn(database)
            database.dependsOnNothing()
        }
}
```

## 2. Every File In Module Resides In Module-specific Package

```kotlin
@Test
fun `every file in module resides in module-specific package`() {
    Konsist
        .scopeFromProject()
        .files
        .assertTrue { it.packagee?.name?.startsWith(it.moduleName) }
}
```

## 3. Files Reside In Package That Is Derived From Module Name

```kotlin
@Test
fun `files reside in package that is derived from module name`() {
    Konsist.scopeFromProduction()
        .files
        .assertTrue {
            /*
            module -> package name:
            feature_meal_planner -> mealplanner
            feature_caloric_calculator -> caloriccalculator
            */
            val featurePackageName = it
                .moduleName
                .removePrefix("feature_")
                .replace("_", "")

            it.hasPackage("com.myapp.$featurePackageName..")
        }
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.konsist.lemonappdev.com/samples/starter-test-snippets/architecture-test-snippets.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
