| name | ca-architecture-boundaries |
| description | Applies Clean Architecture's dependency-direction and SRP-by-actor rules to system-level boundary design: separates business logic from infrastructure, identifies actor-coupling risks, and enforces inward-pointing dependency arrows. For system scope (multiple components, layers, or services), not routine or module scope (use cc-routine-and-class-design). |
| user-invocable | false |
Architecture Boundaries (Clean Architecture)
Operates at SYSTEM level (layers, boundaries, components). For MODULE level (interface depth, information hiding), use aposd-designing-deep-modules.
SRP Is About Actors, Not "Doing One Thing"
"A module should be responsible to one, and only one, actor."
An actor is a group of users/stakeholders who request changes. If two actors share a class, a change for one can break the other.
class Employee {
Money calculatePay() { }
String reportHours() { }
void save() { }
}
class EmployeeData { }
class PayCalculator {
Money calculatePay(EmployeeData e) { }
}
class HourReporter {
String reportHours(EmployeeData e) { }
}
class EmployeeSaver {
void saveEmployee(EmployeeData e) { }
}
class EmployeeFacade {
}
Test: For each class, ask "who requests changes to this?" If the answer is more than one actor, split.
DRY Within Actor Boundaries Only
Duplication across actor boundaries is safer than coupling.
If CFO's calculatePay and COO's reportHours both use the same regularHours helper, they appear duplicated — but they change for different reasons. Merging them couples two actors. When CFO's accounting rules change, COO's reports break.
Rule: DRY applies within a single actor's code. Across actors, prefer duplication over coupling.
Dependency Rule
Dependencies point inward: Frameworks → Adapters → Use Cases → Entities.
Nothing in an inner circle can know anything about an outer circle. Business rules never import database, UI, or framework code. If business logic needs to call infrastructure, define an interface in the business layer and implement it in the infrastructure layer (dependency inversion).
Separate Business Rules from Infrastructure
Pattern: interface defined in the business layer (where it's used), implemented in the infrastructure layer (dependency inversion).
public interface OrderRepository { Order findById(String id); void save(Order order); }
public class SqlOrderRepository implements OrderRepository { }
The Use Case depends on OrderRepository (abstraction). The infrastructure layer depends on OrderRepository too — arrows point inward.
Integration Checklist
When applying to an existing system:
Phase 1: Identify
Phase 2: Draw Boundaries
Phase 3: Verify
Boundary Violation Detection
Adapt paths to your project's directory structure.
grep -r "import.*servlet\|import.*spring.*web\|import.*express" src/domain/
grep -r "import.*sql\|import.*mongoose\|import.*prisma" src/entities/
grep -r "@Entity\|@Table\|@Column" src/domain/
grep -r "instanceof\|getType()\|typeof.*===" src/domain/ src/entities/
Chain
| After | Next |
|---|
| Boundaries drawn | aposd-designing-deep-modules (module-level design) |
| SOLID violations found | cc-refactoring-guidance (safe restructuring) |