MEL - App Architecture
MEL is built using modern iOS development practices with SwiftUI and follows clean architecture principles for maintainable, reliable data collection.
Data Models
Core Entities
- Collection: Top-level container with name, description, sessions, and notes
- Session: Event logging session with start/stop events and recorded timestamps
- Note: Detailed observation with title, description, and timestamp
- Event: Individual timestamped event (A, B, C, Start, Stop)
Relationships
- Collection contains multiple Sessions
- Collection contains multiple Notes
- Session contains multiple Events
- Sessions and Notes can have optional Location data
State Management
CollectionManager
- Singleton Pattern: Single source of truth for app state
- ObservableObject: Reactive updates using @Published properties
- Session Management: Handles active recording sessions
- File Operations: Manages save/load operations
AppState
- Global Settings: Username, display mode, location preferences
- UserDefaults Integration: Persistent user preferences
- Location Services: CoreLocation integration and privacy handling
Data Flow
Collection Lifecycle
- Create โ User input โ Validation โ JSON file creation
- Load โ File system โ CollectionManager โ UI updates
- Modify โ User actions โ State updates โ Auto-save
- Export โ Format conversion โ Share sheet
Session Management
- Start โ Create session โ Begin event recording
- Record โ User input โ Timestamp capture โ Auto-save (5s)
- Stop โ End session โ Final save โ Return to collection
Note Management
- Create โ User input โ Validation โ Add to collection
- Edit โ Load existing โ Modify โ Save changes
- Delete โ Remove from collection โ Update file
UI Architecture
SwiftUI Patterns
- NavigationStack: Declarative navigation between views
- Sheet Presentations: Modal views for editing sessions and notes
- @StateObject/@ObservedObject: Reactive data binding
- @Published Properties: Automatic UI updates
View Hierarchy
- HomeView
- CollectionNewView
- CollectionHistoryView
- CollectionDetailView
- CollectionSessionView
- CollectionNoteView
- SessionDetailsView
- SettingsView
Key Components
- Unified Timeline: Chronological display of sessions and notes
- Reactive Updates: Real-time UI updates on data changes
- Sheet Modals: Consistent editing experience
- Navigation Patterns: Intuitive user flow
External Services
CoreLocation
- Optional Integration: Respects user privacy settings
- Session Tracking: GPS coordinates for event logging
- Note Location: Optional location for observations
- Privacy Handling: Clear user consent and settings
File System
- JSON Storage: Human-readable data format
- Automatic Save/Load: Seamless data persistence
- Export Formats: JSON, Markdown, Text conversion
- File Management: Organized storage and cleanup
Date Handling
- DateFormatterService: Consistent timestamp formatting
- Timezone Handling: Local time representation
- Display Formats: User-friendly date/time display
File Structure
Core Module
- Models/AppState.swift
- Services/DateFormatterService.swift
- Services/FileManagerService.swift
- Views/HomeView.swift
- Views/SettingsView.swift
- Views/LaunchScreenView.swift
Collections Module
- Models/Collection.swift
- Models/CollectionManager.swift
- Views/CollectionDetailView.swift
- Views/CollectionNewView.swift
- Views/CollectionHistoryView.swift
- Views/CollectionNoteView.swift
- Views/CollectionSessionView.swift
- Views/CollectionSessionRecordingView.swift
Assets
- App icons and images
Technical Decisions
Architecture Choices
- MVVM Pattern: Clear separation of concerns
- Singleton State: Centralized data management
- File-based Storage: Simple, portable data format
- Reactive UI: SwiftUI's declarative approach
Performance Considerations
- Lazy Loading: Collections loaded on demand
- Auto-save: 5-second intervals prevent data loss
- Memory Management: Proper cleanup of timers and observers
- File Operations: Efficient JSON serialization
Security & Privacy
- Location Privacy: User-controlled location tracking
- Data Isolation: Collections stored separately
- No Cloud Sync: Local-only data storage
- User Consent: Clear privacy controls
Development Notes
Dependencies
- SwiftUI: iOS 16+ for modern UI patterns
- CoreLocation: Optional location services
- Foundation: File system and data handling
Testing Strategy
- Unit Tests: Data model validation
- Integration Tests: File operations
- UI Tests: User interaction flows
Future Considerations
- Collection Profiles: User-defined data fields
- Frequency Analysis: Statistical event analysis
- Export Enhancements: Additional format support
- Performance: Large dataset handling