Phase 4: Cloud Sync Implementation Plan
Phase 4: Cloud Sync Implementation Plan
Overview
This document outlines the optional backup/sync functionality for Project Myriad, designed to be privacy-first and user-controlled.
Features
What Gets Synced
- User Preferences: Theme, language, reading settings
- Reading Progress: Current page/episode, completion status
- Collections: User-created collections and organization
- Tags: Custom tags and categorization
- Settings: App configuration and customization
What Doesn’t Get Sync
- Media Files: Original .cbz/.cbr/.mp4 files (user’s local files)
- Personal Information: No personal data collection
- Usage Analytics: No tracking or analytics data
Implementation Strategy
Phase 1: Local Sync Foundation
// core/data/src/main/kotlin/com/heartlessveteran/myriad/core/data/sync/
data class SyncData(
val preferences: UserPreferences,
val readingProgress: List<ReadingProgress>,
val collections: List<Collection>,
val tags: List<Tag>,
val lastSyncTimestamp: Long
)
interface SyncRepository {
suspend fun exportSyncData(): Result<SyncData>
suspend fun importSyncData(data: SyncData): Result<Unit>
suspend fun getLastSyncTimestamp(): Long
}
Phase 2: Cloud Storage Options
// Multiple cloud providers for user choice
sealed class CloudProvider {
object GoogleDrive : CloudProvider()
object Dropbox : CloudProvider()
object OneDrive : CloudProvider()
object Custom : CloudProvider() // User's own server
}
interface CloudSyncService {
suspend fun upload(data: SyncData): Result<String> // Returns sync ID
suspend fun download(syncId: String): Result<SyncData>
suspend fun delete(syncId: String): Result<Unit>
}
Phase 3: Conflict Resolution
data class SyncConflict(
val local: SyncData,
val remote: SyncData,
val conflictType: ConflictType
)
enum class ConflictType {
NEWER_LOCAL,
NEWER_REMOTE,
BOTH_MODIFIED
}
interface ConflictResolver {
suspend fun resolveConflict(conflict: SyncConflict): SyncData
}
User Experience
Opt-in Design
- Cloud sync is completely optional
- Clear explanation of what data is synced
- Easy to enable/disable at any time
- No degraded experience if disabled
Setup Flow
- User Choice: “Would you like to backup your settings and progress?”
- Provider Selection: Choose cloud provider or custom server
- Authentication: Secure OAuth flow
- First Sync: Initial backup creation
- Automatic Sync: Background sync with user control
Privacy Controls
- Data Transparency: Clear list of synced data
- Encryption: All data encrypted before upload
- Deletion: Easy data deletion from cloud
- Access Control: User manages permissions
Security
Encryption
interface SyncEncryption {
fun encrypt(data: SyncData, userKey: String): ByteArray
fun decrypt(encryptedData: ByteArray, userKey: String): SyncData
}
// AES-256 encryption with user-derived key
class AESyncEncryption : SyncEncryption {
private val keyDerivation = PBKDF2WithHmacSHA256()
private val cipher = AES256GCM()
}
Key Management
- User-derived encryption keys (not stored on servers)
- Option for user-provided passphrase
- Key rotation capability
- Secure key storage using Android Keystore
Implementation Files
Core Sync Infrastructure
core/data/src/main/kotlin/com/heartlessveteran/myriad/core/data/sync/
├── SyncRepository.kt
├── SyncData.kt
├── SyncEncryption.kt
├── ConflictResolver.kt
└── CloudSyncService.kt
Cloud Providers
core/data/src/main/kotlin/com/heartlessveteran/myriad/core/data/sync/providers/
├── GoogleDriveSyncService.kt
├── DropboxSyncService.kt
├── OneDriveSyncService.kt
└── CustomServerSyncService.kt
UI Components
feature/settings/src/main/kotlin/com/heartlessveteran/myriad/feature/settings/sync/
├── SyncSettingsScreen.kt
├── SyncSetupScreen.kt
├── SyncConflictScreen.kt
└── SyncStatusScreen.kt
Gradle Dependencies
// Add to libs.versions.toml
[versions]
google-drive-api = "1.34.0"
dropbox-core-sdk = "6.0.0"
microsoft-graph = "5.74.0"
[libraries]
google-drive-api = { group = "com.google.apis", name = "google-api-services-drive", version.ref = "google-drive-api" }
dropbox-core-sdk = { group = "com.dropbox.core", name = "dropbox-core-sdk", version.ref = "dropbox-core-sdk" }
microsoft-graph = { group = "com.microsoft.graph", name = "microsoft-graph", version.ref = "microsoft-graph" }
Testing Strategy
Unit Tests
- Sync data serialization/deserialization
- Encryption/decryption functionality
- Conflict resolution logic
- Repository implementations
Integration Tests
- End-to-end sync flows
- Cloud provider integrations
- Error handling scenarios
- Network failure recovery
Privacy Tests
- Data encryption verification
- No sensitive data leakage
- Proper data deletion
- Access control validation
Rollout Plan
Phase 1: Foundation (Week 1-2)
- Implement core sync data structures
- Create local sync repository
- Add encryption infrastructure
- Basic UI for sync settings
Phase 2: Cloud Integration (Week 3-4)
- Implement Google Drive sync
- Add Dropbox support
- Create conflict resolution
- Enhanced UI for setup
Phase 3: Polish & Testing (Week 5-6)
- Add remaining providers
- Comprehensive testing
- Performance optimization
- Documentation and help
Phase 4: Release (Week 7)
- Beta testing with opt-in users
- Monitor sync performance
- Gather user feedback
- Full release with sync feature
Success Metrics
Technical Metrics
- Sync success rate > 99%
- Average sync time < 5 seconds
- Zero data loss incidents
- Encryption strength validation
User Metrics
- Opt-in rate for sync feature
- User satisfaction with sync reliability
- Support requests related to sync
- Feature usage patterns
Future Enhancements
Advanced Features
- Selective Sync: Choose what to sync
- Sync Scheduling: User-controlled timing
- Multiple Devices: Device-specific settings
- Backup History: Multiple backup versions
Enterprise Features
- Team Sync: Shared collections for organizations
- Admin Controls: Management dashboards
- Compliance: GDPR/CCPA compliance tools
- Audit Logs: Sync activity tracking
Notes
- Implementation should be gradual and well-tested
- Privacy and security are paramount
- User control and transparency are essential
- Feature should enhance, not complicate, user experience
- All cloud sync features are optional and can be disabled
This implementation plan supports Phase 4 cloud sync requirements while maintaining Project Myriad’s privacy-first approach.