This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
HushMap is an advanced iOS application for sensory accessibility mapping, built with SwiftUI and SwiftData. It helps users with sensory sensitivities find comfortable environments through AI-powered predictions and community-driven data. Developed for the Google Maps Platform Awards.
# Build for simulator
xcodebuild -project HushMap.xcodeproj -scheme HushMap -configuration Debug build
# Clean build
xcodebuild -project HushMap.xcodeproj -scheme HushMap clean build
# Build for device deployment
xcodebuild -project HushMap.xcodeproj -scheme HushMap -sdk iphoneos -configuration Release build
# Run tests (when available)
xcodebuild -project HushMap.xcodeproj -scheme HushMap test
# Open in Xcode IDE
open HushMap.xcodeprojThe app uses a layered architecture with clear separation of concerns:
-
Data Layer (
Models/): SwiftData models with@ModelmacroReport: Sensory environment data (noise, crowds, lighting, comfort)User: Authentication, points, badges, sensory profileSensoryProfile: AI learning system tracking user preferences- Relationships: User ↔ Reports ↔ SensoryProfile with proper inverses
-
Service Layer (
Services/): @MainActor singleton services- All services use
sharedsingleton pattern for thread safety - Services handle external APIs, device capabilities, and business logic
- Error handling through
AppErrorenum with comprehensive cases
- All services use
-
Presentation Layer: SwiftUI views with reactive state
- Views in
Views/use@State,@StateObject,@ObservedObject - ViewModels use
@Publishedfor reactive updates - SwiftData
@Queryfor automatic UI updates from database
- Views in
The app implements a sophisticated hybrid prediction system:
- Primary: OpenAI GPT-4 predictions via
PredictionService→OpenAIService - Fallback: Algorithmic predictions based on venue type, time, weather
- Learning:
SensoryProfileadapts to user comfort levels using exponential moving averages - Validation: Multi-stage AI response validation with structured parsing
Device capability-aware rendering system:
DeviceCapabilityServicecategorizes devices (High/Medium/Low)- Map markers adapt complexity based on device tier
- Clustering algorithms scale with performance capabilities
- Animation durations adjust to maintain smooth UX
Multi-provider authentication with privacy support:
- Google Sign-In and Apple Sign-In via
AuthenticationService - Anonymous mode with full functionality
- User data association after authentication
- GDPR-compliant account deletion
- Services: Always
@MainActorsingletons withsharedinstance - ViewModels: Use
@Publishedfor properties that trigger UI updates - Views:
@StateObjectfor owned ViewModels,@ObservedObjectfor injected - SwiftData:
@Queryin views for reactive database updates
- Sheet-based modal presentation (no UIKit navigation controllers)
- State cleanup in
.onDisappearmodifiers - Welcome/onboarding flow managed at app level in
HushMapApp
// Services throw errors
func fetchData() async throws -> Data
// ViewModels handle and display
do {
data = try await service.fetchData()
} catch {
self.error = error
self.showAlert = true
}- Always check
GoogleMapsService.shared.isConfiguredbefore map operations - Use
GoogleMapsViewwrapper component for SwiftUI integration - Handle POI taps, map taps, and marker interactions separately
- Device-aware marker rendering for performance
- Create
Config-Local.xcconfigfromConfig.xcconfigtemplate - Required API keys:
GOOGLE_MAPS_API_KEY: Maps SDK and Places APIGOOGLE_PLACES_API_KEY: Place search and autocompleteOPENAI_API_KEY: AI predictions
- Configure Google Cloud Console:
- Enable Maps SDK for iOS
- Enable Places API
- Add bundle identifier to API key restrictions
- Update
Reportmodel with new property - Modify
PredictionService.generatePrediction()prompt - Add UI controls in
AddReportView - Update
SensoryProfilelearning algorithm if needed
- Add method to
OpenAIServicefor API call - Create validation in
PredictionService - Implement fallback algorithm for when AI unavailable
- Cache results in SwiftData model if appropriate
- Edit
GoogleMapsViewfor map configuration - Update
HomeMapViewModelfor data management - Adjust
DeviceCapabilityServicethresholds for performance - Test on low-end devices (iPhone 12 or older)
- SwiftData handles simple migrations automatically
- For complex changes, implement migration plan in
modelContainerinitialization - Test migration path from previous app version
- Map Markers: Limited to 100 on low-end devices, 500 on high-end
- Clustering: Enabled when >50 markers visible
- AI Predictions: Cached for 24 hours to reduce API calls
- Images: Lazy loaded in lists, cached in memory
- Animations: Duration scales with device capability
Required Info.plist keys already configured:
NSLocationWhenInUseUsageDescription: Location for nearby placesNSMicrophoneUsageDescription: Sound level measurementNSCameraUsageDescription: Photo uploads (if implemented)
Manual testing checklist:
- Test on iPhone 12 (low-end) and iPhone 15 Pro (high-end)
- Verify anonymous mode → authenticated transition
- Test offline behavior and error states
- Validate AI prediction fallbacks
- Check accessibility with VoiceOver
- Test Dynamic Type scaling
- Minimum iOS: 17.0 (required for SwiftData)
- Swift Concurrency: All async operations use async/await
- Thread Safety: All UI updates on @MainActor
- Memory: Profile with Instruments for leaks
- API Quotas: Monitor Google Maps and OpenAI usage