← ClaudeAtlas

backend-architect-implementation-patternslisted

Reference patterns for clean architecture, dependency injection, repository pattern, domain-driven design, error handling, security best practices (parameterized queries, no hardcoded secrets), and common backend anti-patterns. Preloaded into the backend-architect subagent so layer-placement, pattern-selection, and anti-pattern-avoidance decisions during TDD Green phase implementation happen without on-demand reference loads.
bankielewicz/DevForgeAI · ★ 4 · AI & Automation · score 63
Install: claude install-skill bankielewicz/DevForgeAI
# Implementation Patterns for Backend Architect **Status**: Preloaded skill (BA-015) | **Agent**: backend-architect --- ## Clean Architecture (Layered) ``` Infrastructure Layer (Repositories, APIs, File I/O) Application Layer (Use Cases, Services, DTOs) Domain Layer (Entities, Business Logic, Domain Events) Dependency Flow: Infrastructure -> Application -> Domain NEVER reverse: Domain MUST NOT depend on Infrastructure ``` ## Dependency Injection **WRONG (Direct Instantiation):** ```python class OrderService: def __init__(self): self.repository = OrderRepository() # Hard dependency! ``` **CORRECT (Dependency Injection):** ```python class OrderService: def __init__(self, repository: IOrderRepository): self.repository = repository # Injected dependency ``` ## Single Responsibility Principle Each class should have ONE reason to change: - **Entity**: Manages its own state and business rules - **Repository**: Handles data persistence only - **Service**: Orchestrates use case only - **Controller**: Handles HTTP concerns only ## Repository Pattern **Interface (Domain Layer):** ```python from abc import ABC, abstractmethod class IOrderRepository(ABC): @abstractmethod def get_by_id(self, order_id: int) -> Order: pass @abstractmethod def save(self, order: Order) -> None: pass ``` **Implementation (Infrastructure Layer):** ```python class SqlOrderRepository(IOrderRepository): def __init__(self, db_connecti