architecture-patterns

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

2|Updated Jun 16, 2026
One-click install
npx skills add https://github.com/monang404/lunawave --skill architecture-patterns-monang404
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: architecture-patterns
Source: https://github.com/monang404/lunawave/tree/main/.agent/skills/architecture-patterns
Command: npx skills add https://github.com/monang404/lunawave --skill architecture-patterns-monang404

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Designing backend systems that remain maintainable and testable as they grow is difficult; tightly coupled code makes refactoring, testing, and framework swaps painful. This Skill provides structured guidance and code templates for applying proven architecture patterns to new designs and legacy refactors. ## Core Features & Use Cases - Clean Architecture Guidance: Layered structure (entities, use cases, adapters, infrastructure) with dependency rules pointing inward, including a full Python/FastAPI implementation example. - Hexagonal Architecture (Ports & Adapters): Define ports as interfaces and swap adapters such as Stripe payment gateways or mock implementations for testing. - Domain-Driven Design Patterns: Tactical patterns including entities, value objects, aggregates, repositories, and domain events with code samples. - Use Case: When refactoring a monolithic order-processing service, use this Skill to define repository ports, move business rules into domain entities, and replace direct database calls with adapter implementations. ## Quick Start Ask the AI to design a hexagonal architecture for a new order management backend with ports, adapters, and domain entities.

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, use cases, adapters, and infrastructure, with dependencies pointing inward. Define repository interfaces in the domain layer, implement them in adapters such as PostgresUserRepository, and keep controllers thin by delegating to use case classes.

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

Clean Architecture organizes code into concentric layers with an inward dependency rule, while Hexagonal Architecture centers the domain and connects external concerns through ports and adapters. Both keep business logic independent of frameworks and make implementations swappable for testing.

How do I use ports and adapters for payment gateways?▼

Define a PaymentGatewayPort abstract interface with methods like charge, then implement adapters such as StripePaymentAdapter for production and MockPaymentAdapter for tests. The domain service depends only on the port, so implementations can be swapped without changing business logic.

When should I not use Clean Architecture?▼

Avoid full Clean Architecture for simple CRUD applications or small localized refactors, where the layering adds overhead without benefit. The pattern fits complex domains with meaningful business rules, multiple external integrations, or long-lived codebases requiring testability.

What are aggregates in Domain-Driven Design?▼

Aggregates are consistency boundaries with a root entity that controls access to related objects and enforces invariants, such as a Customer limiting addresses to five. Repositories persist and reconstitute entire aggregates, and domain events are published after saving.