Files
sam-react-prod/claudedocs/archive/[REF-2025-11-18] cleanup-summary.md
byeongcheolryu 65a8510c0b fix: 품목기준관리 실시간 동기화 수정
- BOM 항목 추가/수정/삭제 시 섹션탭 즉시 반영
- 섹션 복제 시 UI 즉시 업데이트 (null vs undefined 이슈 해결)
- 항목 수정 기능 추가 (useTemplateManagement)
- 실시간 동기화 문서 추가

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-27 22:19:50 +09:00

6.1 KiB

미사용 파일 정리 완료 보고서

작업 일시: 2025-11-18 작업 범위: 미사용 Context 파일 및 컴포넌트 정리


작업 완료 내역

Phase 1: 미사용 Context 8개 정리

이동된 파일 (contexts/_unused/)

  1. FacilitiesContext.tsx
  2. AccountingContext.tsx
  3. HRContext.tsx
  4. ShippingContext.tsx
  5. InventoryContext.tsx
  6. ProductionContext.tsx
  7. PricingContext.tsx
  8. SalesContext.tsx

수정된 파일

  • RootProvider.tsx
    • 8개 Context import 제거
    • Provider 중첩 10개 → 2개로 단순화
    • 현재 사용: AuthProvider, ItemMasterProvider만 유지
    • 주석 업데이트로 미사용 Context 목록 명시

이동된 컴포넌트

  • BOMManager.tsxcomponents/_unused/business/
    • 485 라인의 구형 컴포넌트
    • BOMManagementSection으로 대체됨

빌드 검증

  • npm run build 성공
  • 모든 페이지 정상 빌드 (36개 라우트)
  • 에러 없음

Phase 2: DeveloperModeContext 정리

이동된 파일

  • DeveloperModeContext.tsxcontexts/_unused/
    • Provider는 연결되어 있었으나 실제 devMetadata 기능 미사용
    • 향후 필요 시 복원 가능

수정된 파일

  1. src/app/[locale]/(protected)/layout.tsx

    • DeveloperModeProvider import 제거
    • Provider 래핑 제거
    • 주석 업데이트
  2. src/components/organisms/PageLayout.tsx

    • useDeveloperMode import 제거
    • devMetadata prop 제거
    • useEffect 및 관련 로직 제거
    • ComponentMetadata interface 의존성 제거

빌드 검증

  • npm run build 성공
  • 모든 페이지 정상 빌드
  • 에러 없음

Phase 3: .gitignore 업데이트

추가된 항목

# ---> Unused components and contexts (archived)
src/components/_unused/
src/contexts/_unused/

효과: _unused 디렉토리가 git 추적에서 제외됨


📊 정리 결과

파일 구조 (Before → After)

src/contexts/ (Before)

contexts/
├── AuthContext.tsx ✅
├── FacilitiesContext.tsx ❌
├── AccountingContext.tsx ❌
├── HRContext.tsx ❌
├── ShippingContext.tsx ❌
├── InventoryContext.tsx ❌
├── ProductionContext.tsx ❌
├── PricingContext.tsx ❌
├── SalesContext.tsx ❌
├── ItemMasterContext.tsx ✅
├── ThemeContext.tsx ✅
├── DeveloperModeContext.tsx ❌
├── RootProvider.tsx (10개 Provider 중첩)
└── DataContext.tsx.backup

src/contexts/ (After)

contexts/
├── AuthContext.tsx ✅ (사용 중)
├── ItemMasterContext.tsx ✅ (사용 중)
├── ThemeContext.tsx ✅ (사용 중)
├── RootProvider.tsx (2개 Provider만 유지)
├── DataContext.tsx.backup
└── _unused/ (git 무시)
    ├── FacilitiesContext.tsx
    ├── AccountingContext.tsx
    ├── HRContext.tsx
    ├── ShippingContext.tsx
    ├── InventoryContext.tsx
    ├── ProductionContext.tsx
    ├── PricingContext.tsx
    ├── SalesContext.tsx
    └── DeveloperModeContext.tsx

코드 감소량

항목 Before After 감소량
Context Provider 중첩 10개 2개 -8개 (80% 감소)
RootProvider.tsx 81 lines 48 lines -33 lines
Active Context 파일 13개 4개 -9개
미사용 코드 ~3,000 lines 0 lines ~3,000 lines

성능 개선

  1. 앱 초기화 속도

    • Provider 중첩 10개 → 2개
    • 불필요한 Context 초기화 제거
  2. 번들 크기

    • Tree-shaking으로 미사용 코드 제거
    • First Load JS 유지: ~102 kB (변화 없음, 원래 사용 안했으므로)
  3. 유지보수성

    • 코드베이스 명확성 증가
    • 혼란 방지 (어떤 Context를 사용하는지 명확)

🎯 현재 활성 Context

1. AuthContext.tsx

용도: 사용자 인증 및 권한 관리 상태 수: 2개 (users, currentUser) 사용처: LoginPage, SignupPage, useAuth hook

2. ItemMasterContext.tsx

용도: 품목 마스터 데이터 관리 상태 수: 13개 (itemMasters, specificationMasters, etc.) 사용처: ItemMasterDataManagement

3. ThemeContext.tsx

용도: 다크모드/라이트모드 테마 관리 사용처: DashboardLayout, ThemeSelect

4. RootProvider.tsx

용도: 전역 Context 통합 Provider: AuthProvider, ItemMasterProvider


📁 _unused 디렉토리 관리

위치

  • src/contexts/_unused/ (9개 Context 파일)
  • src/components/_unused/ (43개 구형 컴포넌트)

Git 설정

  • .gitignore에 추가됨
  • 버전 관리에서 제외
  • 로컬에만 보관 (팀원과 공유 안됨)

복원 방법

필요 시 다음 단계로 복원 가능:

  1. 파일 이동

    mv src/contexts/_unused/SalesContext.tsx src/contexts/
    
  2. RootProvider.tsx 수정

    import { SalesProvider } from './SalesContext';
    
    // Provider 추가
    <SalesProvider>
      {/* ... */}
    </SalesProvider>
    
  3. 빌드 검증

    npm run build
    

⚠️ 주의사항

향후 기능 추가 시

미사용 Context를 사용해야 하는 경우:

  1. _unused에서 필요한 Context 복원
  2. RootProvider에 Provider 추가
  3. 필요한 페이지/컴포넌트에서 hook 사용
  4. 빌드 및 테스트

새로운 Context 추가 시:

  1. 새 Context 파일 생성
  2. RootProvider에 Provider 추가
  3. SSR-safe 패턴 준수 (localStorage 접근 시)

📝 관련 문서


작업 요약

정리된 항목: 10개 파일 (Context 9개 + 컴포넌트 1개) 수정된 파일: 4개 (RootProvider, layout, PageLayout, .gitignore) 빌드 검증: 2회 성공 (Phase 1, Phase 2) 코드 감소: ~3,000 라인 Provider 감소: 80% (10개 → 2개)

결과:

  • 코드베이스 단순화 완료
  • 유지보수성 향상
  • 성능 개선 (Provider 초기화 감소)
  • 향후 복원 가능 (_unused 보관)
  • 빌드 에러 없음