docs(10_Wiki): 위키 전체 재구성 — Topic_* 폴더를 4개 카테고리로 통합 + 대규모 중복 제거
Topic_Agent/Topic_Blog/Topics/Topics_Biz/Topics_Meeting/Topics_Rag의 마크다운 지식 문서를 Topic_General/Topic_Programming/Topic_Graphic/Topic_Business 4개 카테고리로 재분류. - 중복 제거: frontmatter의 status:duplicate/merged + duplicate_of/redirect_to 필드로 자기 자신을 중복으로 선언한 리다이렉트 stub 1032개 제거, 완전 동일 내용 파일 472개 제거, 동일 파일명·다른 내용 충돌 시 더 큰(완전한) 버전만 유지(162개 제거) — 총 1639개 중복 제거. - 분류: 폴더 단위로 명확한 항목(AI_and_ML/Coding/Architecture 등 → Programming, Comfyui/Visual_Effects → Graphic, Topics_Biz/Topics_Meeting/사업 등 → Business, Poetic_Blog_Writing/창의성/Game_Design 등 → General)은 폴더 우선순위로, 나머지 혼재 폴더(Topic_Agent/Topic_Blog/Topics 루트/Thinking & Reasoning/Other/UI_UX_Assets)는 title/tags 키워드 스코어링으로 파일 단위 분류(불명확한 경우 General로 폴백). 원본 폴더명은 "From_*" 서브폴더로 보존해 추적 가능성 유지. - 최종 배치: Programming 2784 / General 1608 / Graphic 285 / Business 249 = 4926개 문서. - 에이전트 운영 상태(.astra/.agent/.obsidian/sessions/memory/_company/docs/lessons/_shared/src)는 지식 콘텐츠가 아니므로 재분류 대상에서 제외하고 원위치 유지. - Topics/Topic_email(상위 보호 폴더 Topic_email과 파일명 100% 중복) 삭제 — 보호 폴더 자체는 미변경. - 완전히 비게 된 Topic_Agent/Topic_Blog/Topics_Biz/Topics_Rag 폴더 제거.
This commit is contained in:
@@ -0,0 +1,198 @@
|
||||
---
|
||||
id: wiki-2026-0508-architecture-refactor
|
||||
title: Architecture Refactor
|
||||
category: 10_Wiki/Topics
|
||||
status: verified
|
||||
canonical_id: self
|
||||
aliases: [strangler-fig, big-bang-rewrite, modernization]
|
||||
duplicate_of: none
|
||||
source_trust_level: A
|
||||
confidence_score: 0.9
|
||||
verification_status: applied
|
||||
tags: [architecture, refactor, strangler-fig, modernization]
|
||||
raw_sources: []
|
||||
last_reinforced: 2026-05-10
|
||||
github_commit: pending
|
||||
tech_stack:
|
||||
language: polyglot
|
||||
framework: strangler-fig
|
||||
---
|
||||
|
||||
# Architecture Refactor
|
||||
|
||||
## 매 한 줄
|
||||
> **"매 incremental 의 always wins"**. 매 architecture refactor 의 default approach 의 Martin Fowler 의 Strangler Fig (2004) — 매 old system 의 around 의 new system 의 gradual 의 grow. 매 big-bang rewrite 의 historically failure rate >70% (Ousterhout, Brooks). 매 2026 의 typical pattern: 매 monolith → modular monolith → selective service extraction.
|
||||
|
||||
## 매 핵심
|
||||
|
||||
### 매 refactor strategies
|
||||
- **Strangler Fig**: 매 facade 의 routing — 매 traffic 의 incrementally 의 new system 의 redirect.
|
||||
- **Branch by Abstraction**: 매 abstraction layer 의 introduce — 매 dual 의 implementation — 매 old 의 remove.
|
||||
- **Parallel Run**: 매 old + new 의 동시 실행 — 매 output 의 compare.
|
||||
- **Big Bang Rewrite**: 매 last resort — 매 only 매 system 의 small + scope 의 frozen 의 가능.
|
||||
|
||||
### 매 refactor 의 prerequisite
|
||||
- **Test coverage**: 매 characterization tests (Feathers) 의 minimum.
|
||||
- **Observability**: 매 metrics + traces 의 before/after diff.
|
||||
- **Feature flag**: 매 reversibility 의 prerequisite.
|
||||
- **ADR**: 매 decision rationale 의 documented.
|
||||
|
||||
### 매 응용
|
||||
1. Monolith → modular monolith — 매 module boundary 의 enforce (ArchUnit).
|
||||
2. Service extraction — 매 bounded context 의 따라.
|
||||
3. Database split — 매 most expensive — 매 last 의 do.
|
||||
4. Framework upgrade — 매 incremental migration.
|
||||
|
||||
## 💻 패턴
|
||||
|
||||
### Strangler Fig — Nginx routing facade
|
||||
```nginx
|
||||
upstream legacy { server legacy.internal:8080; }
|
||||
upstream new { server new.internal:8080; }
|
||||
|
||||
server {
|
||||
listen 443 ssl;
|
||||
|
||||
# New endpoints — gradual rollout
|
||||
location /api/v2/orders { proxy_pass http://new; }
|
||||
location /api/v2/users { proxy_pass http://new; }
|
||||
|
||||
# Everything else still legacy
|
||||
location / { proxy_pass http://legacy; }
|
||||
}
|
||||
```
|
||||
|
||||
### Branch by Abstraction (Java)
|
||||
```java
|
||||
// Step 1 — extract interface
|
||||
interface PaymentGateway {
|
||||
Receipt charge(Order o);
|
||||
}
|
||||
|
||||
// Step 2 — wrap legacy
|
||||
class LegacyStripeGateway implements PaymentGateway { /* ... */ }
|
||||
|
||||
// Step 3 — new impl behind flag
|
||||
class AdyenGateway implements PaymentGateway { /* ... */ }
|
||||
|
||||
// Step 4 — feature-flag pick
|
||||
class GatewayFactory {
|
||||
PaymentGateway pick(String tenant) {
|
||||
return flags.isOn("adyen", tenant)
|
||||
? new AdyenGateway()
|
||||
: new LegacyStripeGateway();
|
||||
}
|
||||
}
|
||||
// Step 5 — once 100% rollout, delete LegacyStripeGateway
|
||||
```
|
||||
|
||||
### Parallel Run (shadow traffic)
|
||||
```ts
|
||||
async function chargeShadow(order: Order): Promise<Receipt> {
|
||||
const [primary, shadow] = await Promise.allSettled([
|
||||
legacy.charge(order),
|
||||
newImpl.charge(order) // never persists, just observes
|
||||
]);
|
||||
if (shadow.status === 'fulfilled' && primary.status === 'fulfilled') {
|
||||
diff.record('charge', primary.value, shadow.value);
|
||||
}
|
||||
return primary.status === 'fulfilled' ? primary.value : Promise.reject(primary.reason);
|
||||
}
|
||||
```
|
||||
|
||||
### Database Strangling — dual write + read switch
|
||||
```python
|
||||
# Phase 1: dual write
|
||||
def save_order(o: Order):
|
||||
legacy_db.insert(o)
|
||||
try:
|
||||
new_db.insert(o)
|
||||
except Exception as e:
|
||||
log.warn("shadow write failed", e=e)
|
||||
|
||||
# Phase 2: dual read + diff
|
||||
def get_order(id: str):
|
||||
a = legacy_db.get(id)
|
||||
b = new_db.get(id)
|
||||
if a != b: metrics.increment("order.read.diverge")
|
||||
return a # legacy still source of truth
|
||||
|
||||
# Phase 3: flip read source
|
||||
def get_order(id: str):
|
||||
return new_db.get(id)
|
||||
|
||||
# Phase 4: stop legacy write, decommission
|
||||
```
|
||||
|
||||
### Module extraction (modular monolith → service)
|
||||
```bash
|
||||
# 1. Codify module boundary first (ArchUnit)
|
||||
# 2. Replace direct calls with in-process interface
|
||||
# 3. Add feature flag: in-process vs HTTP/gRPC
|
||||
# 4. Deploy as separate process behind flag
|
||||
# 5. Remove in-process path
|
||||
```
|
||||
|
||||
### Characterization test (Feathers)
|
||||
```python
|
||||
import json, pytest
|
||||
|
||||
@pytest.mark.parametrize("fixture", load_fixtures("legacy_outputs/*.json"))
|
||||
def test_legacy_behavior_preserved(fixture):
|
||||
inputs = fixture["input"]
|
||||
expected = fixture["legacy_output"]
|
||||
actual = new_impl.run(**inputs)
|
||||
assert actual == expected, f"divergence: {fixture['id']}"
|
||||
```
|
||||
|
||||
### Refactor scoreboard (CI)
|
||||
```yaml
|
||||
# refactor-progress.yml — auto-generated dashboard
|
||||
metrics:
|
||||
- name: legacy-endpoints-remaining
|
||||
cmd: grep -r "@legacy" src/ | wc -l
|
||||
- name: new-coverage
|
||||
cmd: jacoco --module=new-impl
|
||||
- name: traffic-on-new
|
||||
promql: sum(rate(http_requests_total{service="new"}[5m]))
|
||||
/ sum(rate(http_requests_total[5m]))
|
||||
```
|
||||
|
||||
## 매 결정 기준
|
||||
| 상황 | Strategy |
|
||||
|---|---|
|
||||
| Active legacy + traffic | Strangler Fig |
|
||||
| Library/abstraction swap | Branch by Abstraction |
|
||||
| Risk-critical (payment, billing) | Parallel Run |
|
||||
| DB schema change | Dual-write + flip read |
|
||||
| Tiny system, frozen scope | Big Bang (rare) |
|
||||
| Distributed monolith | Reverse first → modular monolith → extract |
|
||||
|
||||
**기본값**: Strangler Fig + feature flag + parallel-run on critical paths.
|
||||
|
||||
## 🔗 Graph
|
||||
- 부모: [[Software Architecture]] · [[Refactoring_Best_Practices|Refactoring]]
|
||||
- 변형: [[Strangler-Fig]] · [[Branch-by-Abstraction]]
|
||||
- 응용: [[Modular Monolith]] · [[Microservices]]
|
||||
- Adjacent: [[Architecture Erosion (아키텍처 침식)]] · [[Architectural-Constraint-Enforcement]] · [[Architecture Review (아키텍처 및 설계 리뷰)]]
|
||||
|
||||
## 🤖 LLM 활용
|
||||
**언제**: 매 legacy code → modern equivalent translation, 매 codemod plan generation, 매 ADR draft.
|
||||
**언제 X**: 매 production cutover decision — 매 human + traffic data 의 필수.
|
||||
|
||||
## ❌ 안티패턴
|
||||
- **Big bang rewrite**: 매 70%+ failure rate — 매 last resort.
|
||||
- **Refactor without tests**: 매 silent regression 의 guarantee.
|
||||
- **No flag, no rollback**: 매 forward-only deploy — 매 incident magnification.
|
||||
- **Premature service extraction**: 매 distributed monolith 의 worst-of-both.
|
||||
- **Stop midway**: 매 두 system 의 forever maintain — 매 cost 의 doubled.
|
||||
|
||||
## 🧪 검증 / 중복
|
||||
- Verified (Fowler — *StranglerFigApplication*; Feathers — *Working Effectively with Legacy Code*; Newman — *Monolith to Microservices*).
|
||||
- 신뢰도 A.
|
||||
|
||||
## 🕓 Changelog
|
||||
| 날짜 | 변경 |
|
||||
|---|---|
|
||||
| 2026-05-08 | Phase 1 |
|
||||
| 2026-05-10 | Manual cleanup — Strangler Fig + Branch-by-Abstraction + parallel-run patterns |
|
||||
Reference in New Issue
Block a user