architecture-patterns

Implement Clean Architecture, Hexagonal Architecture, and Domain-Driven Design patterns in Python backends.

Updated Apr 13, 2026
One-click install
npx skills add https://github.com/scoots31/engineering-playbook --skill architecture-patterns-scoots31
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: architecture-patterns
Source: https://github.com/scoots31/engineering-playbook/tree/main/references/architecture-patterns
Command: npx skills add https://github.com/scoots31/engineering-playbook --skill architecture-patterns-scoots31

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Backend codebases often entangle business logic with frameworks, ORM models, and HTTP concerns, making them hard to test, refactor, and split into services. This Skill provides concrete patterns and working code for structuring services so business logic stays independent of infrastructure. ## Core Features & Use Cases - Clean Architecture layering: Directory structures and dependency rules separating entities, use cases, adapters, and infrastructure. - Hexagonal Architecture (Ports and Adapters): Abstract port interfaces with swappable adapters such as PostgreSQL repositories, Stripe payment gateways, and in-memory test doubles. - Domain-Driven Design tactical patterns: Aggregates, value objects, repositories, and domain events with invariant enforcement. - Use Case: When refactoring a monolith where use-case tests require a running database, apply the in-memory adapter pattern so every use case runs in plain unit tests with no Docker or network. ## Quick Start Ask the AI to design a clean architecture structure for a new user management microservice with testable use cases and swappable database adapters.

Frequently Asked Questions about architecture-patterns

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I structure a Python backend with Clean Architecture?

Organize code into domain (entities, value objects, interfaces), use_cases (application rules), adapters (repositories, controllers, gateways), and infrastructure (config, wiring). All imports in domain and use_cases must point inward only, never toward adapters or infrastructure.

What is the difference between Clean Architecture and Hexagonal Architecture?

Both enforce dependency inversion so business logic stays framework-free. Clean Architecture uses concentric layers (entities, use cases, adapters, frameworks), while Hexagonal Architecture defines ports as abstract interfaces with swappable adapters like PostgreSQL or Stripe implementations.

How do I test use cases without a running database?

Inject an in-memory repository implementing the same abstract port interface into the use case constructor. This lets every use case run in plain unit tests with no Docker, database, or network, which is the hallmark of correctly applied Clean Architecture.

Why do I get circular imports between use cases and adapters?

Circular imports happen when a use case imports a concrete adapter class instead of the abstract port. Enforce the rule that use_cases imports only from domain entities and interfaces, never from adapters or infrastructure.

When should I use bounded contexts in Domain-Driven Design?

Use bounded contexts when a single shared model serves multiple subdomains and causes coupling. Isolate a coherent model per context, and add an Anti-Corruption Layer when one context must reference another, such as Order holding its own CustomerId value object.