| name | software-architecture |
| description | Clean Architecture and SOLID principles guide. Use this when designing systems, reviewing architecture, or making structural decisions. |
| allowed-tools | Read, Glob, Grep, Edit, Write |
| license | MIT |
| metadata | {"author":"NeoLabHQ","version":"1.0"} |
Software Architecture
Clean Architecture์ DDD ์์น ๊ธฐ๋ฐ ์ํํธ์จ์ด ์ค๊ณ ๊ฐ์ด๋์
๋๋ค.
Core Principles
SOLID
| ์์น | ์ค๋ช
| ์์ |
|---|
| Single Responsibility | ํ๋์ ํด๋์ค๋ ํ๋์ ์ฑ
์ | UserRepository vs UserService |
| Open/Closed | ํ์ฅ์ ์ด๋ฆผ, ์์ ์ ๋ซํ | ์ธํฐํ์ด์ค ์ฌ์ฉ |
| Liskov Substitution | ํ์ ํ์
์ ์์ ํ์
๋์ฒด ๊ฐ๋ฅ | ์์ ๊ณ์ฝ ์ค์ |
| Interface Segregation | ํด๋ผ์ด์ธํธ๋ณ ์ธํฐํ์ด์ค ๋ถ๋ฆฌ | IReader vs IWriter |
| Dependency Inversion | ์ถ์ํ์ ์์กด | DI ์ปจํ
์ด๋ ์ฌ์ฉ |
Clean Architecture Layers
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Frameworks & Drivers โ โ DB, Web, UI
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ Interface Adapters โ โ Controllers, Gateways
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ Application Business Rules โ โ Use Cases
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ Enterprise Business Rules โ โ Entities
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
์์กด์ฑ ๊ท์น: ๋ฐ๊นฅ โ ์์ชฝ ๋ฐฉํฅ์ผ๋ก๋ง ์์กด
Code Style Rules
Early Return Pattern
function process(user) {
if (user) {
if (user.isActive) {
if (user.hasPermission) {
}
}
}
}
function process(user) {
if (!user) return;
if (!user.isActive) return;
if (!user.hasPermission) return;
}
Function/File Size Limits
| ๋์ | ๊ถ์ฅ | ์ต๋ | ์กฐ์น |
|---|
| ํจ์ | 30์ค | 50์ค | ๋ถ๋ฆฌ |
| ์ปดํฌ๋ํธ | 80์ค | 150์ค | ๋ถ๋ฆฌ |
| ํ์ผ | 200์ค | 300์ค | ๋ชจ๋ํ |
Domain-Specific Naming
utils/helpers.ts
common/index.ts
services/OrderCalculator.ts
auth/UserAuthenticator.ts
Library-First Approach
"๋ชจ๋ ์ปค์คํ
์ฝ๋๋ ์ ์ง๋ณด์, ํ
์คํธ, ๋ฌธ์ํ๊ฐ ํ์ํ ๋ถ์ฑ๋ค"
์ฝ๋ ์์ฑ ์ ํ์ธ:
- npm/yarn ํจํค์ง ๊ฒ์
- ๊ธฐ์กด ์๋น์ค/API ํ์ธ
- ์คํ์์ค ์๋ฃจ์
๊ฒํ
Anti-Patterns to Avoid
| Anti-Pattern | ๋ฌธ์ ์ | ํด๊ฒฐ์ฑ
|
|---|
| NIH Syndrome | ๋ฐํด ์ฌ๋ฐ๋ช
| ๋ผ์ด๋ธ๋ฌ๋ฆฌ ์ฐ์ |
| God Class | ๋๋ฌด ๋ง์ ์ฑ
์ | SRP ์ ์ฉ |
| Spaghetti Code | ์ฝํ ์์กด์ฑ | ๋ ์ด์ด ๋ถ๋ฆฌ |
| Magic Numbers | ์๋ฏธ ๋ถ๋ช
ํ | ์์ ์ถ์ถ |
| Deep Nesting | ๊ฐ๋
์ฑ ์ ํ | Early Return |
Separation of Concerns
โ
์ฌ๋ฐ๋ฅธ ๋ถ๋ฆฌ
โโโ domain/ # ๋น์ฆ๋์ค ๋ก์ง
โโโ application/ # Use Cases
โโโ infrastructure/ # DB, API
โโโ presentation/ # UI, Controllers
โ ์๋ชป๋ ๋ถ๋ฆฌ
โโโ components/
โ โโโ UserCard.tsx # UI + API ํธ์ถ + ๋น์ฆ๋์ค ๋ก์ง ํผํฉ
Decision Checklist
์๋ก์ด ์ฝ๋ ์์ฑ ์: