architecture-patterns

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

Updated Jul 28, 2026
One-click install
npx skills add https://github.com/truongnat/Restly --skill architecture-patterns-truongnat
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: architecture-patterns
Source: https://github.com/truongnat/Restly/tree/main/.agents/skills/architecture-patterns
Command: npx skills add https://github.com/truongnat/Restly --skill architecture-patterns-truongnat

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 proven layered architecture patterns that keep domain logic independent of infrastructure. ## Core Features & Use Cases - Clean Architecture: Enforce inward-pointing dependencies across entities, use cases, adapters, and infrastructure layers. - Hexagonal Architecture: Define ports and adapters so implementations like PostgreSQL or Stripe can be swapped without touching the domain core. - DDD Tactical Patterns: Apply aggregates, value objects, repositories, and domain events with correct consistency boundaries. - Use Case: When refactoring a monolith where use-case tests require a running database, introduce repository interfaces and in-memory adapters so every use case runs as a plain unit test with no Docker or network. ## Quick Start Ask the AI to design a layered architecture with ports and adapters for a new order-processing microservice using Clean Architecture and DDD patterns.

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 a Python backend?▼

Organize code into domain (entities, value objects, interfaces), use_cases, adapters, and infrastructure layers. Every import in domain and use_cases must point only toward domain; concrete implementations like PostgresUserRepository live in adapters and are wired via a DI container.

What is the difference between Hexagonal Architecture and Clean Architecture?▼

Both enforce inward-pointing dependencies. Hexagonal Architecture frames the domain core around ports (abstract interfaces) and adapters (concrete implementations), while Clean Architecture uses four rings: entities, use cases, interface adapters, and frameworks. Onion Architecture is a close variant with explicit domain services.

How do I test use cases without a database?▼

Inject an in-memory repository implementing the same abstract port interface, such as InMemoryUserRepository backed by a dictionary. The use case constructor must accept the abstract port, not the concrete class, so tests need no Docker, database, or network.

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. Define the interface in domain/interfaces, have adapters implement it, and wire implementations in the infrastructure layer's DI container.

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

Use an ACL when one bounded context must consume another's model, such as Ordering fetching Catalog product data. The downstream context defines its own value object (e.g., ProductSnapshot) and a port interface, with an adapter translating the upstream response into the local model.

How do I decide aggregate boundaries in DDD?▼

Put objects that must be consistent together in the same aggregate; use domain events for eventually consistent relationships. Reference other aggregates by ID only, keep aggregates small enough to avoid loading thousands of objects, and make the controlling entity the aggregate root.