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,191 @@
|
||||
---
|
||||
id: wiki-2026-0508-철벽-수비대-인터페이스-설계-전략
|
||||
title: 철벽 수비대 인터페이스 설계 전략
|
||||
category: 10_Wiki/Topics
|
||||
status: verified
|
||||
canonical_id: self
|
||||
aliases: [Defensive UI, Resilient Frontend Design, Hardened Interface]
|
||||
duplicate_of: none
|
||||
source_trust_level: A
|
||||
confidence_score: 0.9
|
||||
verification_status: applied
|
||||
tags: [frontend, ui-design, resilience, defensive-programming]
|
||||
raw_sources: []
|
||||
last_reinforced: 2026-05-10
|
||||
github_commit: pending
|
||||
tech_stack:
|
||||
language: typescript
|
||||
framework: react
|
||||
---
|
||||
|
||||
# 철벽 수비대 인터페이스 설계 전략
|
||||
|
||||
## 매 한 줄
|
||||
> **"매 UI 는 매 적대적 입력 / 네트워크 실패 / 동시 변경 의 환경에서 매 buckle 없이 동작해야 한다"**. 매 철벽 수비대 (Hardened UI) 는 invalid props, race conditions, 부분 실패, hostile users 를 매 graceful 한 fallback 으로 처리하는 설계 철학. 매 2026 modern stack — React 19 Server Components + Suspense + Error Boundaries — 가 매 native 한 defensive primitives 를 제공.
|
||||
|
||||
## 매 핵심
|
||||
|
||||
### 매 위협 모델
|
||||
- **Bad data**: API 가 매 schema 위반 (null, missing field, wrong type).
|
||||
- **Bad timing**: race conditions — 매 stale closure, 매 out-of-order responses.
|
||||
- **Bad network**: timeouts, partial failures, retries.
|
||||
- **Bad users**: XSS payloads, paste 공격, 매 keyboard shortcut 남용.
|
||||
- **Bad state**: 매 corrupted localStorage, 매 stale cache.
|
||||
|
||||
### 매 방어 layer
|
||||
- **Schema layer**: Zod / Valibot 로 매 runtime validation.
|
||||
- **Boundary layer**: Error Boundary + Suspense.
|
||||
- **Retry layer**: TanStack Query / SWR 가 매 exponential backoff.
|
||||
- **Sanitization layer**: DOMPurify, CSP nonce.
|
||||
- **Fallback layer**: Skeleton, empty state, error state.
|
||||
|
||||
### 매 응용
|
||||
1. Banking / fintech — 매 transactional UI 에서 매 double-submit 방지.
|
||||
2. Healthcare records — 매 stale data 보다 매 명시적 error 우선.
|
||||
3. Live collaboration — 매 conflict resolution UI.
|
||||
|
||||
## 💻 패턴
|
||||
|
||||
### Zod schema-first parsing
|
||||
```typescript
|
||||
import { z } from "zod";
|
||||
|
||||
const UserSchema = z.object({
|
||||
id: z.string().uuid(),
|
||||
email: z.string().email(),
|
||||
age: z.number().int().min(0).max(150),
|
||||
});
|
||||
|
||||
async function fetchUser(id: string) {
|
||||
const res = await fetch(`/api/users/${id}`);
|
||||
if (!res.ok) throw new Error(`HTTP ${res.status}`);
|
||||
// 매 parse — 매 invalid data 면 throw, downstream 은 매 typed safe
|
||||
return UserSchema.parse(await res.json());
|
||||
}
|
||||
```
|
||||
|
||||
### Error Boundary + retry
|
||||
```tsx
|
||||
import { ErrorBoundary } from "react-error-boundary";
|
||||
|
||||
function UserView() {
|
||||
return (
|
||||
<ErrorBoundary
|
||||
FallbackComponent={({ error, resetErrorBoundary }) => (
|
||||
<div role="alert">
|
||||
<p>문제 발생: {error.message}</p>
|
||||
<button onClick={resetErrorBoundary}>재시도</button>
|
||||
</div>
|
||||
)}
|
||||
onReset={() => queryClient.invalidateQueries(["user"])}
|
||||
>
|
||||
<Suspense fallback={<UserSkeleton />}>
|
||||
<UserDetail />
|
||||
</Suspense>
|
||||
</ErrorBoundary>
|
||||
);
|
||||
}
|
||||
```
|
||||
|
||||
### Stale closure 방지 (useEffectEvent)
|
||||
```tsx
|
||||
import { useEffectEvent } from "react";
|
||||
|
||||
function ChatRoom({ roomId, onMessage }) {
|
||||
const handleMessage = useEffectEvent((msg) => {
|
||||
onMessage(msg, roomId);
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
const conn = connect(roomId);
|
||||
conn.on("message", handleMessage);
|
||||
return () => conn.disconnect();
|
||||
}, [roomId]); // 매 onMessage 가 매 deps 안 — 매 stale 없음
|
||||
}
|
||||
```
|
||||
|
||||
### Race-condition-safe fetching
|
||||
```typescript
|
||||
useEffect(() => {
|
||||
let cancelled = false;
|
||||
fetch(`/api/search?q=${query}`)
|
||||
.then(r => r.json())
|
||||
.then(data => { if (!cancelled) setResults(data); });
|
||||
return () => { cancelled = true; };
|
||||
}, [query]);
|
||||
```
|
||||
|
||||
### XSS-safe rich text
|
||||
```tsx
|
||||
import DOMPurify from "isomorphic-dompurify";
|
||||
|
||||
function RichText({ html }: { html: string }) {
|
||||
const clean = DOMPurify.sanitize(html, { USE_PROFILES: { html: true } });
|
||||
return <div dangerouslySetInnerHTML={{ __html: clean }} />;
|
||||
}
|
||||
```
|
||||
|
||||
### Optimistic update + rollback
|
||||
```tsx
|
||||
const mutation = useMutation({
|
||||
mutationFn: updateTodo,
|
||||
onMutate: async (newTodo) => {
|
||||
await queryClient.cancelQueries(["todos"]);
|
||||
const prev = queryClient.getQueryData(["todos"]);
|
||||
queryClient.setQueryData(["todos"], (old) =>
|
||||
old.map(t => t.id === newTodo.id ? newTodo : t)
|
||||
);
|
||||
return { prev };
|
||||
},
|
||||
onError: (_err, _new, ctx) => {
|
||||
queryClient.setQueryData(["todos"], ctx.prev); // 매 rollback
|
||||
},
|
||||
onSettled: () => queryClient.invalidateQueries(["todos"]),
|
||||
});
|
||||
```
|
||||
|
||||
### Idempotent submit (double-click 방지)
|
||||
```tsx
|
||||
const [pending, startTransition] = useTransition();
|
||||
const submit = (e) => {
|
||||
e.preventDefault();
|
||||
if (pending) return;
|
||||
startTransition(() => mutation.mutate(formData));
|
||||
};
|
||||
```
|
||||
|
||||
## 매 결정 기준
|
||||
| 상황 | Approach |
|
||||
|---|---|
|
||||
| External API 응답 | Zod validation 필수 |
|
||||
| Component tree crash 위험 | ErrorBoundary 감싸기 |
|
||||
| Async race | AbortController + cleanup |
|
||||
| User-generated HTML | DOMPurify sanitize |
|
||||
| Critical mutation (payment) | Idempotency key + disable button |
|
||||
|
||||
**기본값**: Zod + ErrorBoundary + TanStack Query + DOMPurify 의 layered defense.
|
||||
|
||||
## 🔗 Graph
|
||||
- 부모: [[Large_Frontend_Projects|Frontend Architecture]]
|
||||
- 변형: [[Error Boundary]] · [[Optimistic UI]]
|
||||
- Adjacent: [[CSP]]
|
||||
|
||||
## 🤖 LLM 활용
|
||||
**언제**: 매 production-grade UI, 매 finance / healthcare, 매 untrusted user input 처리.
|
||||
**언제 X**: 매 internal prototype, 매 trusted data only.
|
||||
|
||||
## ❌ 안티패턴
|
||||
- **Trust API blindly**: 매 schema 검증 없이 destructuring → runtime crash.
|
||||
- **Catch and ignore**: `try { ... } catch {}` — 매 silent failure.
|
||||
- **dangerouslySetInnerHTML 직접**: 매 sanitize 없이 → XSS.
|
||||
- **Stale closure**: 매 useEffect deps 누락 → 매 outdated state.
|
||||
|
||||
## 🧪 검증 / 중복
|
||||
- Verified (React 19 docs, OWASP, Kent C. Dodds: "Use react-error-boundary").
|
||||
- 신뢰도 A.
|
||||
|
||||
## 🕓 Changelog
|
||||
| 날짜 | 변경 |
|
||||
|---|---|
|
||||
| 2026-05-08 | Phase 1 |
|
||||
| 2026-05-10 | Manual cleanup — defensive UI 7 patterns |
|
||||
Reference in New Issue
Block a user