xiaohongshu
xiaohongshu
designing-hexagonal-architecture
Guides the design and analysis of hexagonal architecture (Ports & Adapters) for backend systems. Use when structuring modular applications with clean separation between business logic and infrastructure.
Full skill instructions
Hexagonal Architecture, also known as Ports & Adapters pattern, is an architectural pattern proposed by Alistair Cockburn that aims to separate the core business logic of an application from external infrastructure. The philosophy centers on creating a flexible, testable, and maintainable system by inverting dependencies and isolating the domain from technical concerns.
The hexagonal shape represents the idea that the application has multiple "sides" where it interacts with the outside world, and each side is interchangeable. This approach enables:
This skill is particularly valuable when building enterprise applications, microservices, or any system where long-term maintainability and testability are priorities.
Hexagonal Architecture is built on several fundamental principles that work together to create a robust, maintainable system.
The application is organized into distinct layers, each with specific responsibilities:
The dependency direction flows from outer layers toward the domain at the center.
Ports define the boundaries between the domain and the outside world. They are interfaces that express what the business logic needs without specifying how it's implemented.
Characteristics of Ports:
Adapters are concrete implementations of Port interfaces. They handle the actual communication with external systems and infrastructure.
Types of Adapters:
Adapters translate between the domain's language and the technical protocols of external systems.
One of the most critical principles: dependencies point inward, toward the domain.
Dependency Flow:
External → Infrastructure → Application → Domain
Key Rules:
Hexagonal Architecture naturally aligns with SOLID principles:
Each domain module operates independently with minimal coupling:
Begin by understanding your business domains and their relationships. Map out:
For each domain module, identify what it needs from the outside world and what it provides to others:
Build the core business logic without any infrastructure concerns:
Implement concrete adapters for each port:
Wire everything together using a DI container:
Hexagonal Architecture can be implemented in various programming languages and frameworks. We provide detailed examples for:
Each example demonstrates:
Choose the example that matches your technology stack to see concrete implementations of the concepts discussed in this skill.
Maintain strict separation between layers with consistent dependency direction. Each layer should have a single, well-defined responsibility. Never allow business logic to leak into presentation or infrastructure layers.
Guidelines:
Design ports to expose only the methods needed by the domain. Follow the Interface Segregation Principle by creating focused, role-specific interfaces rather than large, monolithic ones.
Guidelines:
Organize code by business domain rather than technical layers. Each domain module should be cohesive and loosely coupled from other domains.
Guidelines:
Circular dependencies between modules indicate design issues. While forwardRef provides a technical solution, it's important to analyze the root cause.
Warning Signs:
Solutions:
Architecture should facilitate testing, not hinder it. Ports enable easy mocking, but only if designed properly.
Common Issues:
Solutions:
Not every interaction needs a port-adapter pair. Over-engineering leads to unnecessary complexity.
When to Avoid:
Balance:
Layer separation and indirection can introduce overhead. Monitor and optimize where necessary.
Considerations:
Optimization Strategies:
xiaohongshu
technical spec
product ux expert
database patterns
Conduct multi-agent task orchestration and workflow coordination.
Initialize project with Conductor artifacts (product definition,
Expert in web animations, transitions, and motion design using Framer Motion and CSS
Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...
PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.
Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...
Display project status, active tracks, and next actions
Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.
Generate, edit, and beat-sync AI video with leading models in one workspace.
The world's fastest calendar for remote work
Transform Your Design with AI Designer by ImgCreator.ai
Revolutionizing Video Production with AI-Powered Creativity
Extend an image past the frame and let AI fill the new aspect ratio.
Discover your celebrity doppelgänger with StarByFace!
ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.
Opus.ai: Revolutionize Your Web Experience