hexagonal-architecture

Structure applications around ports and adapters to decouple business logic.

Updated Sep 13, 2025
One-click install
npx skills add https://github.com/llmh333/employee_management_spring --skill hexagonal-architecture-llmh333
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: hexagonal-architecture
Source: https://github.com/llmh333/employee_management_spring/tree/main/.gemini/skills/hexagonal-architecture
Command: npx skills add https://github.com/llmh333/employee_management_spring --skill hexagonal-architecture-llmh333

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Hexagonal architecture prevents business rules from becoming tightly coupled to frameworks, transport layers, and persistence technology, which makes systems harder to test, evolve, and scale.

Core Features & Use Cases

  • Ports & Adapters separation: model what the application needs (outbound ports) and what it offers (inbound ports) while keeping domain logic independent of I/O.
  • Testable use-case orchestration: implement use cases as pure orchestrators that depend on interfaces and return plain data.
  • Edge-focused adapters: place protocol mapping (HTTP/CLI/queues) and infrastructure integration (DB/SDKs) at the system boundaries.

Use case: Refactor a feature where controller/service code is mixing request handling, database access, and business logic—then migrate slice-by-slice without a big-bang rewrite.

Quick Start

Ask the AI to refactor your feature into inbound/outbound ports plus a dedicated use-case boundary, then describe the adapter wiring at a single composition root.

Frequently Asked Questions about hexagonal-architecture

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I decouple business logic from framework and database coupling in my application?

Hexagonal architecture decouples business logic by structuring applications around ports and adapters, keeping core domain rules independent of transport and persistence layers. This separation allows use-case orchestration to remain pure and testable.

What is the best way to refactor a controller that mixes request handling, database access, and business logic?

Refactoring mixed controller code involves splitting it into inbound and outbound ports with a dedicated use-case boundary. You can migrate slice-by-slice without a big-bang rewrite by moving protocol mapping to edge adapters.

How do you test use cases when using ports and adapters for domain boundaries?

Testing use cases with ports and adapters involves using fakes for unit tests to isolate business logic, while real adapters handle integration and E2E validation. This strategy ensures use-case orchestrators are tested independently of infrastructure.

Can I use hexagonal architecture to support multiple interfaces like HTTP endpoints and worker jobs?

Hexagonal architecture supports multiple interfaces by placing protocol mapping for HTTP, CLI, or queues at the system boundaries as edge adapters. Inbound ports define what the application offers, allowing various transport layers to connect seamlessly.

When should I not use hexagonal architecture for structuring my application?

Hexagonal architecture may be excessive for simple systems that do not require high testability or multiple transport interfaces. The overhead of defining explicit inbound and outbound port contracts is best suited for scalable, complex use-case boundaries.

Do I need a composition root to wire adapters in a ports and adapters architecture?

A composition root is required to explicitly wire edge adapters for protocol and infrastructure mapping to the application ports. This central wiring ensures domain logic remains independent of how dependencies are injected at runtime.