BoundedContext

annotation class BoundedContext(val name: String, val alias: String = "", val description: String = "", val scopes: Array<String> = [], val packageScopes: Array<KClass<*>> = [], val aggregates: Array<BoundedContext.Aggregate> = [])

Defines a bounded context in domain-driven design (DDD).

A bounded context represents a coherent area of the business domain with clear boundaries, containing its own ubiquitous language, domain model, and business rules. It defines the scope where particular terms and rules apply.

This annotation helps organize the codebase by grouping related aggregates and establishing clear boundaries between different business domains.

Example usage:

@BoundedContext(
name = "ecommerce",
alias = "shop",
description = "Handles online retail operations",
aggregates = [
BoundedContext.Aggregate(
name = "order",
tenantId = "tenant-1"
),
BoundedContext.Aggregate(
name = "product",
tenantId = "tenant-1"
)
]
)

Parameters

name

The unique name of the bounded context. Used for identification and configuration.

alias

An optional alias for the bounded context, useful for shorter references.

description

A human-readable description of the bounded context's purpose and scope.

scopes

Array of scope identifiers that define the context's boundaries.

packageScopes

Array of package classes that define which packages belong to this context.

aggregates

Array of aggregate definitions within this bounded context.

See also

for defining aggregates within a bounded context

Types

Link copied to clipboard
annotation class Aggregate(val name: String, val tenantId: String = "", val id: String = "", val scopes: Array<String> = [], val packageScopes: Array<KClass<*>> = [])

Defines an aggregate within a bounded context.

Properties

Link copied to clipboard

Aggregate definitions within this bounded context.

Link copied to clipboard

Optional alias for shorter references to this bounded context.

Link copied to clipboard

Human-readable description of the bounded context's purpose.

Link copied to clipboard

The unique name of the bounded context.

Link copied to clipboard

Package classes that belong to this bounded context.

Link copied to clipboard

Scope identifiers defining the context's boundaries.