--- id: wiki-2026-0508-아키텍처-패턴-지식 title: 아키텍처 패턴 지식 category: 10_Wiki/Topics status: verified canonical_id: self aliases: [Architecture Patterns, Architectural Styles] duplicate_of: none source_trust_level: A confidence_score: 0.9 verification_status: applied tags: [architecture, patterns, design] raw_sources: [] last_reinforced: 2026-05-10 github_commit: pending tech_stack: language: agnostic framework: agnostic --- # 아키텍처 패턴 지식 ## 매 한 줄 > **"매 architectural pattern 은 매 recurring problem 의 매 reusable solution 으로, 매 trade-off 가 매 명시되어야 한다"**. Buschmann 의 매 POSA series (1996) 이래로, 매 modern catalog (Richards/Ford 2020, Vernon 2021) 는 매 microservices, event-driven, hexagonal, modular monolith, serverless 를 매 핵심으로 다룬다. ## 매 핵심 ### 매 6 fundamental styles - **Layered (n-tier)**: presentation / business / data. - **Pipe & filter**: 매 streaming transformation chain. - **Microkernel (plugin)**: 매 core + 매 extension. - **Service-based**: 매 monolith → 매 coarse-grained services. - **Event-driven (broker / mediator)**: 매 async pub/sub. - **Space-based**: 매 in-memory data grid + 매 messaging. ### 매 modern patterns - **Hexagonal (Ports & Adapters)**: 매 domain 매 framework-independent. - **Clean Architecture**: 매 dependency rule (outward → inward). - **CQRS**: 매 read / write 분리. - **Event Sourcing**: 매 state = 매 event sequence. - **Saga**: 매 distributed transaction via 매 compensation. - **BFF (Backend for Frontend)**: 매 client-specific gateway. ### 매 응용 1. 매 quality attribute → 매 pattern 매 mapping. 2. 매 ADR 에서 매 chosen pattern 명시. 3. 매 fitness function 으로 매 pattern adherence 검증. ## 💻 패턴 ### Hexagonal (TypeScript) ```typescript // domain/order.ts (pure) export class Order { confirm(): Order { /*...*/ } } // app/ports.ts export interface OrderRepo { save(o: Order): Promise; } export interface PaymentGate { charge(amt: number): Promise; } // app/place-order.ts (use case) export class PlaceOrder { constructor(private repo: OrderRepo, private pay: PaymentGate) {} async run(cart: Cart): Promise { const txn = await this.pay.charge(cart.total); const order = new Order(cart, txn).confirm(); await this.repo.save(order); return order; } } // infra/postgres-order-repo.ts (adapter) export class PgOrderRepo implements OrderRepo { /*...*/ } ``` ### Event-driven (Kafka, Java) ```java @KafkaListener(topics = "orders.placed") public void onOrderPlaced(OrderPlacedEvent e) { inventoryService.reserve(e.items()); kafka.send("inventory.reserved", new InventoryReservedEvent(e.orderId(), e.items())); } ``` ### CQRS (.NET 9) ```csharp public record PlaceOrderCommand(Guid Id, List Items); public record OrderSummaryQuery(Guid Id); public class CommandHandler : IRequestHandler { public async Task Handle(PlaceOrderCommand cmd, CancellationToken ct) { await writeDb.SaveAsync(new Order(cmd)); await bus.PublishAsync(new OrderPlaced(cmd.Id)); return Unit.Value; } } public class QueryHandler : IRequestHandler { public Task Handle(OrderSummaryQuery q, CancellationToken ct) => readReplica.GetAsync(q.Id); } ``` ### Saga (orchestration, Temporal) ```python @workflow.defn class CheckoutWorkflow: @workflow.run async def run(self, order: Order) -> str: try: payment = await workflow.execute_activity(charge, order) inv = await workflow.execute_activity(reserve, order) ship = await workflow.execute_activity(ship, order) return ship.tracking_id except ActivityError: await workflow.execute_activity(refund, payment) await workflow.execute_activity(release_inventory, inv) raise ``` ### Modular Monolith (Spring Modulith) ```java @Modulith(systemName = "Shop", sharedModules = "shared") @SpringBootApplication public class ShopApp { } // inventory/InventoryService.java — package-private @ApplicationModuleListener void on(OrderPlaced e) { reserve(e.items()); } ``` ## 매 결정 기준 | 상황 | Pattern | |---|---| | 매 startup, single team | Modular monolith | | 매 read >> write | CQRS | | 매 audit / temporal queries | Event Sourcing | | 매 cross-service workflow | Saga (Temporal / orchestration) | | 매 polyglot frontends | BFF | | 매 high event throughput | Event-driven (Kafka) | **기본값**: 매 modular monolith 시작 → 매 evidence 기반 매 split. ## 🔗 Graph - 부모: [[소프트웨어 아키텍처 설계]] - 변형: [[Microservices]] · [[Cloud_Native|Modular Monolith]] · [[Hexagonal Architecture]] - 응용: [[CQRS]] · [[Event Sourcing]] · [[Saga]] · [[BFF]] - Adjacent: [[DDD]] · [[Clean Architecture]] ## 🤖 LLM 활용 **언제**: 매 pattern selection rationale / 매 trade-off 비교 / 매 boilerplate generation. **언제 X**: 매 final architecture decision — 매 senior architect review 필수. ## ❌ 안티패턴 - **Pattern over-application**: 매 모든 곳 매 microservice. - **Mixing CQRS + sync read-after-write**: 매 consistency expectation 위반. - **Saga without compensation test**: 매 partial failure 매 silent. - **Hexagonal in name only**: 매 domain 매 framework annotations 의 침투. ## 🧪 검증 / 중복 - Verified (Richards & Ford, *Software Architecture: The Hard Parts*; Vernon, *Strategic Monoliths and Microservices*; Buschmann, *POSA Vol 1*). - 신뢰도 A. ## 🕓 Changelog | 날짜 | 변경 | |---|---| | 2026-05-08 | Phase 1 | | 2026-05-10 | Manual cleanup — hexagonal/CQRS/saga/modulith 패턴 추가 |