#hexagonal.md
Version: 1.0.0
Target Models
- Claude Fable 5.1
- Claude Opus 5
- Claude Sonnet 5
- Claude 5 Family
- Future Claude Models
#Purpose
This document defines engineering principles, port-and-adapter methodologies, dependency isolation strategies, boundary design practices, and long-term engineering approaches for building software systems whose business logic remains completely independent from external technologies, infrastructure, frameworks, user interfaces, and integration mechanisms.
It applies to
- SaaS Platforms
- AI Applications
- APIs
- Enterprise Software
- Cloud Native Applications
- Microservices
- Monoliths
- Event-Driven Systems
- Long-Lived Software Systems
Hexagonal Architecture is not arranging code into folders.
Hexagonal Architecture is the engineering discipline of isolating business capabilities behind stable ports while allowing every external dependency to interact through replaceable adapters, ensuring that business logic remains independent, testable, maintainable, and continuously evolvable.
Hexagonal Architecture answers one question:
How should software isolate business logic so external technologies can evolve independently without affecting core business capabilities?
#Core Philosophy
Understand the Business
↓
Model Business Capabilities
↓
Define Stable Ports
↓
Separate External Systems
↓
Connect Through Adapters
↓
Protect Business Logic
↓
Enable Independent Evolution
↓
Continuously Improve
Business logic should remain unaware of the outside world.
#Primary Objective
Every Hexagonal Architecture should maximize
Business Independence
Maintainability
Replaceability
Testability
Scalability
Reliability
Engineering Excellence
Long-Term Sustainability
The objective is isolating business capabilities from implementation technologies.
#Engineering Principles
Always prioritize
Business Capabilities
↓
Stable Ports
↓
Independent Adapters
↓
Dependency Inversion
↓
Low Coupling
↓
High Cohesion
↓
Replaceable Infrastructure
↓
Continuous Improvement
External technologies should adapt to business logic.
Business logic should never adapt to infrastructure.
#Hexagonal Architecture Lifecycle
Understand Business
↓
Model Domain
↓
Define Ports
↓
Design Adapters
↓
Isolate Infrastructure
↓
Validate Dependencies
↓
Protect Core Logic
↓
Continuously Improve
Every architectural decision should strengthen the independence of the business core.
#Stage 1 — Business Understanding
Identify
Business Objectives
↓
Customer Problems
↓
Core Capabilities
↓
Business Constraints
↓
Operational Requirements
↓
Critical Workflows
↓
Success Metrics
↓
Future Growth
Business capabilities determine architecture—not frameworks.
Architecture should always begin with business understanding.
#Stage 2 — Domain Modeling
Model
Business Entities
↓
Business Rules
↓
Use Cases
↓
Business Policies
↓
Relationships
↓
Responsibilities
↓
Business Boundaries
↓
Future Evolution
The domain model should represent business knowledge rather than technical implementation.
The business core must remain technology-independent.
#Stage 3 — Core Application Design
Design
Business Services
↓
Use Cases
↓
Domain Logic
↓
Business Policies
↓
Validation Rules
↓
Decision Logic
↓
Workflow Coordination
↓
Long-Term Stability
The application core contains the organization's most valuable software knowledge.
Everything else exists to support it.
#Stage 4 — Port Design
Define
Input Ports
↓
Output Ports
↓
Business Contracts
↓
Application Contracts
↓
Integration Contracts
↓
Communication Rules
↓
Stable Abstractions
↓
Future Flexibility
Ports define how the business communicates—not how technology works.
Stable ports protect long-term maintainability.
#Stage 5 — Adapter Design
Design
REST Adapters
↓
CLI Adapters
↓
Messaging Adapters
↓
Database Adapters
↓
Cloud Adapters
↓
Authentication Adapters
↓
External Service Adapters
↓
Future Integrations
Adapters translate between external technologies and business language.
Adapters should contain translation—not business logic.
#Stage 6 — Dependency Management
Organize
Dependency Direction
↓
Stable Interfaces
↓
Independent Components
↓
Implementation Isolation
↓
Replaceable Infrastructure
↓
Loose Coupling
↓
Clear Responsibilities
↓
Maintainability
Dependencies should always point toward the business core.
The core should never depend upon adapters.
#Stage 7 — Communication Design
Define
Requests
↓
Commands
↓
Queries
↓
Events
↓
Responses
↓
Validation
↓
Failure Handling
↓
Recovery
Communication should occur through ports rather than implementation details.
Every interaction should preserve business independence.
#Stage 8 — Infrastructure Isolation
Separate
Frameworks
↓
Databases
↓
Cloud Providers
↓
Messaging Systems
↓
Authentication
↓
Storage
↓
Networking
↓
Deployment Platforms
Infrastructure should remain completely replaceable.
Technology should never become part of the business model.
#Stage 9 — Adapter Validation
Verify
Business Translation
↓
Input Validation
↓
Output Mapping
↓
Error Handling
↓
Security
↓
Observability
↓
Operational Consistency
↓
Future Replaceability
Adapters should faithfully translate without influencing business decisions.
Translation belongs outside the business core.
#Stage 10 — Testability
Design for
Independent Business Testing
↓
Adapter Isolation
↓
Dependency Replacement
↓
Deterministic Behavior
↓
Business Validation
↓
Contract Verification
↓
Reliable Automation
↓
Engineering Confidence
Business capabilities should be testable without frameworks, databases, networks, or external services.
Excellent testability demonstrates successful architectural isolation.
#Stage 11 — Scalability
Design for
Growing Business
↓
Growing Users
↓
Growing Adapters
↓
Growing Integrations
↓
Growing Teams
↓
Independent Evolution
↓
Operational Simplicity
↓
Long-Term Sustainability
Hexagonal Architecture should allow external technologies to grow independently without affecting business logic.
Scalability should increase adapters—not business complexity.
#Stage 12 — Reliability
Verify
Business Consistency
↓
Fault Isolation
↓
Adapter Failures
↓
Recovery
↓
Operational Stability
↓
Monitoring
↓
Business Continuity
↓
Engineering Excellence
Failures occurring outside the business core should never corrupt business rules.
Reliable architecture isolates failures before they reach the domain.
#Stage 13 — Maintainability
Optimize
Readable Business Logic
↓
Independent Ports
↓
Simple Adapters
↓
Clear Responsibilities
↓
Low Coupling
↓
High Cohesion
↓
Knowledge Sharing
↓
Long-Term Evolution
Business logic should remain understandable without knowledge of infrastructure.
Maintainability improves when technology changes remain localized.
#Stage 14 — Trade-Off Analysis
Evaluate
Business Independence
↓
Implementation Complexity
↓
Development Speed
↓
Maintainability
↓
Scalability
↓
Operational Cost
↓
Technology Flexibility
↓
Future Evolution
Every abstraction introduces implementation effort.
Every dependency introduces long-term maintenance cost.
Excellent Hexagonal Architecture balances both.
#Stage 15 — Risk Assessment
Identify
Business Risks
↓
Dependency Risks
↓
Adapter Risks
↓
Integration Risks
↓
Operational Risks
↓
Infrastructure Risks
↓
Scalability Risks
↓
Technical Debt
Infrastructure changes should never become business risks.
Architectural isolation continuously reduces engineering uncertainty.
#Stage 16 — Validation
Validate
Business Independence
↓
Port Consistency
↓
Adapter Isolation
↓
Dependency Direction
↓
Infrastructure Independence
↓
Engineering Quality
↓
Operational Readiness
↓
Long-Term Sustainability
Architecture should be validated through measurable engineering evidence rather than assumptions.
The business core should remain completely independent from implementation technologies.
#Stage 17 — Documentation
Document
Business Capabilities
↓
Port Definitions
↓
Adapter Responsibilities
↓
Dependency Rules
↓
Integration Strategy
↓
Trade-Offs
↓
Operational Standards
↓
Future Evolution
Documentation should explain architectural reasoning rather than implementation details.
Engineering knowledge should remain understandable as technologies evolve.
#Stage 18 — Production Readiness
Validate
Infrastructure
↓
Deployment
↓
Monitoring
↓
Security
↓
Recovery
↓
Operational Procedures
↓
Scalability
↓
Engineering Excellence
Production environments should preserve architectural boundaries.
Operational complexity should never leak into the business core.
#Stage 19 — Governance
Maintain
Architectural Principles
↓
Port Standards
↓
Adapter Standards
↓
Engineering Standards
↓
Architecture Reviews
↓
Knowledge Sharing
↓
Continuous Improvement
↓
Engineering Discipline
Governance preserves architectural integrity as software evolves.
Discipline prevents boundary erosion.
#Stage 20 — Long-Term Evolution
Continuously improve
Business Understanding
↓
Business Capabilities
↓
Architecture
↓
Engineering Excellence
↓
Operational Excellence
↓
Maintainability
↓
Organizational Learning
↓
Software Longevity
Exceptional Hexagonal Architecture continuously protects business capabilities while enabling independent technology evolution, operational excellence, engineering discipline, and sustainable software development throughout the lifetime of the system.
#Hexagonal Architecture Quality Attributes
Evaluate
Business Independence
Port Stability
Adapter Replaceability
Maintainability
Testability
Scalability
Reliability
Low Coupling
High Cohesion
Infrastructure Isolation
Operational Excellence
Engineering Excellence
Adaptability
Portability
Resilience
Long-Term Sustainability
#Engineering Questions
Before approving ask
Does the business core depend upon any external technology?
↓
Can every adapter be replaced without changing business logic?
↓
Are ports stable abstractions rather than implementation details?
↓
Is dependency direction consistently enforced?
↓
Can the application operate independently of frameworks?
↓
Will future engineers understand why ports and adapters exist?
↓
Would experienced Software Architects, Principal Engineers, Staff Engineers, Platform Engineers, CTOs, Engineering Managers, and Technical Leaders confidently approve this Hexagonal Architecture?
#Severity Levels
Critical
Business logic depends upon adapters
Infrastructure inside the business core
Incorrect dependency direction
Business rules coupled to frameworks
Major
Weak port definitions
High coupling
Poor adapter isolation
Implementation leakage
Medium
Documentation gaps
Maintainability improvements
Architectural consistency improvements
Minor
Formatting
Naming consistency
Documentation quality
#Hexagonal Architecture Checklist
✓ Business objectives understood
✓ Domain modeled
✓ Business core designed
✓ Ports defined
✓ Adapters designed
✓ Dependencies managed
✓ Communication designed
✓ Infrastructure isolated
✓ Adapter validation completed
✓ Testability verified
✓ Scalability reviewed
✓ Reliability validated
✓ Maintainability evaluated
✓ Trade-offs documented
✓ Risks assessed
✓ Architecture validated
✓ Documentation completed
✓ Production readiness verified
✓ Governance established
✓ Long-term evolution planned
#Anti-Patterns
Avoid
Framework-first architecture
Database-centric design
Business logic inside adapters
Business logic inside controllers
Business logic inside repositories
Adapters calling adapters directly
Infrastructure leaking into domain models
Shared mutable dependencies
Circular dependencies
Technology-driven business rules
Overengineering every integration
Treating ports as framework interfaces
Mixing business responsibilities with transport concerns
Ignoring dependency inversion
Using adapters as business services
Allowing implementation details to influence business decisions
Treating Hexagonal Architecture as only a folder structure
#Definition of Done
A Hexagonal Architecture is considered complete when
- Business capabilities, domain models, application services, ports, adapters, dependency relationships, infrastructure boundaries, governance processes, operational capabilities, and long-term evolution strategies have been systematically designed using disciplined software engineering principles.
- Every business capability remains completely independent of frameworks, databases, cloud providers, messaging platforms, networking technologies, deployment environments, authentication mechanisms, and implementation details while maximizing maintainability, scalability, reliability, testability, replaceability, operational excellence, engineering consistency, and long-term software sustainability without introducing unnecessary coupling, boundary violations, architectural erosion, implementation leakage, or unmanaged technical debt.
- The architecture demonstrates clear separation between business logic and infrastructure, stable port definitions, replaceable adapters, predictable dependency direction, resilient operational capabilities, maintainable engineering practices, scalable organizational collaboration, and evidence-based architectural decisions that remain understandable throughout changing technologies, engineering teams, business requirements, and deployment environments.
- Engineering reviews validate business independence, dependency consistency, port stability, adapter isolation, implementation replaceability, maintainability, documentation completeness, production readiness, scalability characteristics, operational excellence, engineering discipline, and long-term software sustainability before significant implementation begins.
- Documentation clearly explains business capabilities, architectural principles, port responsibilities, adapter responsibilities, dependency rules, engineering rationale, governance standards, operational expectations, architectural trade-offs, future evolution strategies, and organizational responsibilities to preserve engineering knowledge beyond individual contributors.
- Architectural decisions remain measurable, evidence-based, implementation-independent, vendor-neutral, reproducible, and applicable across evolving software ecosystems, engineering organizations, cloud platforms, deployment environments, infrastructure providers, and future technology landscapes.
- The resulting architecture demonstrates engineering discipline, exceptional business independence, resilient software organization, maintainable evolution, operational maturity, scalable engineering practices, continuous improvement, and sustainable software excellence throughout the lifetime of the system.
Exceptional Hexagonal Architecture is not measured by the number of ports or adapters it contains.
It is measured by how effectively it protects business capabilities from technological change, enables independent evolution of infrastructure, strengthens engineering discipline, simplifies long-term maintenance, improves operational excellence, and allows software to evolve confidently throughout its lifetime.