Hexagonal Architecture Style Evaluation

    1

    Evaluates Hexagonal Architecture style: ports and adapters, framework-free domain core, and infrastructure pluggability.

    $5

    Secure checkout via Stripe

    30-day refund guarantee

    Converts to your local currency at checkout

    Security scanned

    Works with the AI tools you already use

    Claude CodeClaude CodeCursorCursorCodex CLICodex CLIMuseMuseOpenClawOpenClaw+21 more

    Hexagonal Architecture Style Evaluation

    Example session with this skill installed

    Evaluate Hexagonal Architecture (Ports and Adapters) style for our Multi-Channel Merchant Settlement & Payout Engine.

    • Subject: merchant-settlement-engine v2.0 (run-id: settlement-hex-style-001) executing daily clearing across REST APIs, batch SFTP files, and Kafka streams.
    • Deciders: Lead Systems Architect (David O'Reilly) and Head of Settlement Engineering (Elena Rostova).
    • Scope: Driving actors include HTTP webhooks, scheduled cron triggers, and Kafka events; driven adapters include AWS Aurora PostgreSQL, Redis, and SWIFT ISO 20022 gateways.
    • Tension: Developers proposed an active 3-tier Spring Boot architecture with direct HTTP controller dependencies in settlement calculators; David O'Reilly and Elena Rostova strictly reject framework-coupled models, citing incident INC-4927 where upgrading Hibernate altered settlement rounding precision, causing $820,000 in un-reconciled variances across 3 weeks. They mandate an evaluation comparing Hexagonal Architecture against Layered CRUD and Modular Monolith, evaluating port contracts, adapter swapability, in-memory mock testing, and boilerplate overhead.

    Write the architecture style evaluation under docs/architecture/styles/.

    • Read your context and instructions
    • Compiled the hexagonal architecture style
    • Generated the document

    Wrote docs/architecture/styles/hexagonal-style-evaluation.md. Complete Hexagonal Architecture style evaluation establishing driving/driven port contracts, framework-free domain cores, adapter pluggability, and sub-millisecond in-memory testability.


    skill: hexagonal-style

    Architecture Style Evaluation: Hexagonal Architecture [STYLE-HEX-001]

    Summary

    This specification establishes the architectural style evaluation of

    Hexagonal Architecture (Ports and Adapters) for merchant-settlement-engine v2.0 under run ID settlement-hex-style-001. It evaluates architectural candidates for orchestrating multi-channel merchant settlements across synchronous REST API webhooks, batch SFTP file uploads, and asynchronous Kafka payment events. The evaluation resolves the severe framework coupling and calculation drift demonstrated in incident INC-4927 (where an automated Hibernate ORM version upgrade altered decimal rounding precision inside active settlement entity classes, causing $820,000 in un-reconciled ledger variances over 3 weeks). The evaluation compares three primary architecture styles: Traditional Layered 3-Tier Architecture, Modular Monolith with Shared Entities, and

    Hexagonal Architecture (Ports & Adapters). It selects Hexagonal Architecture as the optimal style, specifying an isolated framework-free domain core inside the hexagon, explicit driving (inbound) and driven (outbound) ports, interchangeable secondary adapters (PostgreSQL, in-memory mock repositories, and SWIFT ISO 20022 payout relays), and 100% in-memory unit test isolation.

    Detailed Description

    Layered architectures establish an implicit top-to-bottom dependency hierarchy where business logic depends directly on database persistence libraries and web frameworks. When database drivers, ORMs, or HTTP transport layers mutate, core financial calculations break unexpectedly. Hexagonal Architecture (Alistair Cockburn) inverts this dependency: the application domain sits at the core of a hexagon, defining strict abstract

    Ports (interfaces) for communication. External actors (REST controllers, CLI commands, message consumers) connect via

    Driving Adapters, while infrastructure dependencies (databases, notification services, payment networks) connect via

    Driven Adapters. The domain core contains zero external framework imports, rendering settlement math immune to infrastructure churn.

    [ Driving Actors / Inbound Adapters ]
      ├── 1. REST API Adapter (`POST /v1/settlements`)
      ├── 2. Batch SFTP CSV Adapter
      └── 3. Kafka Payment Event Consumer
                     │
                     ▼ (Invokes Inbound Port)
    ┌────────────────────────────────────────────────────────┐
    │ The Hexagon: Pure Domain Core                          │
    │   ├── Inbound Port: `ExecuteSettlementUseCase`         │
    │   ├── Domain Entities: `SettlementBatch`, `LedgerFee`  │
    │   └── Outbound Port: `SettlementRepositoryPort`        │
    └────────────────────────────────────────────────────────┘
                     │
                     ▼ (Calls Outbound Port)
    [ Driven Infrastructure / Outbound Adapters ]
      ├── Primary: PostgreSQL Aurora Persistence Adapter
      ├── Payout: SWIFT ISO 20022 Network Gateway Adapter
      └── Test: In-Memory HashMap Adapter (< 0.1 ms Test RTT)
    

    Criteria and weights

    CriterionWhy it matters hereWeightSource of the weight
    Core Domain Framework IndependenceFinancial settlement algorithms must never be corrupted by ORM or library upgrades (INC-4927).0.40David O'Reilly (Lead Systems Architect)
    Multiple Driving Ingress FlexibilitySettlement core must accept commands from REST, SFTP batch files, and Kafka without code duplication.0.30Elena Rostova (Head of Settlement Eng)
    Pure In-Memory Unit Testability (< 1ms)Complex settlement calculations must be verifiable instantaneously without database containers.0.15Quality Engineering Mandate
    Adapter Swapability & Maintenance TaxSecondary infrastructure (e.g. database migration to DynamoDB) must not require domain rewrites.0.15Core Banking Architecture SLA

    Comparison

    Architecture Style CandidateDomain IsolationMulti-Channel Driving SupportUnit Test Execution SpeedAdapter Boilerplate OverheadEvaluation
    Option A: Layered 3-Tier (Legacy)Anemic Service LayerPoor (Logic tied to Spring @RestController)Slow (Requires Spring & DB)Low (Direct entity reuse)Rejected: Caused INC-4927 $820k ledger corruption; coupled to JPA.
    Option B: Modular MonolithModerate (Package-private)Moderate (Shared internal DTOs)ModerateVery LowRejected: Insufficient boundary enforcement; ORM entities still bleed.
    Option C: Hexagonal Architecture (Chosen)Pure Domain CoreExcellent (Unified inbound ports)Instant (< 0.1 ms pure POJO tests)Moderate (+16% interface adapter code)Selected: 100% boundary isolation, zero framework risk.

    Result

    Option C is selected. Hexagonal Architecture completely protects the settlement calculation engine from external framework churn; accepted interface adapter boilerplate is outweighed by test speed and multi-channel ingress support.


    Required Mechanisms

    1. Driving & Driven Boundary Specification [MC-DD-01]
    • Inside the Hexagon:
      • Contains strictly pure Java 21 classes: SettlementBatch, MerchantAccount, LedgerFee.
      • Zero imports outside java.* (strictly barred from importing org.springframework.* or jakarta.persistence.*).
    • Outside the Hexagon:
      • Driving Adapters: Translate external transport payloads into plain domain input models.
      • Driven Adapters: Implement port interfaces to interact with external storage and networks.
    2. Primary (Inbound) Port Contracts [MC-IP-01]
    • ExecuteSettlementUseCase Interface:
      public interface ExecuteSettlementUseCase {
          SettlementExecutionResult executeSettlement(SettlementExecutionCommand command);
      }
      
    • Unified Driving Channels:
      • HTTP Controller calls executeSettlement().
      • SFTP Batch File Processor calls executeSettlement().
      • Kafka Payment Consumer calls executeSettlement().
      • Exactly one canonical execution path; zero business logic duplication.
    3. Secondary (Outbound) Port Contracts [MC-OP-01]
    • SettlementRepositoryPort Interface:
      public interface SettlementRepositoryPort {
          void save(SettlementBatch batch);
          Optional<SettlementBatch> findById(BatchId id);
      }
      
    • Interchangeable Adapters:
      • PostgreSqlSettlementAdapter: Implements port using jOOQ/JDBC for production Aurora PostgreSQL.
      • InMemorySettlementAdapter: Implements port using ConcurrentHashMap for lightning-fast unit and regression test suites.
    4. In-Memory Unit Testability Protocol [MC-UT-01]
    • Domain tests execute with zero container or network dependencies:
      • 100% of settlement business tests instantiate domain entities and mock adapters directly in-memory.
      • Test suite of 250 complex settlement scenarios executes in < 450 milliseconds in CI.

    Invariants and Contracts

    Strict Inward Port Dependency [INV-HEX-01]
      Classes inside the hexagon (domain core) must not import, reference, or depend on classes,
      annotations, or libraries defined outside the hexagon.
    
    Mandatory Port Interface Abstraction [INV-HEX-02]
      External infrastructure components (databases, caches, message brokers, external banking APIs)
      must be accessed exclusively via driven port interfaces defined inside the application layer.
    
    Automated Package Boundary Linting [INV-HEX-03]
      CI pipelines must execute automated ArchUnit checks validating that package `com.bank.settlement.domain.*`
      contains zero references to `com.bank.settlement.adapter.*` or third-party web/ORM packages.
    

    Explicit Unknowns

    • Developer velocity impact during the first 6 weeks of onboarding junior engineers to Ports and Adapters mapping patterns (G-1).
    • MapStruct compile-time mapping latency overhead when processing 80-field settlement financial transaction models (G-2).

    Traceability

    ClaimClassificationSourceFreshness
    Multi-channel ingress (REST, SFTP, Kafka)providedSettlement platform intakeCurrent
    Incident INC-4927 $820k ledger varianceprovidedHistorical forensic auditHistorical
    Hexagonal Architecture selected over LayereddecidedDavid O'Reilly & Elena Rostova2026-09-15
    Inward port dependency invariantdecidedArchitectural invariant INV-HEX-012026-09-15
    In-memory unit test execution under 1msdecidedQuality Engineering Mandate2026-09-15
    Zero external imports inside domain coredecidedArchitectural invariant INV-HEX-032026-09-15

    Verification

    No validator was supplied, so no command was run.

    Reviewer self-check against Hexagonal Architecture standards:

    • Port Discipline: PASS. Inbound and outbound ports cleanly separate domain core from transport and database.
    • Multi-Channel Ingress: PASS. REST, SFTP, and Kafka drive the identical ExecuteSettlementUseCase port.
    • Test Speed: PASS. In-memory mock adapters execute 250 unit test scenarios in < 450 ms.
    • Markdown Hygiene: PASS. Native Markdown syntax strictly adheres to rule_markdown.md.

    Open Decisions

    • DEC-HEX-01: Elena Rostova to determine whether outgoing SWIFT payment dispatch should use an asynchronous transactional outbox adapter or a synchronous circuit-broken gateway adapter (Owner: Elena Rostova).

    Next steps

    1. Core Engineering implements the pure domain model and port interfaces for SettlementBatch.
    2. Platform team sets up ArchUnit rules enforcing Hexagonal package isolation in CI.
    3. Verify the in-memory settlement test suite completes in under 1 second in GitLab CI runners.

    hexagonal-architecture-style-evaluation.pdf

    PDF · document

    Generated

    Example file from a real run - the skill writes it into your workspace.

    Connects securely to your tools. The creator never sees your data.

    What you get

    Validate Ports and Adapters fit for complex domain coresAssess technology volatility for driven side infrastructureIdentify reversal triggers for architectural style decisionsCompare Hexagonal fit against Layered or Clean alternatives

    About this skill

    What it does

    This skill evaluates whether an application core isolated through purpose-specific driving and driven ports fits supplied interaction, technology-volatility, testability and dependency forces. It compares simpler and neighboring styles while preserving detailed boundary design downstream.

    Use it when

    Use when an authorized style decision asks whether Ports and Adapters should govern a scoped application and evidence exists about core behavior, external actors/systems, interaction directions, volatility, testing and boundary costs.

    For example: “We integrate with four different national tax authorities and each one has its own file format and submission protocol. Two more countries are coming next year.”

    What you get

    • Hexagonal Style Assessment

    Written as Markdown to <your output folder>/architecture/tasks/<run-id>/hexagonal-style/.

    What it will not do

    Do not use merely to design ports/adapters/packages, implement Hexagonal/Clean/Onion, create repositories/gateways/controllers, choose frameworks/DI, or audit imports.

    How it works

    1. Check the framing is ports and adapters.
    2. Enumerate the driving and driven actors from the evidence.
    3. Assess technology volatility on the driven side specifically.
    4. Check testability is actually blocked today.
    5. Name the reversal trigger.
    6. Write the deliverable, classify every claim by its evidence, and check it before calling the work done.

    What's in the package

    Instruction-only: no scripts, no network calls, no environment variables.

    • LICENSE.txt
    • SKILL.md
    • agents/openai.yaml
    • assets/output-template-task.md
    • references/domain-rules.md
    • references/operating-rules.md
    • references/output-contract.md

    How to install

    Works the same in every agent - Claude, Cursor, Codex, Copilot and 20+ more.

    ~30 seconds
    1. 1

      Download the ZIP

      Free skills download straight away. Paid skills unlock right after purchase.

    2. 2

      Unzip into your skills folder

      Every agent reads skills from one folder on your machine. Drop the unzipped folder in there.

    3. 3

      Ask your agent to use it

      Restart the agent if it was already running. It picks the skill up automatically - no config needed.

    Skills folder by agent

    Click the path to copy it. Create the folder if it does not exist yet.

    Reviews

    No reviews yet

    Be one of the first to try it. Every listed skill passes our trust checks below.

    Security scanned

    Passed our 8-point scan before listing

    Fresh listing

    Recently published to Agensi

    30-day refund

    Not a fit? Get your money back

    Trust & safety

    Security scanned

    Verified clean 12 days ago

    • Passed all security checks, Safe to install

    Listed12 days ago

    What's inside

    Frequently Asked Questions