architecture-patterns

Implement Clean Architecture, Hexagonal Architecture, and Domain-Driven Design patterns for backend services.

Updated Apr 23, 2026
One-click install
npx skills add https://github.com/SanketAdlak/PDMProjectDesign --skill architecture-patterns-sanketadlak
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: architecture-patterns
Source: https://github.com/SanketAdlak/PDMProjectDesign/tree/main/.agents/skills/architecture-patterns
Command: npx skills add https://github.com/SanketAdlak/PDMProjectDesign --skill architecture-patterns-sanketadlak

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 to structure applications with clear dependency rules and testable layers. ## Core Features & Use Cases - Clean Architecture Implementation: Layered directory structure (domain, use cases, adapters, infrastructure) with complete Python examples for entities, repository ports, use cases, and FastAPI controllers. - Hexagonal Architecture (Ports and Adapters): Abstract port interfaces with swappable adapters, including production Stripe adapters and in-memory test adapters that require no database or Docker. - Domain-Driven Design Tactics: Value objects, aggregates, repositories, domain events, bounded contexts, and Anti-Corruption Layers with a full multi-service project structure. - Use Case: When refactoring a monolith where use-case tests require a running database, apply the in-memory repository pattern to make every use case testable as a plain unit test. ## 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 implement Clean Architecture in Python?

Organize code into four layers: domain (entities and abstract interfaces), use_cases (application logic), adapters (concrete repositories and controllers), and infrastructure (framework wiring). Enforce the rule that domain and use_cases only import from domain, never from adapters or infrastructure.

What is the difference between Clean Architecture and Hexagonal Architecture?

Both enforce inward-pointing dependencies. Hexagonal Architecture frames the core as interacting with the outside through ports (abstract interfaces) and adapters (implementations), while Clean Architecture names four rings: entities, use cases, interface adapters, and frameworks.

How do I test use cases without a database?

Inject an in-memory repository implementing the same abstract port interface instead of the PostgreSQL adapter. The use case constructor accepts the abstract port, so tests run as plain unit tests with no Docker, database, or network required.

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. Fix it by defining the interface in domain/interfaces, having the use case import only that port, and wiring implementations in the infrastructure layer.

When should I use an Anti-Corruption Layer between bounded contexts?

Use an Anti-Corruption Layer when one bounded context must consume another context's model, such as Ordering fetching Catalog product data. The ACL translates the upstream model into the downstream context's own value objects, preventing model coupling.

How do I decide aggregate boundaries in Domain-Driven Design?

Place objects that must be consistent together in the same aggregate, and use domain events for eventually consistent relationships. Keep aggregates small by referencing other aggregates by ID rather than embedding full object graphs.