- Make all Core Data attributes CloudKit-compatible (optional or with defaults) - Fix CoreDataStack to wait for persistent store loading before operations - Add AccentColor to asset catalog (green theme color) - Remove Browse tab from navigation (keep underlying code) - Update CLAUDE.md with current features, architecture, and tab structure Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
4.7 KiB
4.7 KiB
CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Build & Test Commands
# Build
xcodebuild -project PlantGuide.xcodeproj -scheme PlantGuide -configuration Debug
# Run all tests
xcodebuild test -project PlantGuide.xcodeproj -scheme PlantGuide -destination 'platform=iOS Simulator,name=iPhone 16'
# Run a single test class
xcodebuild test -project PlantGuide.xcodeproj -scheme PlantGuide -destination 'platform=iOS Simulator,name=iPhone 16' -only-testing:PlantGuideTests/HybridIdentificationUseCaseTests
# Run a single test method
xcodebuild test -project PlantGuide.xcodeproj -scheme PlantGuide -destination 'platform=iOS Simulator,name=iPhone 16' -only-testing:PlantGuideTests/SavePlantUseCaseTests/testSavePlant_Success
App Structure
Tab Navigation: Camera | Collection | Today | Settings
Implemented Features
- Plant Identification - Camera-based plant ID using on-device ML + PlantNet API fallback
- Plant Collection - Save identified plants with care schedules
- Plant Rooms/Zones - Organize plants by room (Kitchen, Living Room, Bedroom, etc.)
- Today View - Dashboard showing overdue + today's care tasks grouped by room
- Progress Photos - Capture growth photos with time-lapse playback and photo reminders
- Care Scheduling - Watering, fertilizing, repotting, pruning, pest control tasks
- Notifications - Local notifications for care reminders and photo reminders
- CloudKit Sync - iCloud sync via NSPersistentCloudKitContainer
- Dark Mode - System-following color scheme with semantic color tokens
Architecture
Clean Architecture + MVVM with three main layers:
Presentation (SwiftUI Views + ViewModels)
↓
Domain (Use Cases + Entities + Repository Protocols)
↓
Data (Repository Implementations + Data Sources)
Key Patterns
- Dependency Injection:
DIContainer(singleton) provides all dependencies viaLazyService<T>wrappers - Use Cases: Each user action is a separate use case class (e.g.,
SavePlantUseCase,HybridIdentificationUseCase) - Repository Pattern: Protocols in Domain layer, implementations in Data layer
- Actor-based Concurrency:
PlantClassificationService,NotificationService, and Core Data background tasks use actors - ViewModels:
@MainActor @Observableclasses, created viaDIContainer.makeXxxViewModel() - Core Data + CloudKit:
NSPersistentCloudKitContainerwith async store loading andwaitForStoreLoaded()pattern
Data Flow Example
CameraView → IdentificationViewModel → HybridIdentificationUseCase
→ PlantClassificationService (on-device ML)
→ PlantNetAPIService (online fallback)
→ IdentificationView (results)
Directory Structure
App/- Entry point, configuration, API keysCore/DI/- DIContainer and LazyServiceCore/DesignSystem/- Color tokens, animations, appearance managementCore/Services/- NotificationServiceDomain/- Business logic: Entities, UseCases, RepositoryInterfacesData/- Persistence: CoreData, Repositories, API services, MappersML/- Core ML inference service and image preprocessingPresentation/- SwiftUI views, ViewModels, navigationScenes/- Feature-specific views (Camera, Collection, Today, Settings, ProgressPhotos, Rooms)Common/- Shared components and modifiers
External Services
- PlantNet API (
my.plantnet.org) - Plant identification via image upload (500 free/day) - Trefle API (
trefle.io) - Botanical care data (400K+ species) - CloudKit - iCloud sync for plants, rooms, care tasks, and progress photos
API keys configured in App/Configuration/APIKeys.swift via environment variables.
ML Model
PlantNet-300K ResNet50 for on-device plant classification:
- Input: 224x224 RGB image with ImageNet normalization
- Output: 1,081 plant species probabilities
- Conversion scripts in
scripts/directory
Core Data Model
Entities (all CloudKit-compatible with optional attributes):
PlantMO- Plant records with identification dataRoomMO- User-created rooms/zonesCareScheduleMO- Care schedule configuration per plantCareTaskMO- Individual care tasks (watering, fertilizing, etc.)ProgressPhotoMO- Progress photos with thumbnailsIdentificationMO- Plant identification historyPlantCareInfoMO- Cached care information from APIs
Testing
- Unit tests in
PlantGuideTests/with mock implementations inMocks/ - Test fixtures available for
Plant,CareTask,PlantCareSchedule - Mock services:
MockPlantCollectionRepository,MockNetworkService, etc. - In-memory Core Data stack for test isolation:
CoreDataStack(inMemory: true)