liveBook · Manning

Architecture kernel

As explained in Clean Applications with Hexagonal Architecture

The Architecture Kernel is a book-specific framework-independent component that provides technology-agnostic annotations for expressing architectural intent.

A handler that imports a framework’s transaction annotation makes the application core depend on that framework. The Architecture Kernel avoids that coupling: it is a small, framework-independent module of architectural types shared across domain, application, and adapter boundaries. section 4.1.1 section 4.4.3

The kernel is an architectural microframework, not a DDD Shared Kernel. It contains neutral building blocks, not shared domain concepts, business rules, or ubiquitous language. Its types include stereotypes such as @UseCase, Command and Query markers, and command and query bus contracts. section 4.1.1

Listing 4.11 Handler with technology-agnostic transactional boundary
@ApplicationService
@RequiredArgsConstructor
@Transactional #A
final class PublishArticleHandler implements PublishArticleUseCase {
 
  private final ArticleRepository articleRepository;
 
  @Override
  public Either<Error, Void> handle(final PublishArticleCommand command) {
    return this.articleRepository.readById(command.articleId())
      .flatMap(article -> article.publish(command.authorId()))
      .flatMap(article -> this.articleRepository.save(article));
  }
 
}

The handler declares transactional intent with the kernel’s technology-agnostic annotation while orchestrating the use case through a repository abstraction. section 4.4.3

Place the transaction boundary on the handler, not on a repository or input adapter: the handler coordinates the full use case as one unit of work. At runtime, a custom transaction interceptor implements the kernel’s @Transactional intent and rolls back by returned value rather than by exception. section 6.3.4 section 6.6

Listing 4.13 CommandBus from the Architecture Kernel
public interface CommandBus {
  <E, C extends Command> Either<E, Void> 
    execute(final C command); #A
}

The CommandBus contract gives adapters one entry point for executing commands. A use case can extend CommandHandler to participate in bus routing while remaining available through direct injection. section 4.5.2

How Clean Applications with Hexagonal Architecture covers it

How deep it goes
Defines kernel contracts and annotations, shows their use in handlers and buses, and identifies the runtime transaction bridge.
Examples
Uses an article-publishing use case and handler to demonstrate stereotypes, command routing, and transactional intent.
What you can do after
Evaluate handler dependencies and transaction placement to preserve a framework-independent application core.
How it connects
Connects hexagonal architecture with input ports, command buses, transaction boundaries, and domain-driven design.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Clean Applications with Hexagonal Architecture. The section links point to the parts of the book it draws on.