OPEN HYPER STEP
← 목록으로 (stack-analysis)
STACK-ANALYSIS · 5 / 90
stack-analysis
CHAPTER 5 / 90
읽기 약 2
FUNCTION

React 프로젝트 구조: 폴더 아키텍처


핵심 개념

feature-based vs layer-based·barrel export·index.ts 패턴 — 50+ 컴포넌트 프로젝트.

본문

두 가지 폴더 구조 패턴

Layer-based (전통)

📋 코드 (15줄)
src/
├── components/
│   ├── Button.tsx
│   ├── Card.tsx
│   └── Modal.tsx
├── pages/
│   ├── HomePage.tsx
│   └── ProductPage.tsx
├── hooks/
├── utils/
├── types/
└── api/

장점: 단순, 시작 쉬움
단점: 50+ 컴포넌트 시 components/ 폭주

Feature-based (모던)

📋 코드 (18줄)
src/
├── features/
│   ├── auth/
│   │   ├── components/
│   │   ├── hooks/
│   │   ├── api/
│   │   ├── types.ts
│   │   └── index.ts
│   ├── products/
│   └── orders/
├── shared/
│   ├── ui/        (Button, Card 등)
│   ├── lib/       (utils, helpers)
│   └── api/       (기본 client)
└── app/

장점: 도메인별 응집, 대규모 확장
단점: 초기 셋업 부담

Barrel Export 패턴

TYPESCRIPT📋 코드 (11줄)
// features/auth/index.ts
export { LoginForm } from './components/LoginForm';
export { useAuth } from './hooks/useAuth';
export type { User, LoginCredentials } from './types';
// 외부에 노출할 것만 export


// 사용 — 깔끔한 import
import { LoginForm, useAuth } from '@/features/auth';

// 내부 세부 구조 숨김 — 리팩터링 안전

index.ts 패턴 — 자동 collect

TYPESCRIPT📋 코드 (9줄)
// shared/ui/index.ts
export * from './Button';
export * from './Card';
export * from './Modal';
export * from './Input';
// ...

// 사용
import { Button, Card, Modal } from '@/shared/ui';

Path Alias (tsconfig)

JSON📋 코드 (23줄)
// tsconfig.json
{
  "compilerOptions": {
    "baseUrl": ".",
    "paths": {
      "@/*": ["./src/*"],
      "@/features/*": ["./src/features/*"],
      "@/shared/*": ["./src/shared/*"],
      "@/app/*": ["./src/app/*"]
    }
  }
}


// vite.config.ts
import path from 'path';
export default {
  resolve: {
    alias: {
      '@': path.resolve(__dirname, './src'),
    },
  },
};

50+ 컴포넌트 프로젝트 구조

📋 코드 (21줄)
src/
├── app/                    # Next.js App Router
├── features/
│   ├── auth/               # 인증
│   ├── products/           # 상품
│   ├── orders/             # 주문
│   ├── payments/           # 결제
│   ├── shipping/           # 배송
│   └── notifications/      # 알림
├── shared/
│   ├── ui/                 # 디자인 시스템
│   │   ├── Button/
│   │   ├── Card/
│   │   ├── Form/
│   │   └── Modal/
│   ├── lib/                # 유틸
│   ├── hooks/              # 공통 훅
│   ├── api/                # 기본 fetcher
│   └── config/             # 환경변수
├── widgets/                # 큰 단위 (Header, Footer)
└── styles/

다음 챕터

CH.6 "상태 관리 비교" — useState vs Zustand vs Redux.


AI 프롬프트
🤖 AI에게 잘 물어보는 법 — 모델·전략별 프롬프트
Claude

무료: Sonnet 4.6 / Pro $20/mo: Opus 4.6

내 코드의 React 폴더 아키텍처 부분을 분석해서
실전 분석 + 개선 우선순위를 알려줘.
ChatGPT

무료: GPT-5.5 / Plus $20/mo: GPT-5.5 Pro

React 폴더 아키텍처 관련 인기 라이브러리/패턴 5개를
비교 분석해서 패턴 추출를 알려줘.
Gemini

무료: 2.5 Flash / Pro $19.99/mo: 3.1 Pro

내 프로젝트 전체에서 React 폴더 아키텍처
최적화 가능 위치를 보고해줘.
Grok

무료: Grok 4.1 / SuperGrok $30/mo

2026년 한국 프론트엔드 시장의
React 폴더 아키텍처 트렌드를 솔직히 알려줘.

⭐ 이것만 기억하세요
React 프로젝트 구조: 폴더 아키텍처 이 3가지만 확실히 잡으세요
1.Layer-based는 시작 쉬움, Feature-based는 50+ 컴포넌트에서 응집도 높음
2.Barrel export(index.ts) + Path alias = 깔끔한 import + 안전한 리팩터링
3.다음 챕터 CH.6에서 상태 관리 — 로컬 vs 글로벌 결정 기준


공유하기
진행도 5 / 90