DDD Standard Architecture Rules
DDD Standard Architecture Rules
一、總體架構與分層定義
- 系統必須明確劃分為 Domain、Application、Infrastructure、Presentation 四個層級。
- 每個檔案只能屬於一個層級,不得同時承擔多層責任。
- 分層的目的是隔離「業務意圖」與「技術細節」,不得為方便而合併層級。
- 架構設計必須以長期演進與替換成本最小化為目標。
二、依賴方向(不可違反)
- 只允許以下單向依賴:
Domain → Application → Infrastructure → Presentation - 任何反向依賴一律視為架構錯誤。
- 不得以型別、工具函式、barrel export 或 side-effect 間接形成反向依賴。
- 依賴方向必須在 TypeScript
import層級即可被靜態分析出來。
三、Domain 層規則(業務核心)
More from 7spade/black-tortoise
material-design-3
Material Design 3 (Material You) design system knowledge for modern web and Angular applications. Use when implementing Material Design 3 theming, components, typography, color systems, dynamic color, accessibility patterns, or migrating from Material Design 2. Covers design tokens, theming APIs, and Material You principles.
68architecture-ddd
Domain-Driven Design patterns, layer boundaries (Presentation → Application → Domain ← Infrastructure), tactical patterns (entities, value objects, aggregates, repositories), and event-driven flow guidance. Use when designing new features, refactoring across layers, or enforcing DDD architectural boundaries.
13webapp-testing
Toolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing browser screenshots, and viewing browser logs.
12cohesion-coupling-review
Review a proposed change for high cohesion/low coupling; recommends the smallest boundary-safe refactor (ownership, minimal public surface, no reach-in imports). Use when reviewing code for coupling issues, cross-boundary imports, or excessive dependencies.
10angular-material-cdk-animations
Angular Material + CDK + @angular/animations usage patterns aligned with zoneless + signals-first UI and M3 tokens. Use when implementing Material Design 3 components, accessibility features, animations, overlays, drag-drop, virtual scrolling, or custom UI components using CDK utilities.
10angular-fire
Best practices and code patterns for @angular/fire version 20+, integrating Firestore and Auth with Signals and DDD architecture. Use when implementing Firebase integration, Firestore repositories, or AngularFire Auth in the infrastructure layer.
10