student-timekeeper-ios

Streamlined iOS App - Implementation Plan

Executive Summary

Create a minimal, focused iOS app that only tracks screen time using Apple’s Family Controls framework and syncs with the existing dreamlauncher-api to enable cross-platform screen time visibility between iOS and macOS devices.

Why This Plan?

Problems with Current dreamlauncher-ios

After reviewing the codebase, the current iOS app includes excessive features that add complexity without adding value for screen time tracking:

Bloat Identified:

What We Actually Need:


Core Architecture

Technology Stack

┌─────────────────────────────────────────────────────────────┐
│                     iOS App (Swift/SwiftUI)                 │
│  ┌──────────────┐  ┌──────────────┐  ┌──────────────┐     │
│  │ Auth Screen  │→ │ Screen Time  │→ │ Sync Service │     │
│  │ (Apple Sign) │  │   Dashboard   │  │              │     │
│  └──────────────┘  └──────────────┘  └──────┬───────┘     │
└───────────────────────────────────────────────┼─────────────┘
                                                │
                                    ┌───────────▼───────────┐
                                    │  dreamlauncher-api    │
                                    │  (Existing Backend)   │
                                    │                       │
                                    │  • Apple Auth         │
                                    │  • UserScreenTime DB  │
                                    │  • Cross-platform API │
                                    └───────────┬───────────┘
                                                │
                                    ┌───────────▼───────────┐
                                    │   macOS App           │
                                    │   (Displays iOS data) │
                                    └───────────────────────┘

Required Apple Frameworks

  1. FamilyControls - Request authorization to access Screen Time data
  2. DeviceActivity - Query screen time usage data
  3. SwiftUI - Modern UI framework
  4. AuthenticationServices - Apple Sign-In

App Extensions Required

  1. DeviceActivityMonitor Extension - Background monitoring
  2. DeviceActivityReport Extension - Display screen time reports

Feature Breakdown

1. Authentication Flow

Approach: Use existing dreamlauncher-api Apple Sign-In

// Use existing endpoint: POST /api/v1/apple-auth/sign-in
// Request: { identityToken, authorizationCode, user? }
// Response: { accessToken, refreshToken, user }

UI Flow:

Launch → Apple Sign-In Button → API Auth → Main Dashboard

Implementation:

2. Family Controls Integration

Authorization Request:

import FamilyControls

// Request authorization
let center = AuthorizationCenter.shared
try await center.requestAuthorization(for: .individual)

Data Collection:

3. Data Sync Strategy

API Endpoint (Already Exists):

POST /api/v1/user-screen-time
Body: {
  startDate: "2025-01-01T00:00:00Z",
  endDate: "2025-01-01T23:59:59Z",
  durationInMinutes: 180,
  timeZone: "America/Los_Angeles"
}

Sync Schedule:

Local Storage:

// Core Data entities
ScreenTimeEntry {
  id: UUID
  startDate: Date
  endDate: Date
  durationMinutes: Int
  synced: Bool
  createdAt: Date
}

4. Dashboard UI

Single Screen Design:

┌─────────────────────────────────────┐
│          🌙 DreamLauncher           │
├─────────────────────────────────────┤
│                                     │
│   Today's Screen Time               │
│   ┌─────────────────────────────┐  │
│   │        3h 42m               │  │
│   │   ████████████░░░░░         │  │
│   │   iOS: 2h 10m | Mac: 1h 32m │  │
│   └─────────────────────────────┘  │
│                                     │
│   This Week                         │
│   ┌─────────────────────────────┐  │
│   │  Mon  Tue  Wed  Thu  Fri    │  │
│   │   ██   ███  ███  ██   ███   │  │
│   │  3.2h 4.1h 3.8h 3.0h 4.5h   │  │
│   └─────────────────────────────┘  │
│                                     │
│   Platform Breakdown                │
│   ┌─────────────────────────────┐  │
│   │  📱 iPhone    14.2h (60%)   │  │
│   │  💻 MacBook    9.3h (40%)   │  │
│   └─────────────────────────────┘  │
│                                     │
│  [Settings] [Refresh]               │
└─────────────────────────────────────┘

Key Components:

5. Background Sync

Using BGTaskScheduler:

// Register background task
BGTaskScheduler.shared.register(
    forTaskWithIdentifier: "com.dreamlauncher.screentimesync",
    using: nil
) { task in
    await syncScreenTimeData()
    task.setTaskCompleted(success: true)
}

// Schedule next sync (every 4 hours)
let request = BGAppRefreshTaskRequest(
    identifier: "com.dreamlauncher.screentimesync"
)
request.earliestBeginDate = Date(timeIntervalSinceNow: 4 * 60 * 60)
try BGTaskScheduler.shared.submit(request)

File Structure

DreamLauncherLite-iOS/
├── DreamLauncherLite.xcodeproj
├── DreamLauncherLite/
│   ├── App/
│   │   ├── DreamLauncherLiteApp.swift
│   │   └── AppDelegate.swift
│   ├── Models/
│   │   ├── ScreenTimeEntry.swift
│   │   └── User.swift
│   ├── Services/
│   │   ├── AuthService.swift
│   │   ├── ScreenTimeService.swift
│   │   ├── SyncService.swift
│   │   └── APIClient.swift
│   ├── Views/
│   │   ├── AuthView.swift
│   │   ├── DashboardView.swift
│   │   ├── WeekChartView.swift
│   │   └── SettingsView.swift
│   ├── Extensions/
│   │   ├── Date+Extensions.swift
│   │   └── View+Extensions.swift
│   ├── Storage/
│   │   ├── CoreDataStack.swift
│   │   └── DreamLauncher.xcdatamodeld
│   ├── Info.plist
│   └── DreamLauncherLite.entitlements
├── DeviceActivityMonitorExtension/
│   ├── DeviceActivityMonitorExtension.swift
│   ├── Info.plist
│   └── DeviceActivityMonitorExtension.entitlements
└── DeviceActivityReportExtension/
    ├── TotalActivityReport.swift
    ├── Info.plist
    └── DeviceActivityReportExtension.entitlements

Total Files: ~20 Swift files (vs 200+ in current app) Lines of Code Estimate: ~2,000 (vs 10,000+ in current app)


Data Model

Core Data Schema

// ScreenTimeEntry.xcdatamodeld
entity ScreenTimeEntry {
    id: UUID
    startDate: Date
    endDate: Date
    durationInMinutes: Int32
    deviceType: String  // "IOS_PHONE", "IOS_TABLET"
    synced: Bool
    syncedAt: Date?
    createdAt: Date
}

entity User {
    id: String
    appleId: String
    email: String?
    name: String?
    accessToken: String  // Encrypted
    refreshToken: String  // Encrypted
    lastSyncDate: Date?
}

API Data Transfer Objects

struct CreateScreenTimeDTO: Codable {
    let startDate: Date
    let endDate: Date
    let durationInMinutes: Int
    let timeZone: String
}

struct ScreenTimeResponseDTO: Codable {
    let success: Bool
    let data: [ScreenTimeData]
    let pagination: Pagination
}

struct ScreenTimeData: Codable {
    let id: String
    let userId: String
    let startDate: Date
    let endDate: Date
    let durationInMinutes: Int
    let deviceType: String?
    let createdAt: Date
}

API Integration

Existing Endpoints to Use

  1. Authentication
    POST /api/v1/apple-auth/sign-in
    POST /api/v1/refresh-token
    
  2. Screen Time Data
    POST /api/v1/user-screen-time
    GET /api/v1/user-screen-time?startDate={date}&endDate={date}
    GET /api/v1/user-screen-time/combined  // iOS + macOS
    

Network Layer

class APIClient {
    private let baseURL = "https://your-api.railway.app/api/v1"
    
    func signInWithApple(
        identityToken: String,
        authorizationCode: String
    ) async throws -> AuthTokens
    
    func refreshToken() async throws -> AuthTokens
    
    func syncScreenTime(
        entries: [CreateScreenTimeDTO]
    ) async throws -> Bool
    
    func fetchScreenTime(
        startDate: Date,
        endDate: Date
    ) async throws -> [ScreenTimeData]
    
    func fetchCombinedScreenTime(
        startDate: Date,
        endDate: Date
    ) async throws -> CombinedScreenTimeResponse
}

Implementation Phases

Phase 1: Core Foundation (Week 1)

Goal: Basic app that can authenticate and display mock data

Tasks:

Deliverable: App that can log in and show a basic dashboard

Phase 2: Screen Time Integration (Week 2)

Goal: Collect real screen time data from iOS

Tasks:

Deliverable: App shows actual iOS screen time data

Phase 3: API Sync (Week 3)

Goal: Sync data to backend

Tasks:

Deliverable: iOS data visible in backend and on macOS app

Phase 4: Cross-Platform Display (Week 4)

Goal: Show macOS data on iOS

Tasks:

Deliverable: Complete app showing iOS + macOS data

Phase 5: Polish & Testing (Week 5)

Goal: Production-ready app

Tasks:

Deliverable: App Store ready application


Key Differences from Old App

Feature Old App (dreamlauncher-ios) New App (DreamLauncherLite)
Lines of Code ~10,000+ ~2,000
Number of Screens 20+ 3 (Auth, Dashboard, Settings)
Dependencies Health, Location, Motion, Beacons Screen Time only
Onboarding Steps 6 1 (Apple Sign-In)
App Extensions 5 2
Background Tasks Multiple complex systems Single sync task
Data Models 15+ Prisma models 2 Core Data entities
Permissions Required 6+ 2 (Sign-In, Family Controls)
API Endpoints Used 20+ 4
Watch App Yes No
Social Features Yes (leaderboard, friends) No
Analytics Complex weekly reports Simple aggregation

Privacy & Permissions

Required Permissions

  1. Family Controls Authorization
    <key>NSUserTrackingUsageDescription</key>
    <string>We need access to screen time to help you track your device usage across platforms.</string>
    
  2. Apple Sign-In
    • Automatic with Sign in with Apple capability

Privacy Policy Updates

Must disclose:

App Store Requirements

Required Capabilities:

App Review Notes:


Testing Strategy

Unit Tests

// AuthServiceTests.swift
- testAppleSignInSuccess()
- testTokenRefresh()
- testKeychainStorage()

// SyncServiceTests.swift
- testBatchUpload()
- testOfflineQueue()
- testRetryLogic()

// ScreenTimeServiceTests.swift
- testDataCollection()
- testAggregation()

Integration Tests

// APIClientTests.swift
- testEndToEndAuth()
- testScreenTimeUpload()
- testCrossPlatformFetch()

Manual Test Cases

  1. Fresh install → Sign in → View dashboard
  2. Add screen time → Wait for sync → Check on macOS
  3. Offline mode → Go online → Verify sync
  4. Background sync → Kill app → Reopen → Verify data
  5. Multiple devices → Verify aggregation

Deployment

App Store Submission Checklist

Prerequisites:

Build Configuration:

App Store Connect:

Special Considerations:


Maintenance & Updates

Future Enhancements (Post-MVP)

Phase 2 Features:

  1. App-level tracking (if Apple allows more granular data)
    • Show which apps consume most time
    • Category breakdown
  2. Notifications
    • Daily summary notifications
    • Weekly reports
  3. Goals & Limits
    • Set daily screen time goals
    • View progress toward goals
  4. Widgets
    • Home screen widget showing today’s time
    • Lock screen widget (iOS 16+)

Integration Opportunities:

  1. Share data with macOS menu bar app
  2. Shortcuts app integration
  3. Focus mode correlation

Cost Estimate

Development Time

Total: ~7-8 weeks

Recurring Costs


Success Metrics

Technical KPIs

User Experience KPIs

Business KPIs


Risk Mitigation

Technical Risks

Risk Impact Mitigation
Family Controls API changes High Monitor beta releases, have fallback plan
Background sync limitations Medium Implement foreground sync priority
API rate limiting Medium Batch requests, implement exponential backoff
Data sync conflicts Low Use timestamps and server-side deduplication

Business Risks

Risk Impact Mitigation
App Store rejection High Thorough documentation, clear use case
User privacy concerns Medium Transparent privacy policy, minimal data collection
Competition Low Unique value prop: cross-platform tracking

Comparison with student-time-tracker

The student-time-tracker iOS monitor is incomplete and follows a similar minimalist approach. Our new app will:

Advantages:

Key Differences:


Next Steps

Immediate Actions

  1. Create new Xcode project - DreamLauncherLite-iOS
  2. Set up Git repository - Separate from old app
  3. Configure Apple Developer account - Request Family Controls
  4. Start Phase 1 implementation - Auth flow

Repository Structure

DreamLauncher/
├── dreamlauncher-api/          (existing)
├── student-time-tracker/       (existing - macOS only)
├── dreamlauncher-ios/          (DEPRECATED - legal issues)
└── dreamlauncher-lite-ios/     (NEW - this plan)

Documentation Needs

  1. API authentication guide (for iOS app)
  2. Screen Time data format specification
  3. Cross-platform sync protocol
  4. Privacy policy for App Store

Conclusion

This streamlined iOS app will:

The app does one thing and does it well: Cross-platform screen time tracking.

No health data. No location tracking. No social features. No bloat.

Just clean, focused screen time monitoring that works seamlessly with your macOS app.