home / skills / partme-ai / full-stack-skills / ddd-hexagonal-architecture
This skill provides guidance on hexagonal architecture, ports and adapters, domain isolation, and dependency inversion to structure robust, adaptable software.
npx playbooks add skill partme-ai/full-stack-skills --skill ddd-hexagonal-architectureReview the files below or copy the command above to add this skill to your agents.
---
name: ddd-hexagonal-architecture
description: Provides comprehensive guidance for hexagonal architecture including ports and adapters, domain isolation, and dependency inversion. Use when the user asks about hexagonal architecture, needs to implement ports and adapters pattern, or structure applications with hexagonal architecture.
license: Complete terms in LICENSE.txt
---
## When to use this skill
Use this skill whenever the user wants to:
- [待完善:根据具体工具添加使用场景]
## How to use this skill
[待完善:根据具体工具添加使用指南]
## Best Practices
[待完善:根据具体工具添加最佳实践]
## Keywords
[待完善:根据具体工具添加关键词]
This skill provides practical guidance for designing and implementing hexagonal (ports and adapters) architecture with a focus on domain isolation and dependency inversion. It offers concrete patterns, folder layouts, and code-level recommendations for Python applications. Use it to structure systems that are testable, maintainable, and independent from frameworks and infrastructure.
The skill explains the core concepts: defining domain models and use cases inside the application core, exposing ports as interfaces, and implementing adapters for persistence, messaging, UI, and external APIs. It shows how to invert dependencies so the core depends only on abstractions and how adapters bind to those abstractions at the application boundary. The guidance includes recommended module layouts, example adapter responsibilities, and testing strategies to keep the domain isolated.
How do I choose what belongs in the domain core?
Keep business rules, entities, value objects, and use case orchestration in the domain core. Any code that exists only to adapt to frameworks, databases, or transport belongs in adapters.
Can I mix hexagonal structure with frameworks like Django or FastAPI?
Yes. Treat the framework as an adapter: use its request/response machinery in the outer layer and call your pure use cases and domain services from small, thin handlers.