# Superport ERP System - Project Rules v2.0 > πŸ’‘ **Note**: Global Claude Code rules from `~/.claude/CLAUDE.md` are automatically applied. This document contains **project-specific** configurations only. ## 🎯 Project Identity **Superport**λŠ” Rust λ°±μ—”λ“œ + Flutter μ›Ή/λͺ¨λ°”일 기반의 **μ—”ν„°ν”„λΌμ΄μ¦ˆ ERP μ‹œμŠ€ν…œ**μž…λ‹ˆλ‹€. ### Core Domains - **Equipment Management**: μž₯λΉ„ μž…κ³ /좜고, μ‹œλ¦¬μ–Ό 번호 좔적, 재고 관리 - **Company Management**: 고객사 정보, 닀쀑 지점 관리 - **User Management**: μ—­ν•  기반 μ ‘κ·Ό μ œμ–΄ (S: κ΄€λ¦¬μž, M: 멀버) - **License Management**: μœ μ§€λ³΄μˆ˜ λΌμ΄μ„ μŠ€, 만료일 좔적 - **Warehouse Management**: μ°½κ³  μœ„μΉ˜ 체계적 관리 ## πŸ—οΈ Architecture Rules ### Clean Architecture Structure ``` lib/ β”œβ”€β”€ core/ # ⚠️ 핡심 μ„€μ • - μ‹ μ€‘νžˆ μˆ˜μ • β”‚ β”œβ”€β”€ api_client.dart # Dio/Retrofit μ„€μ • β”‚ β”œβ”€β”€ exceptions.dart # μ „μ—­ μ˜ˆμ™Έ 처리 β”‚ └── navigation.dart # λΌμš°νŒ… 관리 β”œβ”€β”€ data/ # 데이터 λ ˆμ΄μ–΄ β”‚ β”œβ”€β”€ dto/ # API 응닡 λͺ¨λΈ (Freezed) β”‚ β”œβ”€β”€ repositories/ # 데이터 μ†ŒμŠ€ 좔상화 β”‚ └── services/ # API μ„œλΉ„μŠ€ (Retrofit) β”œβ”€β”€ domain/ # λΉ„μ¦ˆλ‹ˆμŠ€ 둜직 β”‚ β”œβ”€β”€ entities/ # 도메인 λͺ¨λΈ β”‚ β”œβ”€β”€ repositories/ # Repository μΈν„°νŽ˜μ΄μŠ€ β”‚ └── usecases/ # λΉ„μ¦ˆλ‹ˆμŠ€ 둜직 β”œβ”€β”€ services/ # μ• ν”Œλ¦¬μΌ€μ΄μ…˜ μ„œλΉ„μŠ€ β”‚ β”œβ”€β”€ auth_service.dart # JWT 인증 관리 β”‚ β”œβ”€β”€ api_service.dart # API 호좜 관리 β”‚ └── storage_service.dart # 둜컬 μ €μž₯μ†Œ β”œβ”€β”€ screens/ # Feature-First UI β”‚ └── [feature]/ β”‚ β”œβ”€β”€ controllers/ # Provider 기반 μƒνƒœ 관리 β”‚ β”œβ”€β”€ widgets/ # μž¬μ‚¬μš© μ»΄ν¬λ„ŒνŠΈ β”‚ └── [feature]_form.dart └── di/ # GetIt μ˜μ‘΄μ„± μ£Όμž… ``` ### Architecture Constraints ```yaml constraints: - "ControllerλŠ” λ°˜λ“œμ‹œ ChangeNotifier 상속" - "λͺ¨λ“  API ν˜ΈμΆœμ€ ApiService 경유" - "DTOλŠ” Freezed + JsonSerializable ν•„μˆ˜" - "화면별 Controller 뢄리 원칙" - "Mockκ³Ό Real μ„œλΉ„μŠ€ μ™„μ „ 뢄리" ``` ## πŸ’» Development Environment ### API Endpoints ```yaml development: base_url: "https://api-dev.beavercompany.co.kr" test_account: "admin@test.com / Test123!@#" jwt_expiry: 24h production: base_url: "TBD" security: "JWT + Secure Storage" ``` ### Environment Switching ```dart // ν™˜κ²½ λ³€μˆ˜ μ„€μ • (.env) API_MODE=mock # mock | real BASE_URL=https://api-dev.beavercompany.co.kr // μ½”λ“œμ—μ„œ ν™˜κ²½ μ „ν™˜ final isMockMode = dotenv.env['API_MODE'] == 'mock'; if (isMockMode) { GetIt.I.registerSingleton(MockApiService()); } else { GetIt.I.registerSingleton(RealApiService()); } ``` ## πŸ§ͺ Test Automation System ### Test Infrastructure ```dart // λͺ¨λ“  ν™”λ©΄ ν…ŒμŠ€νŠΈλŠ” BaseScreenTest 상속 abstract class BaseScreenTest { // μžλ™ μ—λŸ¬ 진단 및 μˆ˜μ • ApiErrorDiagnostics diagnostics; // ν•œκ΅­μ‹ ν˜„μ‹€μ  ν…ŒμŠ€νŠΈ 데이터 TestDataGenerator generator; // 병렬 μ‹€ν–‰ μ œμ–΄ (μ΅œλŒ€ 3개) SemaphoreManager semaphore; } ``` ### Test Execution Priority ```yaml test_order: 1: "Company Management" # νšŒμ‚¬ λ¨Όμ € 생성 2: "User Management" # νšŒμ‚¬μ— μ‚¬μš©μž μ—°κ²° 3: "Warehouse Location" # μ°½κ³  μœ„μΉ˜ μ„€μ • 4: "Equipment In" # μž₯λΉ„ μž…κ³  5: "License Management" # λΌμ΄μ„ μŠ€ 등둝 6: "Equipment Out" # μž₯λΉ„ 좜고 7: "Overview Dashboard" # 톡계 확인 ``` ### Test Commands ```bash # 전체 ν…ŒμŠ€νŠΈ μ‹€ν–‰ (병렬) flutter test test/master_test_suite.dart # νŠΉμ • ν™”λ©΄ ν…ŒμŠ€νŠΈ flutter test test/screens/company/company_test.dart # Mock λͺ¨λ“œ ν…ŒμŠ€νŠΈ API_MODE=mock flutter test # μ—λŸ¬ 진단 λͺ¨λ“œ flutter test --dart-define=DIAGNOSTIC_MODE=true ``` ## 🎨 UI/UX Standards ### Design System ```yaml base_template: "Metronic Admin Template" component_library: "ShadCN Flutter Port" colors: primary: "#5867dd" # Metronic 기본색 secondary: "#34bfa3" background: "#f7f8fa" error: "#fd397a" success: "#0abb87" typography: font_family: "NotoSansKR" korean_support: true layout: style: "Microsoft Dynamics 365" structure: "Header + Sidebar + Content" responsive: "Web First β†’ Mobile Adaptive" ``` ### Component Patterns ```dart // λͺ¨λ“  폼은 이 νŒ¨ν„΄ λ”°λ₯΄κΈ° class EntityForm extends StatefulWidget { final EntityController controller; final FormMode mode; // create | edit | view // ν•„μˆ˜ μ„Ήμ…˜ Widget buildBasicInfo() {} Widget buildDetailInfo() {} Widget buildActionButtons() {} } // 리슀트 ν™”λ©΄ νŒ¨ν„΄ class EntityList extends StatelessWidget { // ν•„μˆ˜ μš”μ†Œ Widget buildSearchBar() {} Widget buildFilterOptions() {} Widget buildDataTable() {} Widget buildPagination() {} } ``` ## πŸ”Œ API Integration Rules ### Error Handling Strategy ```dart // λͺ¨λ“  API ν˜ΈμΆœμ€ 이 νŒ¨ν„΄ μ‚¬μš© try { final response = await apiService.call(); return Right(response); } on DioException catch (e) { // 422개 μ—λŸ¬ νŒ¨ν„΄ μžλ™ 뢄석 final diagnosis = ApiErrorDiagnostics.analyze(e); return Left(ApiFailure( code: diagnosis.code, message: diagnosis.userMessage, // ν•œκ΅­μ–΄ technicalDetails: diagnosis.details, )); } ``` ### Response Parsing Rules ```dart // JSON νŒŒμ‹± μ£Όμ˜μ‚¬ν•­ rules: - "null κ°’ μ•ˆμ „ 처리 ν•„μˆ˜" - "λ‚ μ§œλŠ” ISO 8601 ν˜•μ‹" - "IDλŠ” 항상 String νƒ€μž…" - "빈 배열은 [] λ°˜ν™˜" - "쀑첩 κ°μ²΄λŠ” 별도 DTO 생성" ``` ## 🚨 Critical Areas & Known Issues ### ⚠️ Current Gotchas ```yaml equipment_in: issue: "μ‹œλ¦¬μ–Ό 번호 쀑볡 체크 λ―Έκ΅¬ν˜„" workaround: "ν”„λ‘ νŠΈμ—”λ“œμ—μ„œ μž„μ‹œ 검증" license_management: issue: "만료일 계산 둜직 뢈일치" note: "λ°±μ—”λ“œμ™€ ν”„λ‘ νŠΈμ—”λ“œ 둜직 톡일 ν•„μš”" user_permission: issue: "κΆŒν•œ 체크 일뢀 ν™”λ©΄ λˆ„λ½" affected: ["warehouse_location", "overview"] ``` ### πŸ”₯ Hot Paths (μ„±λŠ₯ 주의) ```yaml critical_operations: - path: "Equipment List with 10000+ items" solution: "Virtual scrolling κ΅¬ν˜„λ¨" - path: "Dashboard statistics calculation" solution: "5λΆ„ 캐싱 적용" - path: "Company branch tree loading" solution: "Lazy loading ν•„μˆ˜" ``` ## πŸ“Š Current Sprint Focus ### Active Development (2025-01-06) ```yaml priority_1: task: "Overview Dashboard μ™„μ„±" acceptance_criteria: - "μ‹€μ‹œκ°„ 톡계 데이터 μ •ν™•μ„±" - "차트 λ Œλ”λ§ μ„±λŠ₯ μ΅œμ ν™”" - "필터링 κΈ°λŠ₯ κ΅¬ν˜„" priority_2: task: "Equipment Out ν”„λ‘œμ„ΈμŠ€" blockers: - "좜고 승인 μ›Œν¬ν”Œλ‘œμš° λ―Έμ •" - "재고 차감 둜직 검증 ν•„μš”" priority_3: task: "Mobile App λ³€ν™˜ μ€€λΉ„" requirements: - "λ°˜μ‘ν˜• λ ˆμ΄μ•„μ›ƒ 점검" - "ν„°μΉ˜ 제슀처 μ΅œμ ν™”" ``` ## 🧬 Code Generation Commands ### Freezed & JsonSerializable ```bash # 단일 파일 생성 flutter pub run build_runner build --delete-conflicting-outputs # 전체 μž¬μƒμ„± (주의: μ‹œκ°„ μ†Œμš”) flutter pub run build_runner build --delete-conflicting-outputs # Watch mode (개발 쀑) flutter pub run build_runner watch ``` ### Injectable (DI) ```bash # DI μ„€μ • μž¬μƒμ„± flutter pub run build_runner build --delete-conflicting-outputs ``` ## πŸ” Debugging Helpers ### Quick Debug Commands ```dart // API 응닡 λ‘œκΉ… ApiService.enableLogging = true; // Mock 데이터 확인 MockDataViewer.show(context); // ν˜„μž¬ 인증 μƒνƒœ AuthService.debugPrintToken(); // Controller μƒνƒœ 좔적 controller.addListener(() => print(controller.debugState)); ``` ### Performance Monitoring ```dart // ν™”λ©΄ λ Œλ”λ§ μ‹œκ°„ μΈ‘μ • Timeline.startSync('ScreenRender'); // ... rendering code Timeline.finishSync(); // API 호좜 μ‹œκ°„ 좔적 final stopwatch = Stopwatch()..start(); await apiCall(); print('API took: ${stopwatch.elapsed}'); ``` ## πŸ“ Commit Message Convention ### Project-Specific Prefixes ``` equipment: μž₯λΉ„ 관리 κ΄€λ ¨ company: νšŒμ‚¬ 관리 κ΄€λ ¨ user: μ‚¬μš©μž 관리 κ΄€λ ¨ license: μœ μ§€λ³΄μˆ˜ λΌμ΄μ„ μŠ€ κ΄€λ ¨ warehouse: μ°½κ³  κ΄€λ ¨ dashboard: λŒ€μ‹œλ³΄λ“œ κ΄€λ ¨ auth: 인증/κΆŒν•œ κ΄€λ ¨ api: API 연동 κ΄€λ ¨ ``` ### Examples ``` equipment: μ‹œλ¦¬μ–Ό 번호 쀑볡 검증 둜직 μΆ”κ°€ company: 지점 트리 ꡬ쑰 lazy loading κ΅¬ν˜„ test: Equipment In μžλ™ν™” ν…ŒμŠ€νŠΈ μ™„μ„± api: 422 μ—λŸ¬ μžλ™ 볡ꡬ λ©”μ»€λ‹ˆμ¦˜ κ΅¬ν˜„ ``` ## 🎯 Success Metrics ### Code Quality Standards ```yaml flutter_analyze: errors: 0 warnings: < 10 info: < 50 test_coverage: minimum: 80% critical_paths: 100% performance: initial_load: < 3s api_response: < 500ms list_render: < 100ms ``` ## πŸš€ Quick Start Guide ### For New Developers ```bash # 1. ν™˜κ²½ μ„€μ • cp .env.example .env flutter pub get # 2. μ½”λ“œ 생성 flutter pub run build_runner build --delete-conflicting-outputs # 3. Mock λͺ¨λ“œλ‘œ μ‹œμž‘ API_MODE=mock flutter run -d chrome # 4. ν…ŒμŠ€νŠΈ μ‹€ν–‰ flutter test test/master_test_suite.dart # 5. μ‹€μ œ API 연동 API_MODE=real flutter run -d chrome ``` --- **Version**: 2.0 **Last Updated**: 2025-01-06 **Project Stage**: Production Ready **Next Milestone**: Mobile App Release