refactor(topics): 멀티 에이전트용 지식 재편 — _Common(공통 기본기) + Domain_* 구조
에이전트 8종(대화형/프로그래머 C·S/디자이너/설계자/기획자/QA/PD/PM)에게 [공통 기본 능력 + 롤별 Specialty] 2층으로 지식을 주입하기 위한 재분류. 문서 내용·포맷은 무수정, 폴더 이동만 (6,372개 문서 수 보존 확인). - Topic_Programming → Domain_Programming (내부 구조 보존) - Topic_Graphic → Domain_Design - Topic_Business → Domain_Product - Topic_General → Domain_General - _Common 신설: Math(구 Topic_Math_Specialty), Reasoning(구 General/From_Thinking & Reasoning), Reasoning_Creativity(구 General/From_창의성), Communication(Poetic_Blog_Writing + From_writing) - 타 도메인의 From_* 폴더는 유지 (출처 표기일 뿐, 이미 도메인에 맞게 분류된 문서) - 빈 폴더 정리 (memory/procedures) - 에이전트→폴더 매핑은 workspace의 .astra/agent-knowledge-map.json (9개 에이전트) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,188 @@
|
||||
---
|
||||
id: wiki-2026-0508-프론트엔드-컴포넌트-구조화
|
||||
title: 프론트엔드 컴포넌트 구조화
|
||||
category: 10_Wiki/Topics
|
||||
status: verified
|
||||
canonical_id: self
|
||||
aliases: [Frontend Component Structure, Component Organization]
|
||||
duplicate_of: none
|
||||
source_trust_level: A
|
||||
confidence_score: 0.9
|
||||
verification_status: applied
|
||||
tags: [frontend, react, architecture, component-design]
|
||||
raw_sources: []
|
||||
last_reinforced: 2026-05-10
|
||||
github_commit: pending
|
||||
tech_stack:
|
||||
language: typescript
|
||||
framework: react-19/next-15
|
||||
---
|
||||
|
||||
# 프론트엔드 컴포넌트 구조화
|
||||
|
||||
## 매 한 줄
|
||||
> **"매 component 의 size, scope, composition 의 systematic decomposition"**. 매 atomic design (atom→molecule→organism), feature-based (colocation), compound component, headless UI 의 4-axis. 매 2026 의 default — feature-folder + headless primitives (Radix/Ark) + Server Components.
|
||||
|
||||
## 매 핵심
|
||||
|
||||
### 매 4 가지 axis
|
||||
1. **Size**: atom · molecule · organism · template · page (Atomic Design).
|
||||
2. **Scope**: feature-local vs shared / design system.
|
||||
3. **Composition**: leaf vs container vs compound vs headless.
|
||||
4. **Boundary**: Server Component vs Client Component (RSC).
|
||||
|
||||
### 매 file/folder strategy
|
||||
- **Co-location**: `components/Button/{index.tsx, Button.css, Button.test.tsx, Button.stories.tsx}`.
|
||||
- **Feature folder**: `features/checkout/{components, hooks, api, types}` — feature 의 self-contained.
|
||||
- **Shared design system**: `packages/ui` — monorepo + workspace.
|
||||
|
||||
### 매 응용
|
||||
1. Component library / design system 구축.
|
||||
2. Large app 의 modular feature decomposition.
|
||||
3. Server Components 의 server/client boundary 결정.
|
||||
|
||||
## 💻 패턴
|
||||
|
||||
### 1. Atomic Design folder
|
||||
```
|
||||
src/components/
|
||||
atoms/ Button, Input, Icon
|
||||
molecules/ SearchBar, FormField
|
||||
organisms/ Header, ProductCard
|
||||
templates/ CheckoutLayout
|
||||
```
|
||||
|
||||
### 2. Feature-based folder (recommended 2026)
|
||||
```
|
||||
src/features/checkout/
|
||||
components/CheckoutForm.tsx
|
||||
hooks/useCheckout.ts
|
||||
api/createOrder.ts
|
||||
schemas/order.ts
|
||||
index.ts // public API
|
||||
```
|
||||
|
||||
### 3. Compound component
|
||||
```tsx
|
||||
function Tabs({ children, defaultValue }: Props) {
|
||||
const [value, setValue] = useState(defaultValue);
|
||||
return <TabsContext.Provider value={{ value, setValue }}>{children}</TabsContext.Provider>;
|
||||
}
|
||||
Tabs.List = TabsList;
|
||||
Tabs.Trigger = TabsTrigger;
|
||||
Tabs.Content = TabsContent;
|
||||
|
||||
// Usage:
|
||||
<Tabs defaultValue="a">
|
||||
<Tabs.List><Tabs.Trigger value="a">A</Tabs.Trigger></Tabs.List>
|
||||
<Tabs.Content value="a">...</Tabs.Content>
|
||||
</Tabs>
|
||||
```
|
||||
|
||||
### 4. Headless component (Radix-style)
|
||||
```tsx
|
||||
function useDisclosure() {
|
||||
const [open, setOpen] = useState(false);
|
||||
return { open, toggle: () => setOpen(o => !o), close: () => setOpen(false) };
|
||||
}
|
||||
|
||||
// Consumer styles freely
|
||||
function MyDialog() {
|
||||
const d = useDisclosure();
|
||||
return <div className="my-styles">{d.open && '...'}</div>;
|
||||
}
|
||||
```
|
||||
|
||||
### 5. Server / Client boundary (Next.js 15)
|
||||
```tsx
|
||||
// app/products/page.tsx (Server Component — default)
|
||||
import { ProductList } from './ProductList';
|
||||
import { db } from '@/db';
|
||||
|
||||
export default async function Page() {
|
||||
const products = await db.product.findMany();
|
||||
return <ProductList products={products} />;
|
||||
}
|
||||
|
||||
// app/products/AddToCart.tsx
|
||||
'use client';
|
||||
export function AddToCart({ id }: { id: string }) {
|
||||
return <button onClick={() => addToCart(id)}>Add</button>;
|
||||
}
|
||||
```
|
||||
|
||||
### 6. Polymorphic component (`as` prop)
|
||||
```tsx
|
||||
type BoxProps<T extends React.ElementType> = {
|
||||
as?: T;
|
||||
} & React.ComponentPropsWithoutRef<T>;
|
||||
|
||||
function Box<T extends React.ElementType = 'div'>({ as, ...rest }: BoxProps<T>) {
|
||||
const Tag = as || 'div';
|
||||
return <Tag {...rest} />;
|
||||
}
|
||||
|
||||
<Box as="a" href="/x">link</Box>;
|
||||
```
|
||||
|
||||
### 7. Container / Presentational split (when useful)
|
||||
```tsx
|
||||
// Container — data + logic
|
||||
function UserListContainer() {
|
||||
const { data } = useUsers();
|
||||
return <UserListView users={data} />;
|
||||
}
|
||||
|
||||
// Presentational — pure UI
|
||||
function UserListView({ users }: { users: User[] }) {
|
||||
return <ul>{users.map(u => <li key={u.id}>{u.name}</li>)}</ul>;
|
||||
}
|
||||
```
|
||||
|
||||
### 8. Public API barrel (`index.ts`)
|
||||
```typescript
|
||||
// features/checkout/index.ts
|
||||
export { CheckoutForm } from './components/CheckoutForm';
|
||||
export { useCheckout } from './hooks/useCheckout';
|
||||
export type { Order } from './schemas/order';
|
||||
// 매 internal 은 export X — encapsulation.
|
||||
```
|
||||
|
||||
## 매 결정 기준
|
||||
| 상황 | Approach |
|
||||
|---|---|
|
||||
| Design system | Atomic + headless (Radix/Ark) |
|
||||
| Product feature | Feature folder + co-location |
|
||||
| Multi-trigger UI (Tabs, Menu) | Compound component |
|
||||
| Style flexibility | Headless + custom CSS |
|
||||
| Next.js 15 app | Server-default, Client only when needed |
|
||||
| Reusable variant via tag | Polymorphic `as` |
|
||||
|
||||
**기본값**: 매 feature folder + 매 headless primitives (Radix/Ark) + 매 Server Components default.
|
||||
|
||||
## 🔗 Graph
|
||||
- 부모: [[Component-Composition|Component-Based Architecture]] · [[Large_Frontend_Projects|Frontend Architecture]]
|
||||
- 변형: [[Atomic Design]] · [[Component-Composition|Compound Components]] · [[Headless UI]] · [[Modern_Web_Rendering_and_Optimization|Server Components]]
|
||||
- 응용: [[Design System]] · [[Monorepo]]
|
||||
- Adjacent: [[Custom Hooks]] · [[Render_Props|Render Props]]
|
||||
|
||||
## 🤖 LLM 활용
|
||||
**언제**: 매 large app 의 component decomposition 결정 시. 매 server/client boundary planning 시.
|
||||
**언제 X**: 매 prototype / single-page demo — 매 over-structuring 의 X.
|
||||
|
||||
## ❌ 안티패턴
|
||||
- **God component**: 매 1000-line component — 매 split.
|
||||
- **Atomic Design 의 dogmatic 적용**: 매 feature 에는 feature folder 가 더 적합.
|
||||
- **'use client' 남발**: 매 root 에 client 선언 — 매 RSC benefit 상실.
|
||||
- **Container/Presentational 강요**: 매 hooks 시대에는 obsolete pattern.
|
||||
- **Barrel re-export 의 deep nesting**: 매 bundler tree-shaking 방해.
|
||||
|
||||
## 🧪 검증 / 중복
|
||||
- Verified (React docs, Next.js 15 docs, Radix UI / Ark UI patterns).
|
||||
- 신뢰도 A.
|
||||
|
||||
## 🕓 Changelog
|
||||
| 날짜 | 변경 |
|
||||
|---|---|
|
||||
| 2026-05-08 | Phase 1 |
|
||||
| 2026-05-10 | Manual cleanup — 4-axis decomposition + 8 patterns + RSC boundary |
|
||||
Reference in New Issue
Block a user