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,229 @@
|
||||
---
|
||||
id: wiki-2026-0508-modern-scalable-frontend-archite
|
||||
title: Modern Scalable Frontend Architecture
|
||||
category: 10_Wiki/Topics
|
||||
status: verified
|
||||
canonical_id: self
|
||||
aliases: [Frontend Architecture, Micro-frontends, RSC, Edge SSR, Islands]
|
||||
duplicate_of: none
|
||||
source_trust_level: A
|
||||
confidence_score: 0.9
|
||||
verification_status: applied
|
||||
tags: [frontend, architecture, micro-frontend, rsc, monorepo, edge]
|
||||
raw_sources: []
|
||||
last_reinforced: 2026-05-10
|
||||
github_commit: pending
|
||||
tech_stack: { language: typescript, framework: next-js }
|
||||
---
|
||||
|
||||
# Modern Scalable Frontend Architecture
|
||||
|
||||
## 매 한 줄
|
||||
|
||||
2026년 확장형 프론트엔드는 **monorepo + RSC + edge SSR + islands** 의 4축으로 정리되며, 거대 조직은 micro-frontend, 콘텐츠 사이트는 islands, 풀 앱은 RSC가 default다.
|
||||
|
||||
## 매 핵심
|
||||
|
||||
### 1. Monorepo (코드 공유 단위)
|
||||
|
||||
- **도구**: Turborepo, Nx, pnpm workspaces.
|
||||
- **구조**: `apps/` (배포 단위) + `packages/` (공유 라이브러리).
|
||||
- 핵심 가치: type-safe cross-package import, 단일 PR로 다중 앱 변경, 캐시된 빌드.
|
||||
|
||||
### 2. Micro-frontends (배포 분리)
|
||||
|
||||
- **Module Federation** (webpack/Vite): runtime 동적 로드.
|
||||
- **Single-SPA / Piral**: 라우팅 단위 통합.
|
||||
- **iframe + postMessage**: 강한 격리 (legacy 통합).
|
||||
- 적용: 100+ 개발자, 다중 팀, 다른 release cadence.
|
||||
- 트레이드오프: 번들 중복, 상태 공유 어려움 — 작은 조직에는 over-engineering.
|
||||
|
||||
### 3. RSC (React Server Components, Next.js 14+)
|
||||
|
||||
- 서버에서 렌더링 → 직렬화 → 클라이언트 hydration 없이 렌더.
|
||||
- DB·secret 직접 접근, JS 번들 0 (server-only 컴포넌트).
|
||||
- `"use client"` 경계로 클라이언트 컴포넌트 분리.
|
||||
- 2026 표준: Next.js App Router, Remix v2 (React Router 7).
|
||||
|
||||
### 4. Edge SSR
|
||||
|
||||
- Cloudflare Workers, Vercel Edge, Netlify Edge.
|
||||
- TTFB 50ms- (지리적으로 사용자 근처).
|
||||
- 제약: Node API 일부 미지원, V8 isolate 메모리 제한, cold start 거의 0.
|
||||
|
||||
### 5. Islands Architecture
|
||||
|
||||
- **Astro, Qwik, Fresh** — 정적 HTML + 선택적 hydration.
|
||||
- "interactive island"만 JS 로드 → JS 50-90% 감소.
|
||||
- 콘텐츠/마케팅/블로그/EC 카탈로그에 최적.
|
||||
|
||||
### 6. State / Data Layer
|
||||
|
||||
- **Server state**: TanStack Query, RSC fetch.
|
||||
- **Client state**: Zustand, Jotai (Redux는 거의 사라짐).
|
||||
- **Form**: react-hook-form + zod.
|
||||
- **Real-time**: Liveblocks, Convex, Supabase realtime.
|
||||
|
||||
### 7. 2026 Trend
|
||||
|
||||
- **Server actions** (Next.js): RPC 보일러플레이트 제거.
|
||||
- **Partial Prerendering** (PPR): 정적 + 동적 hybrid.
|
||||
- **Streaming SSR + Suspense**: TTFB ↓, 인지속도 ↑.
|
||||
- **TypeScript 5.5+ inferred types**: tRPC, Zod, Drizzle e2e type safety.
|
||||
- **AI agent UI**: streaming token UI, generative UI (RSC + structured output).
|
||||
|
||||
## 💻 패턴
|
||||
|
||||
```ts
|
||||
// 1. Turborepo turbo.json
|
||||
{
|
||||
"tasks": {
|
||||
"build": { "dependsOn": ["^build"], "outputs": [".next/**", "dist/**"] },
|
||||
"test": { "dependsOn": ["^build"] },
|
||||
"lint": {},
|
||||
"dev": { "cache": false, "persistent": true }
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
```tsx
|
||||
// 2. RSC — server component (Next.js App Router)
|
||||
// app/products/page.tsx
|
||||
import { db } from "@/lib/db";
|
||||
export default async function Page() {
|
||||
const products = await db.product.findMany(); // server-only
|
||||
return <ProductList products={products} />;
|
||||
}
|
||||
```
|
||||
|
||||
```tsx
|
||||
// 3. Client component boundary
|
||||
"use client";
|
||||
import { useState } from "react";
|
||||
export function AddToCart({ id }: { id: string }) {
|
||||
const [pending, setPending] = useState(false);
|
||||
return <button disabled={pending}>Add</button>;
|
||||
}
|
||||
```
|
||||
|
||||
```ts
|
||||
// 4. Module Federation (Vite plugin)
|
||||
import federation from "@originjs/vite-plugin-federation";
|
||||
export default {
|
||||
plugins: [federation({
|
||||
name: "shell",
|
||||
remotes: { checkout: "https://checkout.app/assets/remoteEntry.js" },
|
||||
shared: ["react", "react-dom"],
|
||||
})],
|
||||
};
|
||||
```
|
||||
|
||||
```tsx
|
||||
// 5. Astro island
|
||||
---
|
||||
import Counter from "../components/Counter.tsx";
|
||||
---
|
||||
<html>
|
||||
<body>
|
||||
<h1>Static content (no JS)</h1>
|
||||
<Counter client:visible /> <!-- hydrate when in viewport -->
|
||||
</body>
|
||||
</html>
|
||||
```
|
||||
|
||||
```ts
|
||||
// 6. Server action (Next.js)
|
||||
"use server";
|
||||
import { z } from "zod";
|
||||
const Schema = z.object({ email: z.string().email() });
|
||||
export async function subscribe(formData: FormData) {
|
||||
const { email } = Schema.parse(Object.fromEntries(formData));
|
||||
await db.newsletter.create({ data: { email } });
|
||||
}
|
||||
```
|
||||
|
||||
```ts
|
||||
// 7. Edge runtime
|
||||
export const runtime = "edge";
|
||||
export async function GET(req: Request) {
|
||||
const geo = req.headers.get("x-vercel-ip-country");
|
||||
return Response.json({ country: geo });
|
||||
}
|
||||
```
|
||||
|
||||
```tsx
|
||||
// 8. Streaming SSR with Suspense
|
||||
import { Suspense } from "react";
|
||||
export default function Page() {
|
||||
return (
|
||||
<>
|
||||
<Header />
|
||||
<Suspense fallback={<Skeleton />}>
|
||||
<SlowFeed />
|
||||
</Suspense>
|
||||
</>
|
||||
);
|
||||
}
|
||||
```
|
||||
|
||||
```ts
|
||||
// 9. TanStack Query — client cache
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
const { data } = useQuery({
|
||||
queryKey: ["user", id],
|
||||
queryFn: () => fetch(`/api/user/${id}`).then(r => r.json()),
|
||||
staleTime: 60_000,
|
||||
});
|
||||
```
|
||||
|
||||
```ts
|
||||
// 10. End-to-end type safety with tRPC
|
||||
// server
|
||||
export const appRouter = t.router({
|
||||
user: t.procedure.input(z.string()).query(({ input }) => db.user.find(input)),
|
||||
});
|
||||
// client
|
||||
const user = await trpc.user.query("123"); // 자동 타입
|
||||
```
|
||||
|
||||
## 매 결정 기준
|
||||
|
||||
| 상황 | 권장 아키텍처 |
|
||||
|------|--------------|
|
||||
| 마케팅/블로그/EC 카탈로그 | **Islands** (Astro) |
|
||||
| SaaS 풀 앱 (단일팀-중규모) | **Next.js RSC + Server Actions** |
|
||||
| 대조직 다팀 다배포 | **Module Federation micro-frontend** |
|
||||
| 글로벌 저지연 | **Edge SSR** (Vercel/Cloudflare) |
|
||||
| 실시간 협업 | **Convex / Liveblocks** + RSC |
|
||||
| 정적 + 동적 혼합 | **PPR (Partial Prerendering)** |
|
||||
| 모바일 우선 PWA | **Vite + Workbox** |
|
||||
|
||||
## 🔗 Graph
|
||||
|
||||
- 부모: [[Large_Frontend_Projects|Frontend Architecture]], [[Web Performance]]
|
||||
- 변형: [[Micro-Frontends]], [[Islands Architecture]], [[React Server Components — 경계 의식]]
|
||||
- 응용: [[Astro]], [[Qwik]], [[Edge Runtime]]
|
||||
- Adjacent: [[Monorepo]], [[Turborepo]], [[Module Federation]]
|
||||
|
||||
## 🤖 LLM 활용
|
||||
|
||||
- v0.dev / Bolt.new — RSC + shadcn 코드 생성.
|
||||
- "이 SPA를 RSC로 마이그레이션하는 단계별 계획" — 점진적 변환.
|
||||
- LLM이 component boundary (`"use client"`) 자동 추론.
|
||||
|
||||
## ❌ 안티패턴
|
||||
|
||||
- **소규모 팀의 micro-frontend**: 운영 비용 >> 이익.
|
||||
- **RSC 안에서 useState/useEffect**: 컴파일 에러 — boundary 누락.
|
||||
- **Edge에서 무거운 Node API 사용**: 런타임 실패.
|
||||
- **모든 컴포넌트 client**: RSC 이점 무화.
|
||||
- **큰 모놀리식 SPA + 무한 스크롤**: TTI > 5s — islands/SSR로.
|
||||
|
||||
## 🧪 검증 / 중복
|
||||
|
||||
- 검증: Next.js / Astro / Vercel docs, web.dev Core Web Vitals.
|
||||
- 중복: [[Next.js App Router]] (specific) — 본 문서는 architectural overview.
|
||||
|
||||
## 🕓 Changelog
|
||||
|
||||
- 2026-05-10: 신규 작성. Monorepo + RSC + Edge SSR + Islands 4축 + 2026 trend.
|
||||
Reference in New Issue
Block a user