hexagonal-architecture
Master the Ports & Adapters pattern to isolate business logic from frameworks and infrastructure. This skill covers domain modeling, use-case orchestration, inbound and outbound port design, adapter implementation, and composition wiring across multiple languages.
Hexagonal Architecture teaches you to structure applications with clear domain boundaries, dependency inversion, and testable use cases.
AI-generated summary based on this skill's SKILL.md
Decision gist · record as of 2026-07-27
Hexagonal Architecture teaches you to structure applications with clear domain boundaries, dependency inversion, and testable use cases. Master the Ports & Adapters pattern to isolate business logic from frameworks and infrastructure. This skill covers domain modeling, use-case orchestration, inbound and outbound port design, adapter implementation, and composition wiring across multiple languages.
Use it when
- In hexagonal-architecture.
- Hexagonal-architecture enables decoupling by extracting business logic into a framework-independent core.
Verify before relying
Read SKILL.md below before installing (1 file). Open directory: indexed for reading, not audited.
Install
affaan-m/ECC/hexagonal-architecture · repository language: JavaScript
Open directory. Skills are indexed for reading, not audited. Review a skill's body before installing it.
Frequently asked questions
AI-generated answers based on this skill's SKILL.md and metadata
How do you implement hexagonal architecture with ports and adapters?
Hexagonal-architecture structures applications by isolating business logic at the core, surrounded by ports (interfaces defining contracts) and adapters (implementations connecting to external systems). Start by identifying your domain use cases, define inbound ports for incoming requests and outbound ports for external dependencies, then implement adapters that translate between your domain and frameworks like HTTP, databases, or message queues. This separation ensures your core logic remains testable and framework-agnostic.
What is the difference between inbound and outbound ports in hexagonal architecture?
In hexagonal-architecture, inbound ports expose your application's use cases to the outside world—they define how external actors trigger business logic. Outbound ports define contracts for external resources your domain needs, like databases or APIs. Inbound adapters (controllers, CLI handlers) call inbound ports; outbound adapters (repositories, HTTP clients) implement outbound ports. This bidirectional structure keeps dependencies pointing inward toward your domain.
How can you refactor existing services to decouple business logic from framework dependencies?
Hexagonal-architecture enables decoupling by extracting business logic into a framework-independent core. Identify tightly-coupled code, move it into use-case classes that depend only on domain objects and port interfaces, then create adapters wrapping your existing framework calls. Use dependency injection at a composition root to wire ports to adapters. This approach works across TypeScript, Java, Kotlin, and Go, allowing gradual migration without rewriting everything at once.
Why is hexagonal architecture beneficial for testing?
Hexagonal-architecture improves testability by isolating business logic from external dependencies. Since your use cases depend only on port interfaces, you can inject mock adapters during tests without touching real databases, APIs, or frameworks. Test boundaries align with clear domain separation, letting you verify use-case logic in isolation. This design eliminates the need for complex test infrastructure and makes tests faster, more reliable, and easier to maintain.
How do you apply hexagonal architecture patterns across TypeScript, Java, Kotlin, and Go?
Hexagonal-architecture principles remain consistent across languages, though implementation details vary. In TypeScript, use interfaces and dependency injection frameworks; in Java/Kotlin, leverage annotations and Spring; in Go, use interfaces and struct composition. The core pattern—domain core, inbound/outbound ports, adapters—translates directly. Language-specific tooling differs, but the architectural intent of isolating business logic and managing dependencies through ports stays the same.
What role does the composition root play in hexagonal architecture?
The composition root in hexagonal-architecture is where you wire all dependencies together—instantiating adapters, injecting them into ports, and configuring the application for startup. It's the single place where your framework and infrastructure concerns live, keeping them out of your domain core. By centralizing composition, you maintain clean separation of concerns and make it easy to swap adapters or change configurations without touching business logic.
SKILL.md
Rendered from the published skill. Quoted content, verbatim.
Hexagonal Architecture
Hexagonal architecture (Ports and Adapters) keeps business logic independent from frameworks, transport, and persistence details. The core app depends on abstract ports, and adapters implement those ports at the edges.
When to Use
- Building new features where long-term maintainability and testability matter.
- Refactoring layered or framework-heavy code where domain logic is mixed with I/O concerns.
- Supporting multiple interfaces for the same use case (HTTP, CLI, queue workers, cron jobs).
- Replacing infrastructure (database, external APIs, message bus) without rewriting business rules.
Use this skill when the request involves boundaries, domain-centric design, refactoring tightly coupled services, or decoupling application logic from specific libraries.
Core Concepts
- Domain model: Business rules and entities/value objects. No framework imports.
- **Use cases
(truncated - see the full file via the links below)
File tree — 1 file
skills/hexagonal-architecture/SKILL.md
Let your AI agent find skills like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 56,283 agent skills by what they can do, searchable in plain language.
wish › “Learn how to structure and implement hexagonal architecture with ports and adapters”
Give your agent the search over MCP, or paste the wish link into any chat. No install? Search from any chat →
Related skills
Guides you through selecting the right architecture pattern—clean, hexagonal, feature-based, or vertical slice—based on team size and domain complexity. Covers folder structure, dependency inversion, module boundaries, and SOLID principles at application scale. Diagnoses architectural problems like fat controllers and circular dependencies.
This skill guides you through building Spring Boot applications with clean architecture principles, ensuring domain logic stays independent of frameworks and infrastructure. Learn to structure layered packages, implement ports and adapters, apply domain-driven design tactical patterns, and maintain strict dependency rules that keep your codebase testable and maintainable.
Master three foundational backend architecture approaches—Clean Architecture, Hexagonal Architecture, and Domain-Driven Design—to structure systems for testability, maintainability, and scalability. Each pattern teaches dependency management, separation of concerns, and technology-agnostic core logic through practical examples and directory structures.
Learn to organize Android and KMP projects using Clean Architecture principles, including module boundaries, dependency inversion, and layered data flow. Covers UseCase and Repository patterns, database integration with Room and SQLDelight, network clients with Ktor, and dependency injection setup with Koin or Hilt.
Master three foundational backend architecture approaches: Clean Architecture's layered dependency flow, Hexagonal Architecture's port-and-adapter model for technology independence, and Domain-Driven Design's strategic and tactical patterns for complex domains. Use this skill when designing new systems, refactoring monoliths, or establishing architecture standards for your team.
Master Swift 6.2's concurrency paradigm where code executes on a single thread by default and background work requires explicit opt-in via @concurrent. This skill teaches you how async functions now remain on their calling actor, eliminating the implicit offloading that caused data-race errors in earlier versions. Learn to use isolated conformances for MainActor types, protect global state, and migrate existing projects incrementally while leveraging the compiler's safety guarantees.