| name | architecture-patterns |
| description | Architectural decision guide by complexity. Trigger: When choosing architecture, planning strategic refactoring, or evaluating pattern trade-offs. |
| license | Apache 2.0 |
| metadata | {"version":"1.0","type":"universal"} |
Architecture Patterns
Decision guide for choosing architectural approaches by project complexity, team size, and context. Orchestrates architectural thinking without coupling to specific patterns.
When to Use
- Deciding WHEN to apply architecture vs keeping it simple
- Choosing architectural approach by project complexity
- Planning strategic refactoring (module boundaries, layers)
- Understanding frontend vs backend architectural differences
- Evaluating architecture trade-offs
Don't use for:
- Learning specific patterns โ use pattern-specific skills (solid, domain-driven-design, clean-architecture)
- Tactical refactoring (rename, extract, inline) โ use code-refactoring skill
- Code review โ use critical-partner skill
Critical Patterns
โ
REQUIRED: Complexity-Driven Architecture
Match architecture complexity to project size and team.
Small (1-3 devs, <10k LOC):
โ Keep simple โ folder structure + code-conventions is enough
โ Apply: Basic separation (routes, components, utils)
โ Avoid: Layered architecture, DDD, Clean Architecture (overkill)
Medium (4-10 devs, 10k-100k LOC):
โ Modular architecture โ clear module boundaries
โ Apply: Single responsibility per module, layer separation
โ Consider: Clean Architecture for testability
Large/Enterprise (10+ devs, >100k LOC, multiple teams):
โ Full architectural approach required
โ Apply: Strict boundaries, domain-driven modules, hexagonal for testability
โ Consider: DDD for complex business domains
Guideline: Start simple. Apply architecture when pain points emerge.
โ
REQUIRED: Recognize Architecture Pain Points
Apply architecture when you see these signals:
โ Files >500 lines with mixed responsibilities
โ Changing one feature breaks unrelated features
โ Tests require 5+ mocks to test one unit
โ New devs take >2 weeks to make first contribution
โ Same bug fixed multiple times in different places
โ
REQUIRED: Frontend vs Backend Architecture
Different architectural concerns by platform:
Frontend architecture:
โ Component hierarchy and composition
โ State management boundaries (local vs global)
โ Data fetching and caching strategies
โ Route-based code splitting
Backend architecture:
โ Request/response flow layers
โ Business logic isolation from infrastructure
โ Database access patterns
โ API contract design
Common mistake: Applying backend patterns (repositories, use cases) to simple frontends. Most SPAs need state management + component composition, not full Clean Architecture.
โ
REQUIRED: Strategic vs Tactical Refactoring
Tactical (use code-refactoring skill):
โ Rename variables/functions
โ Extract small function
โ Inline variable
Strategic (THIS skill):
โ Define module boundaries
โ Separate layers (presentation, domain, data)
โ Extract entire modules
โ Redesign dependencies
When to refactor strategically:
โ Files >500 lines
โ Changing one feature breaks unrelated features
โ Tests require mocking 5+ dependencies
Decision Tree
Choosing architecture approach?
โ Small project (<10k LOC, 1-3 devs)?
โ Keep simple - folder structure + code-conventions
โ Medium project (10k-100k LOC, 4-10 devs)?
โ Apply modular architecture - clear module boundaries
โ Large project (>100k LOC, 10+ devs)?
โ Apply full architecture - strict boundaries, domain-driven
Frontend or backend?
โ Frontend โ Focus: component composition, state management, data fetching
โ Backend โ Focus: layer separation, business logic isolation, API contracts
Planning refactoring?
โ Tactical (rename, extract, inline)? โ Use code-refactoring skill
โ Strategic (modules, layers)? โ Use THIS skill
Need specific pattern knowledge?
โ SOLID principles โ solid skill
โ Clean Architecture โ clean-architecture skill
โ Domain-Driven Design โ domain-driven-design skill
โ Ports and Adapters โ hexagonal-architecture skill
โ Domain-first folder structure โ screaming-architecture skill
โ Error handling pattern โ result-pattern skill
โ Eliminate duplication โ dry-principle skill
โ Decoupled communication โ mediator-pattern skill
โ State / workflow modeling โ state-machines-pattern skill
โ Flexible component APIs โ composition-pattern skill
โ Fault tolerance / fast fail โ circuit-breaker-pattern skill
โ Microservice sidecar โ sidecar-pattern skill
Example
Repository + Service Layer pattern applied to a user feature in a medium-sized backend.
Request: POST /api/v1/users
โ
UserController (Presentation)
โ validates input with zod
โ calls UserService.createUser(dto)
โ
UserService (Business Logic)
โ checks email uniqueness
โ hashes password
โ calls UserRepository.save(user)
โ
UserRepository (Data Access)
โ IUserRepository interface defined in application layer
โ PostgresUserRepository implements it in infrastructure
โ returns saved User entity
โ
UserController
โ maps result to 201 Created + UserResponseDTO
Why this fits a medium project (4-10 devs, 10kโ100k LOC):
- Clear layer boundaries make code navigable for new team members
- Repository interface lets tests inject in-memory fakes (no DB required)
- Service layer owns business rules (uniqueness, hashing) โ not the controller
Edge Cases
Over-engineering: Applying Clean Architecture to a 1000-line app. Start simple, add architecture when pain emerges.
Under-engineering: No architecture in 100k LOC app with 10 devs. Technical debt compounds, velocity slows dramatically.
Premature abstraction: Creating 5 layers before knowing requirements. Apply YAGNI โ add layers when needed, not speculatively.
Frontend Clean Architecture: Usually overkill for React apps. State management (Redux/Zustand) + smart component composition is sufficient for most cases.
Checklist
Resources
Pattern-specific skills:
Integration examples: