빠른 참조

React 및 Next.js 아키텍처 계층과 엔지니어링 결정 치트시트 (UI 라이브러리 vs 풀스택 프레임워크 vs BFF)

최신 웹 5계층 아키텍처 완벽 가이드: 브라우저 런타임, React UI 추상화 계층, Next.js 풀스택 프레임워크, API/BFF 서비스 오케스트레이션, 백엔드 도메인 데이터 계층의 명확한 경계와 기술 선택 기준.

· 게시일 · 수정일

React, Next.js, Node.js를 동일한 기술 계층으로 취급하지 마세요. React는 선언적 UI 라이브러리이고, Next.js는 서버와 엣지에서 실행되는 풀스택 애플리케이션 프레임워크이며, Node.js는 서버 실행을 지원하는 비동기 런타임 엔진입니다.

🔗 관련 치트시트: React.js 기본 · React Router · Node.js 핵심 모듈 · Node.js 패키지 공급망


1. 모던 웹 풀스택 5계층 아키텍처 토폴로지

브라우저 사용자 인터랙션부터 데이터베이스의 ACID 트랜잭션 지속성까지 현대 웹 엔지니어링은 5개의 계층을 통해 동작합니다:

flowchart TD
    subgraph Client ["Client Runtime"]
        L1["① Browser Runtime (Client)<br>HTML / CSS / DOM / Web APIs / Cookies & Storage"]
        L2["② React UI Abstraction (UI Library)<br>Components / State / Props / Virtual DOM & Hooks"]
    end

    subgraph Edge_Server ["Server & Edge Runtime"]
        L3["③ Next.js App Layer (Full-stack Framework)<br>App Router / RSC / SSR·SSG·ISR / Turbopack"]
        L4["④ API / BFF Layer (Service Orchestration)<br>Microservice Aggregation / Auth / Rate Limiting / Tailored Contracts"]
    end

    subgraph Backend ["Core Backend & Storage"]
        L5["⑤ Domain Services & DB (Core Backend)<br>Go / Java Core Services / PostgreSQL / Redis / S3 / Kafka"]
    end

    L1 <-->|"DOM Events / Rerender"| L2
    L2 <-->|"RSC Streaming / Hydration"| L3
    L3 <-->|"Server Actions / HTTP / gRPC"| L4
    L4 <-->|"Internal RPC / Microservices"| L5

    classDef client fill:#e8f4fd,stroke:#1d70b8,stroke-width:1px,color:#0b0c0c;
    classDef server fill:#f3f0ff,stroke:#6e40c9,stroke-width:1px,color:#0b0c0c;
    classDef backend fill:#fef3c7,stroke:#d97706,stroke-width:1px,color:#0b0c0c;
    class L1,L2 client;
    class L3,L4 server;
    class L5 backend;
Architectural Layer Core Positioning & Responsibility Representative Technologies Key Benefits Engineering Trade-offs & Cost
① Browser Layer
(Client)
Provides HTML/CSS/JS execution sandbox; handles pixel rasterization, gestures, Cookie/IndexedDB storage and network requests Chrome, Safari, WebKit, V8 Engine Ultimate user experience anchor; instant UI response Constrained by varied client hardware and network bandwidth
② React UI Layer
(UI Scheme)
Declarative state-to-view mapping; manages component tree lifecycle, Hooks, state dispatching and synthetic events React 19, JSX/TSX, React DOM Unmatched flexibility, concise mental model, vast component ecosystem Focuses only on UI; does not provide routing, data fetching, or build tooling
③ Next.js App Layer
(Full-stack)
Turns React into a production application: file-system routing, Server Components (RSC), hybrid rendering (SSR/SSG/ISR), build optimization and deployment adaptation Next.js 14/15, Turbopack, App Router Out-of-the-box performance, near-zero TTFB, superior SEO, automatic code splitting Strict opinionated conventions, steeper learning curve, dual runtime boundaries
④ API / BFF Layer
(Orchestration)
Service orchestration: shields microservice complexity, aggregates multi-service endpoints, validates auth, rate limits, and shapes tailored DTOs Next.js Route Handlers, NestJS, Hono, Fastify Decouples frontend and backend; cuts round-trips; shields internal microservice churn Extra network hop; requires maintaining API contracts
⑤ Domain & Storage
(Core Backend)
Domain modeling, ACID transactions, long-lived business systems, and high-throughput concurrent pipelines Go, Java (Spring), PostgreSQL, Redis, Kafka Extreme throughput, strong ACID guarantees, multi-region disaster recovery Longer development lifecycle; more deliberate deployment cadences

2. 기반 기술: 프로그래밍 언어 대 런타임 엔진

Behind the five architectural layers lies a unified language and asynchronous runtime foundation:

flowchart LR
    A["JavaScript / TypeScript<br><b>Language Layer</b><br>(Full-stack Types & Syntax)"] --> B["Node.js / Bun / Edge<br><b>Runtime Engine</b><br>(Non-blocking I/O & Networking)"]
    B --> C["Next.js / BFF Framework<br><b>Application Layer</b><br>(Serverless & Containers)"]

    classDef base fill:#f6f8fa,stroke:#d0d7de,stroke-width:1px,color:#24292f;
    class A,B,C base;
  • JavaScript / TypeScript (Language): Unifies syntax across client and server, enabling end-to-end type sharing for DTOs and API contracts.
  • Node.js / Edge Runtime (Runtime Engine): Provides non-blocking I/O, file access, and HTTP sockets to power Next.js SSR, Route Handlers, and BFF services.

3. React vs Next.js: 핵심 차원별 심층 비교

The core distinctions between React and Next.js at a glance:

Dimension React (UI Library) Next.js (Full-stack Framework)
Product Positioning Declarative UI rendering library Enterprise-grade full-stack Web application framework
Built-in Routing ❌ None (requires React Router or TanStack Router) Built-in (File-system based App Router / Pages Router)
Execution Environment Client browser only (traditional SPA mode) Dual Environment (Server Node/Edge + Client Browser)
Rendering Paradigms Client-Side Rendering (CSR) only Hybrid: RSC, SSR, SSG, ISR, and Streaming SSR
Data Fetching useEffect(), fetch(), SWR, TanStack Query Server async/await direct DB access, Server Actions, Route Handlers
SEO & Initial Paint Weak (initial HTML is blank <div id="root">) Superior (pre-rendered semantic HTML delivered from server)
Build Tooling Requires manual bundler setup (Vite, Webpack) Out-of-the-box Turbopack / Webpack with SWC compiler
Bundle Optimization Manual React.lazy() dynamic imports Automatic route splitting, optimized <Image /> and font loaders

4. Next.js 경계: Server Components vs Client Components

App Router enforces an explicit boundary between Server Components and Client Components to minimize bundle size:

flowchart TD
    Page["Page Entry (Page / Layout)<br><b>Default: Server Component (Server)</b>"] --> SC["Data Fetching & Static Content<br>(Direct DB Access / Private Keys / Zero Bundle)"]
    Page --> CC["Interactive UI ('use client')<br>(Runs in Browser / Rehydrates State)"]
    
    CC --> Hook["State & Browser Events<br>useState / useEffect / onClick"]
    SC --> DB["Server Resources<br>Direct DB query / fs / process.env"]

    classDef sc fill:#e1f5fe,stroke:#0288d1,stroke-width:1px,color:#01579b;
    classDef cc fill:#fff3e0,stroke:#f57c00,stroke-width:1px,color:#e65100;
    class Page,SC sc;
    class CC,Hook cc;
    class DB sc;
Requirement / Use Case Component Type Declaration & Architecture Notes
Direct DB access, backend file system access, private API keys Server Component Default behavior; code contributes 0 KB to client bundle
Heavy dependencies (e.g. Markdown parsers, syntax highlighters) Server Component Executed purely on the server; client receives only rendered HTML
Browser event listeners (onClick, onChange, onSubmit) Client Component Must declare 'use client' at the very top of the file
React state & lifecycle hooks (useState, useEffect, custom hooks) Client Component Must declare 'use client'; state managed in client memory
Browser-only APIs (window, localStorage, navigator) Client Component Must declare 'use client' and access APIs inside useEffect or callbacks

5. 최신 렌더링 방식 비교 매트릭스 (CSR / SSR / SSG / ISR / Streaming)

Rendering Mode When & Where Render Occurs Ideal Scenarios Key Advantages Trade-offs & Challenges
CSR
(Client-Side)
Browser executes JS to build DOM client-side Admin dashboards, SaaS tools, private user portals Zero server CPU load, seamless app transitions Blank initial paint, poor SEO without pre-rendering
SSG
(Static Site Gen)
Generated once at build time on server Documentation, blogs, marketing landing pages Maximum speed (cached on global CDN edge), high stability Content updates require triggering a full rebuild
SSR
(Server-Side)
Generated dynamically on each request on server User profile pages, dynamic feeds, time-sensitive news High SEO ranking, immediate visible content Increases server CPU load, TTFB dependent on backend latency
ISR
(Incremental)
Built statically, revalidated in background on timer E-commerce product catalogs, discussion forums Combines CDN speed with dynamic data updates Brief window of stale data during background revalidation
Streaming SSR
(Streaming)
HTML streamed in chunks via HTTP with React Suspense Complex e-commerce homepages (slow blocks don't block viewport) Instant initial paint, skeletal loading, progressive hydration Requires sophisticated Suspense boundaries and state design

6. API / BFF 계층을 도입해야 하는 시점과 기준

Not every application requires a dedicated BFF. Align your architecture with organizational and system scale:

flowchart LR
    A{System Scale & Complexity} -->|Lean Team / Single Database| B["Pattern A: Next.js Direct Full-Stack<br>Server Actions + Route Handlers<br>(Lean team, fastest velocity)"]
    A -->|Multi-client / Dense Microservices| C["Pattern B: Independent BFF Orchestration<br>Tailored API for Web / Mobile Apps<br>(Shields microservices, decouples releases)"]

    classDef opt fill:#f8fafc,stroke:#64748b,stroke-width:1px,color:#1e293b;
    class B,C opt;

6.1 Direct Next.js Full-Stack Pattern (No Separate BFF)

  • Early-stage startups or small to mid-sized teams delivering web-first products;
  • Simplified data layer where Server Actions query PostgreSQL/MySQL directly via Prisma or Drizzle;
  • Full-stack engineers owning features end-to-end; extra layers introduce unnecessary overhead.
  • High microservice density: Pages require data from 5+ backend services (Catalog, Pricing, Inventory, Auth, Recommendations). The BFF aggregates these over high-speed internal networks in a single round trip;
  • Multi-client ecosystems (Web + iOS + Android + Mini-programs): Different clients need distinct image sizes, field masks, and auth flows;
  • Cross-team anti-corruption layer: Frontend teams control the BFF layer, shipping UI optimizations without waiting for backend sprint schedules.

관련 주제