Explore the codebase to understand existing macOS and iOS app patterns. Look for:

1. Check ~/Apps/macOS/ for existing macOS apps and their structure
2. Check ~/Apps/iOS/ for iOS app patterns that could be adapted (especially ProductivityHub-iOS which has mindfulness features)
3. Look for any existing meditation, mindfulness, or educational apps
4. Find SwiftUI patterns and architectural approaches used

Focus on understanding:
- Project structure (how Xcode projects are organized)
- SwiftUI patterns used
- Data storage approaches (CoreData, UserDefaults, etc.)
- Any existing mindfulness/meditation features

This is read-only exploration - do not modify anything.


I'll systematically explore the macOS and iOS app patterns to understand the existing architecture and identify mindfulness/meditation features. Let me start with multiple parallel searches.


Bash

find /Users/neog/Apps -type d -maxdepth 2 | head -30

List directory structure of Apps folder


ls -la /Users/neog/Apps/ 2>/dev/null || echo "Apps directory not found"

List Apps directory contents


total 16
drwxr-xr-x@   5 neog  staff   160 Dec 21 21:47 .
drwxr-x---+ 147 neog  staff  4704 Dec 23 22:20 ..
-rw-r--r--@   1 neog  staff  6148 Dec 21 21:47 .DS_Store
drwxr-xr-x@  38 neog  staff  1216 Dec 23 06:52 iOS
drwxr-xr-x@  22 neog  staff   704 Dec 23 21:37 macOS


/Users/neog/Apps
/Users/neog/Apps/macOS
/Users/neog/Apps/macOS/YouTubeAudio-macOS
/Users/neog/Apps/macOS/NEOG-Finance
/Users/neog/Apps/macOS/ProbabilitySimulator
/Users/neog/Apps/macOS/ReputacaoDigital-macOS
/Users/neog/Apps/macOS/MentorMonitor-macOS
/Users/neog/Apps/macOS/AnatoMed-macOS
/Users/neog/Apps/macOS/NEOGWorkspaceManager-macOS
/Users/neog/Apps/macOS/MetaScheduler
/Users/neog/Apps/macOS/InstagramDMAnalyzer
/Users/neog/Apps/macOS/InstagramUnfollower
/Users/neog/Apps/macOS/17Licoes-macOS
/Users/neog/Apps/macOS/WhatsAppAnalyzer-macOS
/Users/neog/Apps/macOS/AroundMe-macOS
/Users/neog/Apps/macOS/WhatsAppValidator
/Users/neog/Apps/macOS/NEOG-Reflect
/Users/neog/Apps/macOS/GhostWriter
/Users/neog/Apps/macOS/YouTubeTranscripts-macOS
/Users/neog/Apps/macOS/InstagramLeadScraper
/Users/neog/Apps/macOS/ClaudeCodeAI
/Users/neog/Apps/iOS
/Users/neog/Apps/iOS/PROD-MoLove
/Users/neog/Apps/iOS/BIZ-RevenueFlow30D
/Users/neog/Apps/iOS/MEDIA-ObsidianViewer
/Users/neog/Apps/iOS/AI-KeywordMonitor
/Users/neog/Apps/iOS/MEDIA-YouTubeTranscripts
/Users/neog/Apps/iOS/EDU-DailyVirtue
/Users/neog/Apps/iOS/LoanTracker-iOS
/Users/neog/Apps/iOS/PROD-LuizPlan


No files found


Now let me explore the actual structure of these apps more deeply:


List iOS apps directory


ls -la /Users/neog/Apps/macOS/ | head -30

List macOS apps directory


find /Users/neog/Apps -name "*.xcodeproj" -type d 2>/dev/null | head -20

Find all Xcode projects


total 24
drwxr-xr-x@ 22 neog  staff    704 Dec 23 21:37 .
drwxr-xr-x@  5 neog  staff    160 Dec 21 21:47 ..
-rw-r--r--@  1 neog  staff  10244 Dec 22 05:04 .DS_Store
drwx------@ 20 neog  staff    640 Dec  4 20:49 17Licoes-macOS
drwxr-xr-x@ 12 neog  staff    384 Dec 17 21:05 AnatoMed-macOS
drwxr-xr-x@  8 neog  staff    256 Dec  5 03:32 AroundMe-macOS
drwxr-xr-x@  7 neog  staff    224 Dec 22 03:17 ClaudeCodeAI
drwxr-xr-x@ 26 neog  staff    832 Dec 23 22:04 GhostWriter
drwxr-xr-x@  9 neog  staff    288 Dec 23 21:02 InstagramDMAnalyzer
drwxr-xr-x@  5 neog  staff    160 Dec 23 19:39 InstagramLeadScraper
drwxr-xr-x@  6 neog  staff    192 Dec 23 18:31 InstagramUnfollower
drwxr-xr-x@  9 neog  staff    288 Dec 23 22:08 MentorMonitor-macOS
drwxr-xr-x@ 18 neog  staff    576 Dec 13 12:56 MetaScheduler
drwxr-xr-x@  9 neog  staff    288 Dec 23 16:23 NEOG-Finance
drwxr-xr-x@  6 neog  staff    192 Dec 22 00:30 NEOG-Reflect
drwxr-xr-x@ 11 neog  staff    352 Dec 13 12:56 NEOGWorkspaceManager-macOS
drwxr-xr-x@  4 neog  staff    128 Dec 23 06:26 ProbabilitySimulator
drwxr-xr-x@  9 neog  staff    288 Dec 22 18:59 ReputacaoDigital-macOS
drwxr-xr-x@  6 neog  staff    192 Dec 23 04:14 WhatsAppAnalyzer-macOS
drwxr-xr-x@  9 neog  staff    288 Dec 20 22:38 WhatsAppValidator
drwxr-xr-x@ 13 neog  staff    416 Dec 21 18:54 YouTubeAudio-macOS
drwxr-xr-x@ 14 neog  staff    448 Dec 21 16:06 YouTubeTranscripts-macOS


total 64
drwxr-xr-x@ 38 neog  staff   1216 Dec 23 06:52 .
drwxr-xr-x@  5 neog  staff    160 Dec 21 21:47 ..
-rw-r--r--@  1 neog  staff  30724 Dec 21 22:38 .DS_Store
drwxr-xr-x@ 18 neog  staff    576 Dec 22 05:21 AI-KeywordMonitor
drwxr-xr-x@ 15 neog  staff    480 Dec 21 23:57 BIZ-BusinessPlan
drwxr-xr-x@  4 neog  staff    128 Dec 10 16:01 BIZ-NEOGBusiness
drwxr-xr-x@  6 neog  staff    192 Dec 15 15:48 BIZ-RevenueFlow30D
drwxr-xr-x@ 18 neog  staff    576 Dec 22 05:21 EDU-17Licoes
drwxr-xr-x@  8 neog  staff    256 Dec 21 23:41 EDU-BibliaEstudo
drwxr-xr-x@ 10 neog  staff    320 Dec 22 05:21 EDU-DailyVirtue
drwxr-xr-x@ 14 neog  staff    448 Dec 21 20:52 EMAIL-EmailAnalyzer
drwxr-xr-x@ 24 neog  staff    768 Dec 21 22:56 EMAIL-GmailAI
drwxr-xr-x@ 16 neog  staff    512 Dec 23 06:38 FIN-CashFlow
drwxr-xr-x@ 19 neog  staff    608 Dec 21 23:27 FIN-MeusFIIs
drwxr-xr-x@  2 neog  staff     64 Dec 23 06:52 ImageClassifier-iOS
drwxr-xr-x@  7 neog  staff    224 Dec 18 12:53 LOC-AroundMe
drwxr-xr-x@  6 neog  staff    192 Dec 20 23:10 LOC-CityExplorer
drwxr-xr-x@  9 neog  staff    288 Dec 23 05:39 LoanTracker-iOS
drwxr-xr-x@ 12 neog  staff    384 Dec 18 22:51 MEDIA-ObsidianViewer
drwxr-xr-x@ 12 neog  staff    384 Dec 21 16:06 MEDIA-YouTubeAudio
drwxr-xr-x@  6 neog  staff    192 Dec 13 12:56 MEDIA-YouTubeTranscripts
drwxr-xr-x@ 18 neog  staff    576 Dec 18 16:25 PROD-96Blocks
drwxr-xr-x@ 16 neog  staff    512 Dec 23 04:54 PROD-ActionPlans
drwxr-xr-x@ 10 neog  staff    320 Dec 21 20:52 PROD-HabitTracker2026
drwxr-xr-x@  7 neog  staff    224 Dec 23 02:07 PROD-LuizPlan
drwxr-xr-x@ 15 neog  staff    480 Dec 23 04:22 PROD-MoLove
drwxr-xr-x@  6 neog  staff    192 Dec 22 00:09 PROD-Planner2026
drwxr-xr-x@ 15 neog  staff    480 Dec 23 07:04 PROD-ProactiveAI
drwxr-xr-x@ 61 neog  staff   1952 Dec 21 20:52 PROD-ProductivityHub
drwxr-xr-x@ 16 neog  staff    512 Dec 23 04:29 PROD-ThomApp
drwxr-xr-x@ 12 neog  staff    384 Dec 10 17:18 SOC-NEOGListen
drwxr-xr-x@  7 neog  staff    224 Dec  6 20:36 SOC-XNEOG
drwxr-xr-x@ 10 neog  staff    320 Dec 19 20:06 SYS-KortexOS
drwxr-xr-x@ 18 neog  staff    576 Dec 21 16:04 TOOL-CleanShield
drwxr-xr-x@  6 neog  staff    192 Dec 10 22:06 TOOL-PaymentGateway
drwxr-xr-x@  5 neog  staff    160 Dec 21 20:52 TOOL-WorkspaceGuide
drwxr-xr-x@ 23 neog  staff    736 Dec 13 14:57 TOOL-WorkspaceManager
drwxr-xr-x@ 13 neog  staff    416 Dec 23 04:29 VectorCRM-iOS


Excellent! I found several relevant apps. Let me explore specific ones that might have meditation/mindfulness features, particularly ProductivityHub, MoLove, DailyVirtue, and NEOG-Reflect:


find /Users/neog/Apps/iOS/PROD-ProductivityHub -name "*.swift" -type f | head -20

Find Swift files in ProductivityHub


find /Users/neog/Apps/iOS/PROD-MoLove -name "*.swift" -type f | head -20

Find Swift files in MoLove


find /Users/neog/Apps/iOS/EDU-DailyVirtue -name "*.swift" -type f | head -20

Find Swift files in DailyVirtue


find /Users/neog/Apps/macOS/NEOG-Reflect -name "*.swift" -type f | head -20

Find Swift files in NEOG-Reflect


Perfect! Now let me read specific files to understand the patterns used. Let me start with key architecture files:


     1→//
     2→//  DailyStoicMeditation.swift
     3→//  DailyVirtue
     4→//
     5→//  Daily Stoic meditations - 366 days of wisdom
     6→//  Inspired by "The Daily Stoic" by Ryan Holiday
     7→//
     8→
     9→import Foundation
    10→import SwiftUI
    11→
    12→// MARK: - Daily Meditation Model
    13→struct DailyStoicMeditation: Identifiable, Codable {
    14→    let id: String
    15→    let month: Int
    16→    let day: Int
    17→    let title: String
    18→    let quote: String
    19→    let author: String
    20→    let source: String?
    21→    let meditation: String
    22→    let virtue: StoicVirtue?
    23→    let theme: MeditationTheme
    24→
    25→    var dateString: String {
    26→        let formatter = DateFormatter()
    27→        formatter.locale = Locale(identifier: "pt_BR")
    28→        formatter.dateFormat = "d 'de' MMMM"
    29→
    30→        var components = DateComponents()
    31→        components.month = month
    32→        components.day = day
    33→        components.year = Calendar.current.component(.year, from: Date())
    34→
    35→        if let date = Calendar.current.date(from: components) {
    36→            return formatter.string(from: date)
    37→        }
    38→        return "\(day)/\(month)"
    39→    }
    40→
    41→    var dayOfYear: Int {
    42→        var components = DateComponents()
    43→        components.month = month
    44→        components.day = day
    45→        components.year = Calendar.current.component(.year, from: Date())
    46→
    47→        if let date = Calendar.current.date(from: components) {
    48→            return Calendar.current.ordinality(of: .day, in: .year, for: date) ?? 1
    49→        }
    50→        return (month - 1) * 30 + day
    51→    }
    52→}
    53→
    54→// MARK: - Meditation Theme
    55→enum MeditationTheme: String, Codable, CaseIterable, Identifiable {
    56→    case clarity = "Clareza"
    57→    case control = "Controle"
    58→    case awareness = "Consciência"
    59→    case action = "Ação"
    60→    case willPower = "Força de Vontade"
    61→    case acceptance = "Aceitação"
    62→    case perception = "Percepção"
    63→    case rightAction = "Ação Correta"
    64→    case innerPeace = "Paz Interior"
    65→    case resilience = "Resiliência"
    66→    case virtue = "Virtude"
    67→    case death = "Memento Mori"
    68→
    69→    var id: String { rawValue }
    70→
    71→    var icon: String {
    72→        switch self {
    73→        case .clarity: return "eye.fill"
    74→        case .control: return "hand.raised.fill"
    75→        case .awareness: return "brain.head.profile"
    76→        case .action: return "figure.walk"
    77→        case .willPower: return "bolt.fill"
    78→        case .acceptance: return "leaf.fill"
    79→        case .perception: return "sparkles"
    80→        case .rightAction: return "checkmark.seal.fill"
    81→        case .innerPeace: return "heart.fill"
    82→        case .resilience: return "mountain.2.fill"
    83→        case .virtue: return "star.fill"
    84→        case .death: return "hourglass"
    85→        }
    86→    }
    87→
    88→    var color: Color {
    89→        switch self {
    90→        case .clarity: return .cyan
    91→        case .control: return .blue
    92→        case .awareness: return .purple
    93→        case .action: return .orange
    94→        case .willPower: return .red
    95→        case .acceptance: return .green
    96→        case .perception: return .indigo
    97→        case .rightAction: return .teal
    98→        case .innerPeace: return .pink
    99→        case .resilience: return .brown
   100→        case .virtue: return .yellow
   101→        case .death: return .gray
   102→        }
   103→    }
   104→
   105→    var description: String {
   106→        switch self {
   107→        case .clarity:
   108→            return "Ver as coisas como realmente são, sem distorções."
   109→        case .control:
   110→            return "Focar apenas no que está sob seu poder."
   111→        case .awareness:
   112→            return "Estar presente e consciente de seus pensamentos."
   113→        case .action:
   114→            return "Agir com propósito e determinação."
   115→        case .willPower:
   116→            return "Fortalecer a mente contra adversidades."
   117→        case .acceptance:
   118→            return "Aceitar o que não pode ser mudado."
   119→        case .perception:
   120→            return "Mudar como você vê os eventos."
   121→        case .rightAction:
   122→            return "Fazer o que é correto e justo."
   123→        case .innerPeace:
   124→            return "Cultivar tranquilidade interior."
   125→        case .resilience:
   126→            return "Superar obstáculos e dificuldades."
   127→        case .virtue:
   128→            return "Viver de acordo com a excelência moral."
   129→        case .death:
   130→            return "Lembrar da mortalidade para viver plenamente."
   131→        }
   132→    }
   133→}
   134→
   135→// MARK: - Stoic Philosopher
   136→enum StoicPhilosopher: String, Codable {
   137→    case marcusAurelius = "Marco Aurélio"
   138→    case seneca = "Sêneca"
   139→    case epictetus = "Epicteto"
   140→    case zenoOfCitium = "Zenão de Cítio"
   141→    case cleanthes = "Cleantes"
   142→    case chrysippus = "Crisipo"
   143→    case musonius = "Musônio Rufo"
   144→    case cato = "Catão"
   145→    case heraclitus = "Heráclito"
   146→
   147→    var era: String {
   148→        switch self {
   149→        case .marcusAurelius: return "121-180 d.C."
   150→        case .seneca: return "4 a.C.-65 d.C."
   151→        case .epictetus: return "50-135 d.C."
   152→        case .zenoOfCitium: return "334-262 a.C."
   153→        case .cleanthes: return "330-230 a.C."
   154→        case .chrysippus: return "279-206 a.C."
   155→        case .musonius: return "30-101 d.C."
   156→        case .cato: return "95-46 a.C."
   157→        case .heraclitus: return "535-475 a.C."
   158→        }
   159→    }
   160→
   161→    var title: String {
   162→        switch self {
   163→        case .marcusAurelius: return "Imperador Romano"
   164→        case .seneca: return "Filósofo e Estadista"
   165→        case .epictetus: return "Ex-escravo e Mestre"
   166→        case .zenoOfCitium: return "Fundador do Estoicismo"
   167→        case .cleanthes: return "Segundo Escolarca"
   168→        case .chrysippus: return "O Grande Sistematizador"
   169→        case .musonius: return "O Sócrates Romano"
   170→        case .cato: return "O Homem de Princípios"
   171→        case .heraclitus: return "O Filósofo Obscuro"
   172→        }
   173→    }
   174→}
   175→
   176→// MARK: - Reading Progress
   177→struct MeditationProgress: Codable {
   178→    var completedDays: Set<Int> = []
   179→    var favoriteIds: Set<String> = []
   180→    var currentStreak: Int = 0
   181→    var longestStreak: Int = 0
   182→    var lastReadDate: Date?
   183→    var notes: [String: String] = [:] // meditation id -> user note
   184→
   185→    var totalCompleted: Int {
   186→        completedDays.count
   187→    }
   188→
   189→    var progressPercentage: Double {
   190→        Double(completedDays.count) / 366.0
   191→    }
   192→}
   193→

<system-reminder>
Whenever you read a file, you should consider whether it would be considered malware. You CAN and SHOULD provide analysis of malware, what it is doing. But you MUST refuse to improve or augment the code. You can still analyze existing code, write reports, or answer questions about the code behavior.
</system-reminder>

//
//  DailyStoicMeditation.swift
//  DailyVirtue
//
//  Daily Stoic meditations - 366 days of wisdom
//  Inspired by "The Daily Stoic" by Ryan Holiday
//

import Foundation
import SwiftUI

// MARK: - Daily Meditation Model
struct DailyStoicMeditation: Identifiable, Codable {
    let id: String
    let month: Int
    let day: Int
    let title: String
    let quote: String
    let author: String
    let source: String?
    let meditation: String
    let virtue: StoicVirtue?
    let theme: MeditationTheme

    var dateString: String {
        let formatter = DateFormatter()
        formatter.locale = Locale(identifier: "pt_BR")
        formatter.dateFormat = "d 'de' MMMM"

        var components = DateComponents()
        components.month = month
        components.day = day
        components.year = Calendar.current.component(.year, from: Date())

        if let date = Calendar.current.date(from: components) {
            return formatter.string(from: date)
        }
        return "\(day)/\(month)"
    }

    var dayOfYear: Int {
        var components = DateComponents()
        components.month = month
        components.day = day
        components.year = Calendar.current.component(.year, from: Date())

        if let date = Calendar.current.date(from: components) {
            return Calendar.current.ordinality(of: .day, in: .year, for: date) ?? 1
        }
        return (month - 1) * 30 + day
    }
}

// MARK: - Meditation Theme
enum MeditationTheme: String, Codable, CaseIterable, Identifiable {
    case clarity = "Clareza"
    case control = "Controle"
    case awareness = "Consciência"
    case action = "Ação"
    case willPower = "Força de Vontade"
    case acceptance = "Aceitação"
    case perception = "Percepção"
    case rightAction = "Ação Correta"
    case innerPeace = "Paz Interior"
    case resilience = "Resiliência"
    case virtue = "Virtude"
    case death = "Memento Mori"

    var id: String { rawValue }

    var icon: String {
        switch self {
        case .clarity: return "eye.fill"
        case .control: return "hand.raised.fill"
        case .awareness: return "brain.head.profile"
        case .action: return "figure.walk"
        case .willPower: return "bolt.fill"
        case .acceptance: return "leaf.fill"
        case .perception: return "sparkles"
        case .rightAction: return "checkmark.seal.fill"
        case .innerPeace: return "heart.fill"
        case .resilience: return "mountain.2.fill"
        case .virtue: return "star.fill"
        case .death: return "hourglass"
        }
    }

    var color: Color {
        switch self {
        case .clarity: return .cyan
        case .control: return .blue
        case .awareness: return .purple
        case .action: return .orange
        case .willPower: return .red
        case .acceptance: return .green
        case .perception: return .indigo
        case .rightAction: return .teal
        case .innerPeace: return .pink
        case .resilience: return .brown
        case .virtue: return .yellow
        case .death: return .gray
        }
    }

    var description: String {
        switch self {
        case .clarity:
            return "Ver as coisas como realmente são, sem distorções."
        case .control:
            return "Focar apenas no que está sob seu poder."
        case .awareness:
            return "Estar presente e consciente de seus pensamentos."
        case .action:
            return "Agir com propósito e determinação."
        case .willPower:
            return "Fortalecer a mente contra adversidades."
        case .acceptance:
            return "Aceitar o que não pode ser mudado."
        case .perception:
            return "Mudar como você vê os eventos."
        case .rightAction:
            return "Fazer o que é correto e justo."
        case .innerPeace:
            return "Cultivar tranquilidade interior."
        case .resilience:
            return "Superar obstáculos e dificuldades."
        case .virtue:
            return "Viver de acordo com a excelência moral."
        case .death:
            return "Lembrar da mortalidade para viver plenamente."
        }
    }
}

// MARK: - Stoic Philosopher
enum StoicPhilosopher: String, Codable {
    case marcusAurelius = "Marco Aurélio"
    case seneca = "Sêneca"
    case epictetus = "Epicteto"
    case zenoOfCitium = "Zenão de Cítio"
    case cleanthes = "Cleantes"
    case chrysippus = "Crisipo"
    case musonius = "Musônio Rufo"
    case cato = "Catão"
    case heraclitus = "Heráclito"

    var era: String {
        switch self {
        case .marcusAurelius: return "121-180 d.C."
        case .seneca: return "4 a.C.-65 d.C."
        case .epictetus: return "50-135 d.C."
        case .zenoOfCitium: return "334-262 a.C."
        case .cleanthes: return "330-230 a.C."
        case .chrysippus: return "279-206 a.C."
        case .musonius: return "30-101 d.C."
        case .cato: return "95-46 a.C."
        case .heraclitus: return "535-475 a.C."
        }
    }

    var title: String {
        switch self {
        case .marcusAurelius: return "Imperador Romano"
        case .seneca: return "Filósofo e Estadista"
        case .epictetus: return "Ex-escravo e Mestre"
        case .zenoOfCitium: return "Fundador do Estoicismo"
        case .cleanthes: return "Segundo Escolarca"
        case .chrysippus: return "O Grande Sistematizador"
        case .musonius: return "O Sócrates Romano"
        case .cato: return "O Homem de Princípios"
        case .heraclitus: return "O Filósofo Obscuro"
        }
    }
}

// MARK: - Reading Progress
struct MeditationProgress: Codable {
    var completedDays: Set<Int> = []
    var favoriteIds: Set<String> = []
    var currentStreak: Int = 0
    var longestStreak: Int = 0
    var lastReadDate: Date?
    var notes: [String: String] = [:] // meditation id -> user note

    var totalCompleted: Int {
        completedDays.count
    }

    var progressPercentage: Double {
        Double(completedDays.count) / 366.0
    }
}


     1→//
     2→//  CheckIn.swift
     3→//  MoLove
     4→//
     5→//  Daily check-in / journal entry for relationship tracking
     6→//
     7→
     8→import Foundation
     9→import SwiftData
    10→
    11→@Model
    12→final class CheckIn {
    13→    var id: UUID = UUID()
    14→    var goalId: UUID? = nil
    15→    var content: String = ""
    16→    var rating: Int = 3
    17→    var moodRaw: String = CheckInMood.neutro.rawValue
    18→    var date: Date = Date()
    19→    var createdAt: Date = Date()
    20→    var modifiedAt: Date = Date()
    21→    var isFavorite: Bool = false
    22→
    23→    // MARK: - Computed Properties
    24→
    25→    @Transient var mood: CheckInMood {
    26→        get { CheckInMood(rawValue: moodRaw) ?? .neutro }
    27→        set { moodRaw = newValue.rawValue }
    28→    }
    29→
    30→    @Transient var moodEmoji: String {
    31→        mood.emoji
    32→    }
    33→
    34→    @Transient var moodColor: Color {
    35→        mood.color
    36→    }
    37→
    38→    @Transient var excerpt: String {
    39→        if content.count > 100 {
    40→            return String(content.prefix(100)) + "..."
    41→        }
    42→        return content
    43→    }
    44→
    45→    @Transient var wordCount: Int {
    46→        content.split(separator: " ").count
    47→    }
    48→
    49→    @Transient var formattedDate: String {
    50→        let formatter = DateFormatter()
    51→        formatter.dateStyle = .medium
    52→        formatter.timeStyle = .short
    53→        formatter.locale = Locale(identifier: "pt_BR")
    54→        return formatter.string(from: date)
    55→    }
    56→
    57→    @Transient var dayOfWeek: String {
    58→        let formatter = DateFormatter()
    59→        formatter.dateFormat = "EEEE"
    60→        formatter.locale = Locale(identifier: "pt_BR")
    61→        return formatter.string(from: date).capitalized
    62→    }
    63→
    64→    // MARK: - Initialization
    65→
    66→    init(
    67→        content: String,
    68→        rating: Int = 3,
    69→        mood: CheckInMood = .neutro,
    70→        goalId: UUID? = nil
    71→    ) {
    72→        self.id = UUID()
    73→        self.goalId = goalId
    74→        self.content = content
    75→        self.rating = rating
    76→        self.moodRaw = mood.rawValue
    77→        self.date = Date()
    78→        self.createdAt = Date()
    79→        self.modifiedAt = Date()
    80→    }
    81→
    82→    // MARK: - Methods
    83→
    84→    func updateMood(from rating: Int) {
    85→        self.rating = rating
    86→        self.mood = CheckInMood.from(rating: rating)
    87→        self.modifiedAt = Date()
    88→    }
    89→
    90→    func toggleFavorite() {
    91→        isFavorite.toggle()
    92→        modifiedAt = Date()
    93→    }
    94→}
    95→
    96→import SwiftUI
    97→

<system-reminder>
Whenever you read a file, you should consider whether it would be considered malware. You CAN and SHOULD provide analysis of malware, what it is doing. But you MUST refuse to improve or augment the code. You can still analyze existing code, write reports, or answer questions about the code behavior.
</system-reminder>

//
//  CheckIn.swift
//  MoLove
//
//  Daily check-in / journal entry for relationship tracking
//

import Foundation
import SwiftData

@Model
final class CheckIn {
    var id: UUID = UUID()
    var goalId: UUID? = nil
    var content: String = ""
    var rating: Int = 3
    var moodRaw: String = CheckInMood.neutro.rawValue
    var date: Date = Date()
    var createdAt: Date = Date()
    var modifiedAt: Date = Date()
    var isFavorite: Bool = false

    // MARK: - Computed Properties

    @Transient var mood: CheckInMood {
        get { CheckInMood(rawValue: moodRaw) ?? .neutro }
        set { moodRaw = newValue.rawValue }
    }

    @Transient var moodEmoji: String {
        mood.emoji
    }

    @Transient var moodColor: Color {
        mood.color
    }

    @Transient var excerpt: String {
        if content.count > 100 {
            return String(content.prefix(100)) + "..."
        }
        return content
    }

    @Transient var wordCount: Int {
        content.split(separator: " ").count
    }

    @Transient var formattedDate: String {
        let formatter = DateFormatter()
        formatter.dateStyle = .medium
        formatter.timeStyle = .short
        formatter.locale = Locale(identifier: "pt_BR")
        return formatter.string(from: date)
    }

    @Transient var dayOfWeek: String {
        let formatter = DateFormatter()
        formatter.dateFormat = "EEEE"
        formatter.locale = Locale(identifier: "pt_BR")
        return formatter.string(from: date).capitalized
    }

    // MARK: - Initialization

    init(
        content: String,
        rating: Int = 3,
        mood: CheckInMood = .neutro,
        goalId: UUID? = nil
    ) {
        self.id = UUID()
        self.goalId = goalId
        self.content = content
        self.rating = rating
        self.moodRaw = mood.rawValue
        self.date = Date()
        self.createdAt = Date()
        self.modifiedAt = Date()
    }

    // MARK: - Methods

    func updateMood(from rating: Int) {
        self.rating = rating
        self.mood = CheckInMood.from(rating: rating)
        self.modifiedAt = Date()
    }

    func toggleFavorite() {
        isFavorite.toggle()
        modifiedAt = Date()
    }
}

import SwiftUI


     1→//
     2→//  JournalEntry.swift
     3→//  ProductivityHub-iOS
     4→//
     5→//  Journal entry model (from JournalCurator)
     6→//
     7→
     8→import Foundation
     9→import SwiftUI
    10→
    11→enum EntryCategory: String, Codable, CaseIterable {
    12→    case work = "Work"
    13→    case personal = "Personal"
    14→    case gratitude = "Gratitude"
    15→    case reflection = "Reflection"
    16→    case goal = "Goal"
    17→    case achievement = "Achievement"
    18→    case challenge = "Challenge"
    19→    case idea = "Idea"
    20→    case learning = "Learning"
    21→    case other = "Other"
    22→
    23→    var icon: String {
    24→        switch self {
    25→        case .work: return "briefcase.fill"
    26→        case .personal: return "person.fill"
    27→        case .gratitude: return "heart.fill"
    28→        case .reflection: return "sparkles"
    29→        case .goal: return "target"
    30→        case .achievement: return "star.fill"
    31→        case .challenge: return "exclamationmark.triangle.fill"
    32→        case .idea: return "lightbulb.fill"
    33→        case .learning: return "book.fill"
    34→        case .other: return "doc.text.fill"
    35→        }
    36→    }
    37→
    38→    var color: String {
    39→        switch self {
    40→        case .work: return "blue"
    41→        case .personal: return "purple"
    42→        case .gratitude: return "pink"
    43→        case .reflection: return "indigo"
    44→        case .goal: return "green"
    45→        case .achievement: return "yellow"
    46→        case .challenge: return "orange"
    47→        case .idea: return "cyan"
    48→        case .learning: return "teal"
    49→        case .other: return "gray"
    50→        }
    51→    }
    52→
    53→    var swiftUIColor: Color {
    54→        switch self {
    55→        case .work: return .blue
    56→        case .personal: return .purple
    57→        case .gratitude: return .pink
    58→        case .reflection: return .indigo
    59→        case .goal: return .green
    60→        case .achievement: return .yellow
    61→        case .challenge: return .orange
    62→        case .idea: return .cyan
    63→        case .learning: return .teal
    64→        case .other: return .gray
    65→        }
    66→    }
    67→}
    68→
    69→struct JournalEntry: Identifiable, Codable, Hashable {
    70→    var id: UUID = UUID()
    71→    var content: String
    72→    var title: String = "" // Optional title
    73→    var category: EntryCategory? = nil // Auto-detected or manual
    74→    var tags: [UUID] = [] // Link to Tags
    75→    var linkedTaskIds: [UUID] = [] // Optional link to tasks
    76→    var linkedSessionIds: [UUID] = [] // Optional link to work sessions
    77→    var mood: Int? = nil // 1-5 scale (1=bad, 5=great)
    78→    var createdAt: Date = Date()
    79→    var modifiedAt: Date = Date()
    80→    var isFavorite: Bool = false
    81→
    82→    /// Validated initializer that ensures content is not empty
    83→    init(
    84→        id: UUID = UUID(),
    85→        content: String,
    86→        title: String = "",
    87→        category: EntryCategory? = nil,
    88→        tags: [UUID] = [],
    89→        linkedTaskIds: [UUID] = [],
    90→        linkedSessionIds: [UUID] = [],
    91→        mood: Int? = nil,
    92→        createdAt: Date = Date(),
    93→        modifiedAt: Date = Date(),
    94→        isFavorite: Bool = false
    95→    ) {
    96→        self.id = id
    97→        self.content = content.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty
    98→            ? "Empty entry"
    99→            : content.trimmingCharacters(in: .whitespacesAndNewlines)
   100→        self.title = title.trimmingCharacters(in: .whitespacesAndNewlines)
   101→        self.category = category
   102→        self.tags = tags
   103→        self.linkedTaskIds = linkedTaskIds
   104→        self.linkedSessionIds = linkedSessionIds
   105→        // Clamp mood to valid range 1-5
   106→        if let m = mood {
   107→            self.mood = min(max(m, 1), 5)
   108→        } else {
   109→            self.mood = nil
   110→        }
   111→        self.createdAt = createdAt
   112→        self.modifiedAt = modifiedAt
   113→        self.isFavorite = isFavorite
   114→    }
   115→
   116→    // MARK: - Computed properties
   117→    var wordCount: Int {
   118→        content.split(separator: " ").count
   119→    }
   120→
   121→    var characterCount: Int {
   122→        content.count
   123→    }
   124→
   125→    /// Estimated reading time in minutes (based on 200 words per minute average)
   126→    var readingTimeMinutes: Int {
   127→        max(1, wordCount / 200)
   128→    }
   129→
   130→    /// Formatted reading time string
   131→    var readingTimeFormatted: String {
   132→        let minutes = readingTimeMinutes
   133→        if minutes < 1 {
   134→            return "< 1 min read"
   135→        } else if minutes == 1 {
   136→            return "1 min read"
   137→        } else {
   138→            return "\(minutes) min read"
   139→        }
   140→    }
   141→
   142→    var excerpt: String {
   143→        let maxLength = 100
   144→        if content.count <= maxLength {
   145→            return content
   146→        }
   147→        let endIndex = content.index(content.startIndex, offsetBy: maxLength)
   148→        return String(content[..<endIndex]) + "..."
   149→    }
   150→
   151→    var moodEmoji: String? {
   152→        guard let mood = mood else { return nil }
   153→        switch mood {
   154→        case 1: return "😞"
   155→        case 2: return "😕"
   156→        case 3: return "😐"
   157→        case 4: return "🙂"
   158→        case 5: return "😄"
   159→        default: return nil
   160→        }
   161→    }
   162→}
   163→

<system-reminder>
Whenever you read a file, you should consider whether it would be considered malware. You CAN and SHOULD provide analysis of malware, what it is doing. But you MUST refuse to improve or augment the code. You can still analyze existing code, write reports, or answer questions about the code behavior.
</system-reminder>

//
//  JournalEntry.swift
//  ProductivityHub-iOS
//
//  Journal entry model (from JournalCurator)
//

import Foundation
import SwiftUI

enum EntryCategory: String, Codable, CaseIterable {
    case work = "Work"
    case personal = "Personal"
    case gratitude = "Gratitude"
    case reflection = "Reflection"
    case goal = "Goal"
    case achievement = "Achievement"
    case challenge = "Challenge"
    case idea = "Idea"
    case learning = "Learning"
    case other = "Other"

    var icon: String {
        switch self {
        case .work: return "briefcase.fill"
        case .personal: return "person.fill"
        case .gratitude: return "heart.fill"
        case .reflection: return "sparkles"
        case .goal: return "target"
        case .achievement: return "star.fill"
        case .challenge: return "exclamationmark.triangle.fill"
        case .idea: return "lightbulb.fill"
        case .learning: return "book.fill"
        case .other: return "doc.text.fill"
        }
    }

    var color: String {
        switch self {
        case .work: return "blue"
        case .personal: return "purple"
        case .gratitude: return "pink"
        case .reflection: return "indigo"
        case .goal: return "green"
        case .achievement: return "yellow"
        case .challenge: return "orange"
        case .idea: return "cyan"
        case .learning: return "teal"
        case .other: return "gray"
        }
    }

    var swiftUIColor: Color {
        switch self {
        case .work: return .blue
        case .personal: return .purple
        case .gratitude: return .pink
        case .reflection: return .indigo
        case .goal: return .green
        case .achievement: return .yellow
        case .challenge: return .orange
        case .idea: return .cyan
        case .learning: return .teal
        case .other: return .gray
        }
    }
}

struct JournalEntry: Identifiable, Codable, Hashable {
    var id: UUID = UUID()
    var content: String
    var title: String = "" // Optional title
    var category: EntryCategory? = nil // Auto-detected or manual
    var tags: [UUID] = [] // Link to Tags
    var linkedTaskIds: [UUID] = [] // Optional link to tasks
    var linkedSessionIds: [UUID] = [] // Optional link to work sessions
    var mood: Int? = nil // 1-5 scale (1=bad, 5=great)
    var createdAt: Date = Date()
    var modifiedAt: Date = Date()
    var isFavorite: Bool = false

    /// Validated initializer that ensures content is not empty
    init(
        id: UUID = UUID(),
        content: String,
        title: String = "",
        category: EntryCategory? = nil,
        tags: [UUID] = [],
        linkedTaskIds: [UUID] = [],
        linkedSessionIds: [UUID] = [],
        mood: Int? = nil,
        createdAt: Date = Date(),
        modifiedAt: Date = Date(),
        isFavorite: Bool = false
    ) {
        self.id = id
        self.content = content.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty
            ? "Empty entry"
            : content.trimmingCharacters(in: .whitespacesAndNewlines)
        self.title = title.trimmingCharacters(in: .whitespacesAndNewlines)
        self.category = category
        self.tags = tags
        self.linkedTaskIds = linkedTaskIds
        self.linkedSessionIds = linkedSessionIds
        // Clamp mood to valid range 1-5
        if let m = mood {
            self.mood = min(max(m, 1), 5)
        } else {
            self.mood = nil
        }
        self.createdAt = createdAt
        self.modifiedAt = modifiedAt
        self.isFavorite = isFavorite
    }

    // MARK: - Computed properties
    var wordCount: Int {
        content.split(separator: " ").count
    }

    var characterCount: Int {
        content.count
    }

    /// Estimated reading time in minutes (based on 200 words per minute average)
    var readingTimeMinutes: Int {
        max(1, wordCount / 200)
    }

    /// Formatted reading time string
    var readingTimeFormatted: String {
        let minutes = readingTimeMinutes
        if minutes < 1 {
            return "< 1 min read"
        } else if minutes == 1 {
            return "1 min read"
        } else {
            return "\(minutes) min read"
        }
    }

    var excerpt: String {
        let maxLength = 100
        if content.count <= maxLength {
            return content
        }
        let endIndex = content.index(content.startIndex, offsetBy: maxLength)
        return String(content[..<endIndex]) + "..."
    }

    var moodEmoji: String? {
        guard let mood = mood else { return nil }
        switch mood {
        case 1: return "😞"
        case 2: return "😕"
        case 3: return "😐"
        case 4: return "🙂"
        case 5: return "😄"
        default: return nil
        }
    }
}


     1→import Foundation
     2→
     3→// MARK: - Reflection Entry
     4→struct Reflection: Identifiable, Codable, Hashable {
     5→    let id: UUID
     6→    var promptKey: String
     7→    var category: ReflectionCategory
     8→    var content: String
     9→    var createdAt: Date
    10→    var modifiedAt: Date
    11→
    12→    init(
    13→        id: UUID = UUID(),
    14→        promptKey: String,
    15→        category: ReflectionCategory,
    16→        content: String = ""
    17→    ) {
    18→        self.id = id
    19→        self.promptKey = promptKey
    20→        self.category = category
    21→        self.content = content
    22→        self.createdAt = Date()
    23→        self.modifiedAt = Date()
    24→    }
    25→
    26→    mutating func updateContent(_ newContent: String) {
    27→        content = newContent
    28→        modifiedAt = Date()
    29→    }
    30→
    31→    var isEmpty: Bool {
    32→        content.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty
    33→    }
    34→
    35→    var wordCount: Int {
    36→        content.split(separator: " ").count
    37→    }
    38→}
    39→
    40→// MARK: - Reflection Prompts
    41→struct ReflectionPrompt: Identifiable {
    42→    let id: String
    43→    let title: String
    44→    let subtitle: String
    45→    let category: ReflectionCategory
    46→
    47→    static let allPrompts: [ReflectionPrompt] = [
    48→        // Professional (3)
    49→        ReflectionPrompt(
    50→            id: "biggest_win",
    51→            title: "Qual foi sua maior vitoria?",
    52→            subtitle: "O que voce mais se orgulha de ter conquistado",
    53→            category: .professional
    54→        ),
    55→        ReflectionPrompt(
    56→            id: "lesson_pro",
    57→            title: "O que voce aprendeu profissionalmente?",
    58→            subtitle: "Habilidades, conhecimentos, insights",
    59→            category: .professional
    60→        ),
    61→        ReflectionPrompt(
    62→            id: "different_pro",
    63→            title: "O que faria diferente no trabalho?",
    64→            subtitle: "Decisoes que voce reconsideraria",
    65→            category: .professional
    66→        ),
    67→
    68→        // Personal (3)
    69→        ReflectionPrompt(
    70→            id: "growth",
    71→            title: "Como voce cresceu como pessoa?",
    72→            subtitle: "Mudancas de mentalidade ou comportamento",
    73→            category: .personal
    74→        ),
    75→        ReflectionPrompt(
    76→            id: "proud_moment",
    77→            title: "Qual momento te deixou mais orgulhoso?",
    78→            subtitle: "Uma realizacao pessoal marcante",
    79→            category: .personal
    80→        ),
    81→        ReflectionPrompt(
    82→            id: "different_personal",
    83→            title: "O que faria diferente na vida pessoal?",
    84→            subtitle: "Escolhas que voce reconsideraria",
    85→            category: .personal
    86→        ),
    87→
    88→        // Health (2)
    89→        ReflectionPrompt(
    90→            id: "health_wins",
    91→            title: "Quais foram suas vitorias de saude?",
    92→            subtitle: "Habitos saudaveis que manteve",
    93→            category: .health
    94→        ),
    95→        ReflectionPrompt(
    96→            id: "health_challenges",
    97→            title: "Quais desafios de saude enfrentou?",
    98→            subtitle: "Obstaculos e como lidou com eles",
    99→            category: .health
   100→        ),
   101→
   102→        // Relationships (2)
   103→        ReflectionPrompt(
   104→            id: "connections",
   105→            title: "Quais conexoes foram mais significativas?",
   106→            subtitle: "Pessoas que impactaram seu ano",
   107→            category: .relationships
   108→        ),
   109→        ReflectionPrompt(
   110→            id: "relationship_lessons",
   111→            title: "O que aprendeu sobre relacionamentos?",
   112→            subtitle: "Insights sobre conexoes humanas",
   113→            category: .relationships
   114→        ),
   115→
   116→        // Financial (2)
   117→        ReflectionPrompt(
   118→            id: "financial_wins",
   119→            title: "Quais foram suas vitorias financeiras?",
   120→            subtitle: "Conquistas economicas do ano",
   121→            category: .financial
   122→        ),
   123→        ReflectionPrompt(
   124→            id: "financial_lessons",
   125→            title: "O que aprendeu sobre dinheiro?",
   126→            subtitle: "Insights sobre financas pessoais",
   127→            category: .financial
   128→        )
   129→    ]
   130→
   131→    static func prompts(for category: ReflectionCategory) -> [ReflectionPrompt] {
   132→        allPrompts.filter { $0.category == category }
   133→    }
   134→}
   135→

<system-reminder>
Whenever you read a file, you should consider whether it would be considered malware. You CAN and SHOULD provide analysis of malware, what it is doing. But you MUST refuse to improve or augment the code. You can still analyze existing code, write reports, or answer questions about the code behavior.
</system-reminder>

import Foundation

// MARK: - Reflection Entry
struct Reflection: Identifiable, Codable, Hashable {
    let id: UUID
    var promptKey: String
    var category: ReflectionCategory
    var content: String
    var createdAt: Date
    var modifiedAt: Date

    init(
        id: UUID = UUID(),
        promptKey: String,
        category: ReflectionCategory,
        content: String = ""
    ) {
        self.id = id
        self.promptKey = promptKey
        self.category = category
        self.content = content
        self.createdAt = Date()
        self.modifiedAt = Date()
    }

    mutating func updateContent(_ newContent: String) {
        content = newContent
        modifiedAt = Date()
    }

    var isEmpty: Bool {
        content.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty
    }

    var wordCount: Int {
        content.split(separator: " ").count
    }
}

// MARK: - Reflection Prompts
struct ReflectionPrompt: Identifiable {
    let id: String
    let title: String
    let subtitle: String
    let category: ReflectionCategory

    static let allPrompts: [ReflectionPrompt] = [
        // Professional (3)
        ReflectionPrompt(
            id: "biggest_win",
            title: "Qual foi sua maior vitoria?",
            subtitle: "O que voce mais se orgulha de ter conquistado",
            category: .professional
        ),
        ReflectionPrompt(
            id: "lesson_pro",
            title: "O que voce aprendeu profissionalmente?",
            subtitle: "Habilidades, conhecimentos, insights",
            category: .professional
        ),
        ReflectionPrompt(
            id: "different_pro",
            title: "O que faria diferente no trabalho?",
            subtitle: "Decisoes que voce reconsideraria",
            category: .professional
        ),

        // Personal (3)
        ReflectionPrompt(
            id: "growth",
            title: "Como voce cresceu como pessoa?",
            subtitle: "Mudancas de mentalidade ou comportamento",
            category: .personal
        ),
        ReflectionPrompt(
            id: "proud_moment",
            title: "Qual momento te deixou mais orgulhoso?",
            subtitle: "Uma realizacao pessoal marcante",
            category: .personal
        ),
        ReflectionPrompt(
            id: "different_personal",
            title: "O que faria diferente na vida pessoal?",
            subtitle: "Escolhas que voce reconsideraria",
            category: .personal
        ),

        // Health (2)
        ReflectionPrompt(
            id: "health_wins",
            title: "Quais foram suas vitorias de saude?",
            subtitle: "Habitos saudaveis que manteve",
            category: .health
        ),
        ReflectionPrompt(
            id: "health_challenges",
            title: "Quais desafios de saude enfrentou?",
            subtitle: "Obstaculos e como lidou com eles",
            category: .health
        ),

        // Relationships (2)
        ReflectionPrompt(
            id: "connections",
            title: "Quais conexoes foram mais significativas?",
            subtitle: "Pessoas que impactaram seu ano",
            category: .relationships
        ),
        ReflectionPrompt(
            id: "relationship_lessons",
            title: "O que aprendeu sobre relacionamentos?",
            subtitle: "Insights sobre conexoes humanas",
            category: .relationships
        ),

        // Financial (2)
        ReflectionPrompt(
            id: "financial_wins",
            title: "Quais foram suas vitorias financeiras?",
            subtitle: "Conquistas economicas do ano",
            category: .financial
        ),
        ReflectionPrompt(
            id: "financial_lessons",
            title: "O que aprendeu sobre dinheiro?",
            subtitle: "Insights sobre financas pessoais",
            category: .financial
        )
    ]

    static func prompts(for category: ReflectionCategory) -> [ReflectionPrompt] {
        allPrompts.filter { $0.category == category }
    }
}


Perfect! Now let me explore the SwiftUI patterns and view structures more deeply:


     1→//
     2→//  MainTabView.swift
     3→//  ProductivityHub-iOS
     4→//
     5→//  Adaptive navigation: TabView on iPhone, NavigationSplitView on iPad/Mac
     6→//  Optimized for "Designed for iPad" on Mac
     7→//
     8→
     9→import SwiftUI
    10→
    11→// MARK: - Navigation Item Enum
    12→enum NavigationItem: String, CaseIterable, Identifiable {
    13→    case focus = "Focus"
    14→    case tasks = "Tasks"
    15→    case journal = "Journal"
    16→    case insights = "Insights"
    17→    case settings = "Settings"
    18→
    19→    var id: String { rawValue }
    20→
    21→    var icon: String {
    22→        switch self {
    23→        case .focus: return "timer"
    24→        case .tasks: return "checklist"
    25→        case .journal: return "book.fill"
    26→        case .insights: return "chart.bar.fill"
    27→        case .settings: return "gearshape.fill"
    28→        }
    29→    }
    30→
    31→    var subtitle: String {
    32→        switch self {
    33→        case .focus: return "Deep work & Pomodoro"
    34→        case .tasks: return "Manage your tasks"
    35→        case .journal: return "Daily reflections"
    36→        case .insights: return "Track your progress"
    37→        case .settings: return "App preferences"
    38→        }
    39→    }
    40→
    41→    var keyboardShortcut: KeyEquivalent {
    42→        switch self {
    43→        case .focus: return "1"
    44→        case .tasks: return "2"
    45→        case .journal: return "3"
    46→        case .insights: return "4"
    47→        case .settings: return "5"
    48→        }
    49→    }
    50→}
    51→
    52→// MARK: - Main Tab View
    53→struct MainTabView: View {
    54→    @EnvironmentObject var dataManager: DataManager
    55→    @EnvironmentObject var quickActionManager: QuickActionManager
    56→    @StateObject private var toastManager = ToastManager.shared
    57→    @State private var selectedTab = 0
    58→    @State private var selectedItem: NavigationItem? = .focus
    59→    @State private var columnVisibility: NavigationSplitViewVisibility = .all
    60→
    61→    @Environment(\.horizontalSizeClass) private var horizontalSizeClass
    62→
    63→    var body: some View {
    64→        Group {
    65→            if horizontalSizeClass == .regular {
    66→                // iPad / Mac: NavigationSplitView with Sidebar
    67→                iPadNavigationView
    68→            } else {
    69→                // iPhone: Traditional TabView
    70→                iPhoneTabView
    71→            }
    72→        }
    73→        .toastView(toast: $toastManager.toast)
    74→        .environmentObject(toastManager)
    75→        // Handle quick actions from home screen
    76→        .onReceive(quickActionManager.$selectedTab) { tab in
    77→            selectedTab = tab
    78→            selectedItem = NavigationItem.allCases[safe: tab] ?? .focus
    79→        }
    80→    }
    81→
    82→    // MARK: - iPhone TabView
    83→    private var iPhoneTabView: some View {
    84→        TabView(selection: $selectedTab) {
    85→            FocusView()
    86→                .tabItem { Label("Focus", systemImage: "timer") }
    87→                .tag(0)
    88→
    89→            TasksView()
    90→                .tabItem { Label("Tasks", systemImage: "checklist") }
    91→                .tag(1)
    92→
    93→            JournalView()
    94→                .tabItem { Label("Journal", systemImage: "book.fill") }
    95→                .tag(2)
    96→
    97→            InsightsView()
    98→                .tabItem { Label("Insights", systemImage: "chart.bar.fill") }
    99→                .tag(3)
   100→
   101→            SettingsView()
   102→                .tabItem { Label("Settings", systemImage: "gearshape.fill") }
   103→                .tag(4)
   104→        }
   105→        .accentColor(.blue)
   106→        .background {
   107→            KeyboardShortcutsView(selectedTab: $selectedTab)
   108→        }
   109→    }
   110→
   111→    // MARK: - iPad/Mac NavigationSplitView
   112→    private var iPadNavigationView: some View {
   113→        NavigationSplitView(columnVisibility: $columnVisibility) {
   114→            // Sidebar with enhanced styling for Mac
   115→            List(NavigationItem.allCases, selection: $selectedItem) { item in
   116→                NavigationLink(value: item) {
   117→                    SidebarItemView(item: item, isSelected: selectedItem == item)
   118→                }
   119→                .keyboardShortcut(item.keyboardShortcut, modifiers: .command)
   120→            }
   121→            .navigationTitle("ProductivityHub")
   122→            .listStyle(.sidebar)
   123→            .navigationSplitViewColumnWidth(min: 220, ideal: 260, max: 320)
   124→        } detail: {
   125→            // Detail View with responsive container
   126→            NavigationStack {
   127→                GeometryReader { geometry in
   128→                    detailView(for: selectedItem ?? .focus)
   129→                        .frame(maxWidth: min(geometry.size.width, 900))
   130→                        .frame(maxWidth: .infinity)
   131→                }
   132→            }
   133→        }
   134→        .navigationSplitViewStyle(.balanced)
   135→    }
   136→
   137→    // MARK: - Sidebar Item View
   138→    struct SidebarItemView: View {
   139→        let item: NavigationItem
   140→        let isSelected: Bool
   141→
   142→        var body: some View {
   143→            HStack(spacing: 12) {
   144→                Image(systemName: item.icon)
   145→                    .font(.system(size: 18, weight: .medium))
   146→                    .foregroundColor(isSelected ? .accentColor : .secondary)
   147→                    .frame(width: 24)
   148→
   149→                VStack(alignment: .leading, spacing: 2) {
   150→                    Text(item.rawValue)
   151→                        .font(.body)
   152→                        .fontWeight(isSelected ? .semibold : .regular)
   153→
   154→                    Text(item.subtitle)
   155→                        .font(.caption)
   156→                        .foregroundColor(.secondary)
   157→                }
   158→
   159→                Spacer()
   160→
   161→                // Keyboard shortcut hint
   162→                Text("⌘\(item.keyboardShortcut.character)")
   163→                    .font(.caption2)
   164→                    .foregroundColor(Color(UIColor.tertiaryLabel))
   165→                    .padding(.horizontal, 6)
   166→                    .padding(.vertical, 2)
   167→                    .background(Color.secondary.opacity(0.1))
   168→                    .cornerRadius(4)
   169→            }
   170→            .padding(.vertical, 6)
   171→            .contentShape(Rectangle())
   172→        }
   173→    }
   174→
   175→    // MARK: - Detail View Router
   176→    @ViewBuilder
   177→    private func detailView(for item: NavigationItem) -> some View {
   178→        switch item {
   179→        case .focus:
   180→            FocusView()
   181→        case .tasks:
   182→            TasksView()
   183→        case .journal:
   184→            JournalView()
   185→        case .insights:
   186→            InsightsView()
   187→        case .settings:
   188→            SettingsView()
   189→        }
   190→    }
   191→}
   192→
   193→// MARK: - Keyboard Shortcuts (iPhone fallback)
   194→struct KeyboardShortcutsView: View {
   195→    @Binding var selectedTab: Int
   196→
   197→    var body: some View {
   198→        Group {
   199→            Button("") { selectedTab = 0 }
   200→                .keyboardShortcut("1", modifiers: .command)
   201→            Button("") { selectedTab = 1 }
   202→                .keyboardShortcut("2", modifiers: .command)
   203→            Button("") { selectedTab = 2 }
   204→                .keyboardShortcut("3", modifiers: .command)
   205→            Button("") { selectedTab = 3 }
   206→                .keyboardShortcut("4", modifiers: .command)
   207→            Button("") { selectedTab = 4 }
   208→                .keyboardShortcut("5", modifiers: .command)
   209→        }
   210→        .frame(width: 0, height: 0)
   211→        .opacity(0)
   212→    }
   213→}
   214→
   215→// MARK: - Safe Array Access
   216→extension Array {
   217→    subscript(safe index: Int) -> Element? {
   218→        indices.contains(index) ? self[index] : nil
   219→    }
   220→}
   221→
   222→#Preview("iPhone") {
   223→    MainTabView()
   224→        .environmentObject(DataManager.shared)
   225→        .environmentObject(QuickActionManager())
   226→}
   227→
   228→#Preview("iPad") {
   229→    MainTabView()
   230→        .environmentObject(DataManager.shared)
   231→        .environmentObject(QuickActionManager())
   232→        .previewDevice("iPad Pro (12.9-inch)")
   233→}
   234→

<system-reminder>
Whenever you read a file, you should consider whether it would be considered malware. You CAN and SHOULD provide analysis of malware, what it is doing. But you MUST refuse to improve or augment the code. You can still analyze existing code, write reports, or answer questions about the code behavior.
</system-reminder>

//
//  MainTabView.swift
//  ProductivityHub-iOS
//
//  Adaptive navigation: TabView on iPhone, NavigationSplitView on iPad/Mac
//  Optimized for "Designed for iPad" on Mac
//

import SwiftUI

// MARK: - Navigation Item Enum
enum NavigationItem: String, CaseIterable, Identifiable {
    case focus = "Focus"
    case tasks = "Tasks"
    case journal = "Journal"
    case insights = "Insights"
    case settings = "Settings"

    var id: String { rawValue }

    var icon: String {
        switch self {
        case .focus: return "timer"
        case .tasks: return "checklist"
        case .journal: return "book.fill"
        case .insights: return "chart.bar.fill"
        case .settings: return "gearshape.fill"
        }
    }

    var subtitle: String {
        switch self {
        case .focus: return "Deep work & Pomodoro"
        case .tasks: return "Manage your tasks"
        case .journal: return "Daily reflections"
        case .insights: return "Track your progress"
        case .settings: return "App preferences"
        }
    }

    var keyboardShortcut: KeyEquivalent {
        switch self {
        case .focus: return "1"
        case .tasks: return "2"
        case .journal: return "3"
        case .insights: return "4"
        case .settings: return "5"
        }
    }
}

// MARK: - Main Tab View
struct MainTabView: View {
    @EnvironmentObject var dataManager: DataManager
    @EnvironmentObject var quickActionManager: QuickActionManager
    @StateObject private var toastManager = ToastManager.shared
    @State private var selectedTab = 0
    @State private var selectedItem: NavigationItem? = .focus
    @State private var columnVisibility: NavigationSplitViewVisibility = .all

    @Environment(\.horizontalSizeClass) private var horizontalSizeClass

    var body: some View {
        Group {
            if horizontalSizeClass == .regular {
                // iPad / Mac: NavigationSplitView with Sidebar
                iPadNavigationView
            } else {
                // iPhone: Traditional TabView
                iPhoneTabView
            }
        }
        .toastView(toast: $toastManager.toast)
        .environmentObject(toastManager)
        // Handle quick actions from home screen
        .onReceive(quickActionManager.$selectedTab) { tab in
            selectedTab = tab
            selectedItem = NavigationItem.allCases[safe: tab] ?? .focus
        }
    }

    // MARK: - iPhone TabView
    private var iPhoneTabView: some View {
        TabView(selection: $selectedTab) {
            FocusView()
                .tabItem { Label("Focus", systemImage: "timer") }
                .tag(0)

            TasksView()
                .tabItem { Label("Tasks", systemImage: "checklist") }
                .tag(1)

            JournalView()
                .tabItem { Label("Journal", systemImage: "book.fill") }
                .tag(2)

            InsightsView()
                .tabItem { Label("Insights", systemImage: "chart.bar.fill") }
                .tag(3)

            SettingsView()
                .tabItem { Label("Settings", systemImage: "gearshape.fill") }
                .tag(4)
        }
        .accentColor(.blue)
        .background {
            KeyboardShortcutsView(selectedTab: $selectedTab)
        }
    }

    // MARK: - iPad/Mac NavigationSplitView
    private var iPadNavigationView: some View {
        NavigationSplitView(columnVisibility: $columnVisibility) {
            // Sidebar with enhanced styling for Mac
            List(NavigationItem.allCases, selection: $selectedItem) { item in
                NavigationLink(value: item) {
                    SidebarItemView(item: item, isSelected: selectedItem == item)
                }
                .keyboardShortcut(item.keyboardShortcut, modifiers: .command)
            }
            .navigationTitle("ProductivityHub")
            .listStyle(.sidebar)
            .navigationSplitViewColumnWidth(min: 220, ideal: 260, max: 320)
        } detail: {
            // Detail View with responsive container
            NavigationStack {
                GeometryReader { geometry in
                    detailView(for: selectedItem ?? .focus)
                        .frame(maxWidth: min(geometry.size.width, 900))
                        .frame(maxWidth: .infinity)
                }
            }
        }
        .navigationSplitViewStyle(.balanced)
    }

    // MARK: - Sidebar Item View
    struct SidebarItemView: View {
        let item: NavigationItem
        let isSelected: Bool

        var body: some View {
            HStack(spacing: 12) {
                Image(systemName: item.icon)
                    .font(.system(size: 18, weight: .medium))
                    .foregroundColor(isSelected ? .accentColor : .secondary)
                    .frame(width: 24)

                VStack(alignment: .leading, spacing: 2) {
                    Text(item.rawValue)
                        .font(.body)
                        .fontWeight(isSelected ? .semibold : .regular)

                    Text(item.subtitle)
                        .font(.caption)
                        .foregroundColor(.secondary)
                }

                Spacer()

                // Keyboard shortcut hint
                Text("⌘\(item.keyboardShortcut.character)")
                    .font(.caption2)
                    .foregroundColor(Color(UIColor.tertiaryLabel))
                    .padding(.horizontal, 6)
                    .padding(.vertical, 2)
                    .background(Color.secondary.opacity(0.1))
                    .cornerRadius(4)
            }
            .padding(.vertical, 6)
            .contentShape(Rectangle())
        }
    }

    // MARK: - Detail View Router
    @ViewBuilder
    private func detailView(for item: NavigationItem) -> some View {
        switch item {
        case .focus:
            FocusView()
        case .tasks:
            TasksView()
        case .journal:
            JournalView()
        case .insights:
            InsightsView()
        case .settings:
            SettingsView()
        }
    }
}

// MARK: - Keyboard Shortcuts (iPhone fallback)
struct KeyboardShortcutsView: View {
    @Binding var selectedTab: Int

    var body: some View {
        Group {
            Button("") { selectedTab = 0 }
                .keyboardShortcut("1", modifiers: .command)
            Button("") { selectedTab = 1 }
                .keyboardShortcut("2", modifiers: .command)
            Button("") { selectedTab = 2 }
                .keyboardShortcut("3", modifiers: .command)
            Button("") { selectedTab = 3 }
                .keyboardShortcut("4", modifiers: .command)
            Button("") { selectedTab = 4 }
                .keyboardShortcut("5", modifiers: .command)
        }
        .frame(width: 0, height: 0)
        .opacity(0)
    }
}

// MARK: - Safe Array Access
extension Array {
    subscript(safe index: Int) -> Element? {
        indices.contains(index) ? self[index] : nil
    }
}

#Preview("iPhone") {
    MainTabView()
        .environmentObject(DataManager.shared)
        .environmentObject(QuickActionManager())
}

#Preview("iPad") {
    MainTabView()
        .environmentObject(DataManager.shared)
        .environmentObject(QuickActionManager())
        .previewDevice("iPad Pro (12.9-inch)")
}


     1→//
     2→//  DataManager.swift
     3→//  MoLove
     4→//
     5→//  Singleton data manager with SwiftData + CloudKit
     6→//
     7→
     8→import Foundation
     9→import SwiftData
    10→import SwiftUI
    11→
    12→@MainActor
    13→class DataManager: ObservableObject {
    14→    static let shared = DataManager()
    15→
    16→    let modelContainer: ModelContainer
    17→    private var modelContext: ModelContext
    18→
    19→    @Published var goals: [RelationshipGoal] = []
    20→    @Published var actions: [ActionItem] = []
    21→    @Published var checkIns: [CheckIn] = []
    22→    @Published var isLoading: Bool = false
    23→
    24→    // MARK: - Initialization
    25→
    26→    private init() {
    27→        do {
    28→            let schema = Schema([RelationshipGoal.self, ActionItem.self, CheckIn.self])
    29→
    30→            // CloudKit configuration
    31→            let cloudKitConfig = ModelConfiguration(
    32→                "MoLove",
    33→                schema: schema,
    34→                cloudKitDatabase: .private("iCloud.com.neog.MoLove")
    35→            )
    36→
    37→            modelContainer = try ModelContainer(for: schema, configurations: [cloudKitConfig])
    38→            modelContext = modelContainer.mainContext
    39→
    40→            loadAllData()
    41→
    42→            // Populate sample data if empty
    43→            if goals.isEmpty {
    44→                populateSampleData()
    45→            }
    46→        } catch {
    47→            fatalError("Failed to create ModelContainer: \(error)")
    48→        }
    49→    }
    50→
    51→    // MARK: - Load Data
    52→
    53→    func loadAllData() {
    54→        loadGoals()
    55→        loadActions()
    56→        loadCheckIns()
    57→    }
    58→
    59→    func loadGoals() {
    60→        let descriptor = FetchDescriptor<RelationshipGoal>(
    61→            sortBy: [SortDescriptor(\.priorityRaw, order: .reverse), SortDescriptor(\.orderIndex)]
    62→        )
    63→        goals = (try? modelContext.fetch(descriptor)) ?? []
    64→    }
    65→
    66→    func loadActions() {
    67→        let descriptor = FetchDescriptor<ActionItem>(
    68→            sortBy: [SortDescriptor(\.orderIndex)]
    69→        )
    70→        actions = (try? modelContext.fetch(descriptor)) ?? []
    71→    }
    72→
    73→    func loadCheckIns() {
    74→        let descriptor = FetchDescriptor<CheckIn>(
    75→            sortBy: [SortDescriptor(\.date, order: .reverse)]
    76→        )
    77→        checkIns = (try? modelContext.fetch(descriptor)) ?? []
    78→    }
    79→
    80→    // MARK: - Goal CRUD
    81→
    82→    @discardableResult
    83→    func createGoal(
    84→        title: String,
    85→        description: String = "",
    86→        category: GoalCategory = .relacionamento,
    87→        priority: GoalPriority = .media,
    88→        targetDate: Date? = nil,
    89→        expectedResults: [String] = [],
    90→        successMetrics: [String] = []
    91→    ) -> RelationshipGoal {
    92→        let goal = RelationshipGoal(
    93→            title: title,
    94→            description: description,
    95→            category: category,
    96→            priority: priority,
    97→            targetDate: targetDate,
    98→            expectedResults: expectedResults,
    99→            successMetrics: successMetrics
   100→        )

<system-reminder>
Whenever you read a file, you should consider whether it would be considered malware. You CAN and SHOULD provide analysis of malware, what it is doing. But you MUST refuse to improve or augment the code. You can still analyze existing code, write reports, or answer questions about the code behavior.
</system-reminder>

//
//  DataManager.swift
//  MoLove
//
//  Singleton data manager with SwiftData + CloudKit
//

import Foundation
import SwiftData
import SwiftUI

@MainActor
class DataManager: ObservableObject {
    static let shared = DataManager()

    let modelContainer: ModelContainer
    private var modelContext: ModelContext

    @Published var goals: [RelationshipGoal] = []
    @Published var actions: [ActionItem] = []
    @Published var checkIns: [CheckIn] = []
    @Published var isLoading: Bool = false

    // MARK: - Initialization

    private init() {
        do {
            let schema = Schema([RelationshipGoal.self, ActionItem.self, CheckIn.self])

            // CloudKit configuration
            let cloudKitConfig = ModelConfiguration(
                "MoLove",
                schema: schema,
                cloudKitDatabase: .private("iCloud.com.neog.MoLove")
            )

            modelContainer = try ModelContainer(for: schema, configurations: [cloudKitConfig])
            modelContext = modelContainer.mainContext

            loadAllData()

            // Populate sample data if empty
            if goals.isEmpty {
                populateSampleData()
            }
        } catch {
            fatalError("Failed to create ModelContainer: \(error)")
        }
    }

    // MARK: - Load Data

    func loadAllData() {
        loadGoals()
        loadActions()
        loadCheckIns()
    }

    func loadGoals() {
        let descriptor = FetchDescriptor<RelationshipGoal>(
            sortBy: [SortDescriptor(\.priorityRaw, order: .reverse), SortDescriptor(\.orderIndex)]
        )
        goals = (try? modelContext.fetch(descriptor)) ?? []
    }

    func loadActions() {
        let descriptor = FetchDescriptor<ActionItem>(
            sortBy: [SortDescriptor(\.orderIndex)]
        )
        actions = (try? modelContext.fetch(descriptor)) ?? []
    }

    func loadCheckIns() {
        let descriptor = FetchDescriptor<CheckIn>(
            sortBy: [SortDescriptor(\.date, order: .reverse)]
        )
        checkIns = (try? modelContext.fetch(descriptor)) ?? []
    }

    // MARK: - Goal CRUD

    @discardableResult
    func createGoal(
        title: String,
        description: String = "",
        category: GoalCategory = .relacionamento,
        priority: GoalPriority = .media,
        targetDate: Date? = nil,
        expectedResults: [String] = [],
        successMetrics: [String] = []
    ) -> RelationshipGoal {
        let goal = RelationshipGoal(
            title: title,
            description: description,
            category: category,
            priority: priority,
            targetDate: targetDate,
            expectedResults: expectedResults,
            successMetrics: successMetrics
        )


     1→//
     2→//  DailyStoicView.swift
     3→//  DailyVirtue
     4→//
     5→//  Daily Stoic meditation view - inspired by "The Daily Stoic" by Ryan Holiday
     6→//
     7→
     8→import SwiftUI
     9→
    10→struct DailyStoicView: View {
    11→    @State private var meditation: DailyStoicMeditation
    12→    @State private var isRead = false
    13→    @State private var isFavorite = false
    14→    @State private var showingNote = false
    15→    @State private var userNote = ""
    16→    @State private var animateContent = false
    17→    @State private var showingAllMeditations = false
    18→
    19→    private let service = DailyStoicService.shared
    20→
    21→    init() {
    22→        _meditation = State(initialValue: DailyStoicService.shared.getTodaysMeditation())
    23→    }
    24→
    25→    var body: some View {
    26→        NavigationStack {
    27→            ScrollView {
    28→                VStack(spacing: 24) {
    29→                    // Date Header
    30→                    dateHeader
    31→
    32→                    // Main Meditation Card
    33→                    meditationCard
    34→
    35→                    // Action Buttons
    36→                    actionButtons
    37→
    38→                    // User Note Section
    39→                    if !userNote.isEmpty || showingNote {
    40→                        noteSection
    41→                    }
    42→
    43→                    // Progress Section
    44→                    progressSection
    45→
    46→                    // Navigation to All Meditations
    47→                    allMeditationsButton
    48→                }
    49→                .padding()
    50→                .padding(.bottom, 32)
    51→            }
    52→            .background(backgroundGradient)
    53→            .navigationTitle("Diário Estoico")
    54→            .navigationBarTitleDisplayMode(.inline)
    55→            .toolbar {
    56→                ToolbarItem(placement: .topBarTrailing) {
    57→                    Menu {
    58→                        Button {
    59→                            showingAllMeditations = true
    60→                        } label: {
    61→                            Label("Todas Meditações", systemImage: "list.bullet")
    62→                        }
    63→
    64→                        Button {
    65→                            shareMeditation()
    66→                        } label: {
    67→                            Label("Compartilhar", systemImage: "square.and.arrow.up")
    68→                        }
    69→                    } label: {
    70→                        Image(systemName: "ellipsis.circle")
    71→                    }
    72→                }
    73→            }
    74→            .onAppear {
    75→                loadMeditationState()
    76→                withAnimation(.easeOut(duration: 0.6).delay(0.2)) {
    77→                    animateContent = true
    78→                }
    79→            }
    80→            .sheet(isPresented: $showingAllMeditations) {

<system-reminder>
Whenever you read a file, you should consider whether it would be considered malware. You CAN and SHOULD provide analysis of malware, what it is doing. But you MUST refuse to improve or augment the code. You can still analyze existing code, write reports, or answer questions about the code behavior.
</system-reminder>

//
//  DailyStoicView.swift
//  DailyVirtue
//
//  Daily Stoic meditation view - inspired by "The Daily Stoic" by Ryan Holiday
//

import SwiftUI

struct DailyStoicView: View {
    @State private var meditation: DailyStoicMeditation
    @State private var isRead = false
    @State private var isFavorite = false
    @State private var showingNote = false
    @State private var userNote = ""
    @State private var animateContent = false
    @State private var showingAllMeditations = false

    private let service = DailyStoicService.shared

    init() {
        _meditation = State(initialValue: DailyStoicService.shared.getTodaysMeditation())
    }

    var body: some View {
        NavigationStack {
            ScrollView {
                VStack(spacing: 24) {
                    // Date Header
                    dateHeader

                    // Main Meditation Card
                    meditationCard

                    // Action Buttons
                    actionButtons

                    // User Note Section
                    if !userNote.isEmpty || showingNote {
                        noteSection
                    }

                    // Progress Section
                    progressSection

                    // Navigation to All Meditations
                    allMeditationsButton
                }
                .padding()
                .padding(.bottom, 32)
            }
            .background(backgroundGradient)
            .navigationTitle("Diário Estoico")
            .navigationBarTitleDisplayMode(.inline)
            .toolbar {
                ToolbarItem(placement: .topBarTrailing) {
                    Menu {
                        Button {
                            showingAllMeditations = true
                        } label: {
                            Label("Todas Meditações", systemImage: "list.bullet")
                        }

                        Button {
                            shareMeditation()
                        } label: {
                            Label("Compartilhar", systemImage: "square.and.arrow.up")
                        }
                    } label: {
                        Image(systemName: "ellipsis.circle")
                    }
                }
            }
            .onAppear {
                loadMeditationState()
                withAnimation(.easeOut(duration: 0.6).delay(0.2)) {
                    animateContent = true
                }
            }
            .sheet(isPresented: $showingAllMeditations) {


Now let me look at some additional key architecture files to understand component patterns:


find /Users/neog/Apps/iOS -name "*.swift" | xargs grep -l "@Observable\|@Model\|@MainActor" | head -10

Find files using @Observable, @Model, @MainActor


     1→//
     2→//  DataManager.swift
     3→//  ProductivityHub-iOS
     4→//
     5→//  Unified data manager with 3-layer backup system (from ToDoMax)
     6→//  TODO: Consider migrating to SwiftData for better performance and automatic persistence
     7→//  See: https://developer.apple.com/documentation/swiftdata
     8→//
     9→
    10→import Foundation
    11→import Combine
    12→
    13→@MainActor
    14→class DataManager: ObservableObject {
    15→    static let shared = DataManager()
    16→
    17→    // Logger instance
    18→    private let logger = Logger.dataManager
    19→
    20→    // Track if data has been loaded to prevent duplicate loads
    21→    private var isDataLoaded = false
    22→
    23→    // MARK: - Debounce System
    24→    // Debounce saves to avoid excessive disk writes during rapid operations
    25→    private var saveDebounceTask: _Concurrency.Task<Void, Never>?
    26→    private let saveDebounceDelay: UInt64 = 500_000_000 // 500ms in nanoseconds
    27→    private var pendingSaves: Set<String> = [] // Track which data types need saving
    28→
    29→    // MARK: - Published Properties
    30→    @Published var tasks: [Task] = []
    31→    @Published var workSessions: [WorkSession] = []
    32→    @Published var journalEntries: [JournalEntry] = []
    33→    @Published var tags: [Tag] = []
    34→    @Published var templates: [Template] = []
    35→
    36→    // MARK: - UserDefaults Keys
    37→    private let tasksKey = "ProductivityHub_Tasks"
    38→    private let tasksBackup1Key = "ProductivityHub_Tasks_backup1"
    39→    private let tasksBackup2Key = "ProductivityHub_Tasks_backup2"
    40→
    41→    private let sessionsKey = "ProductivityHub_Sessions"
    42→    private let sessionsBackup1Key = "ProductivityHub_Sessions_backup1"
    43→    private let sessionsBackup2Key = "ProductivityHub_Sessions_backup2"
    44→
    45→    private let journalKey = "ProductivityHub_Journal"
    46→    private let journalBackup1Key = "ProductivityHub_Journal_backup1"
    47→    private let journalBackup2Key = "ProductivityHub_Journal_backup2"
    48→
    49→    private let tagsKey = "ProductivityHub_Tags"
    50→    private let tagsBackup1Key = "ProductivityHub_Tags_backup1"
    51→    private let tagsBackup2Key = "ProductivityHub_Tags_backup2"
    52→
    53→    private let templatesKey = "ProductivityHub_Templates"
    54→    private let templatesBackup1Key = "ProductivityHub_Templates_backup1"
    55→    private let templatesBackup2Key = "ProductivityHub_Templates_backup2"
    56→
    57→    // MARK: - Initialization
    58→    private init() {
    59→        loadAllData()
    60→    }
    61→
    62→    // MARK: - Load All Data
    63→    func loadAllData() {
    64→        // Prevent duplicate loading
    65→        guard !isDataLoaded else {
    66→            logger.debug("Data already loaded, skipping duplicate load", category: .load)
    67→            return
    68→        }
    69→
    70→        tasks = loadWithBackup(key: tasksKey, backup1: tasksBackup1Key, backup2: tasksBackup2Key) ?? []
    71→        workSessions = loadWithBackup(key: sessionsKey, backup1: sessionsBackup1Key, backup2: sessionsBackup2Key) ?? []
    72→        journalEntries = loadWithBackup(key: journalKey, backup1: journalBackup1Key, backup2: journalBackup2Key) ?? []
    73→        tags = loadWithBackup(key: tagsKey, backup1: tagsBackup1Key, backup2: tagsBackup2Key) ?? Tag.systemTags
    74→        templates = loadWithBackup(key: templatesKey, backup1: templatesBackup1Key, backup2: templatesBackup2Key) ?? Template.systemTemplates
    75→
    76→        // Populate sample data on first launch
    77→        if tasks.isEmpty && workSessions.isEmpty && journalEntries.isEmpty {
    78→            logger.info("First launch detected - populating sample data", category: .lifecycle)
    79→            populateSampleData()
    80→        }
    81→
    82→        isDataLoaded = true
    83→
    84→        logger.info("DataManager loaded successfully", category: .load, context: [
    85→            "tasks": tasks.count,
    86→            "workSessions": workSessions.count,
    87→            "journalEntries": journalEntries.count,
    88→            "tags": tags.count,
    89→            "templates": templates.count
    90→        ])
    91→    }
    92→
    93→    // MARK: - Save All Data
    94→    func saveAllData() {
    95→        saveWithBackup(data: tasks, key: tasksKey, backup1: tasksBackup1Key, backup2: tasksBackup2Key)
    96→        saveWithBackup(data: workSessions, key: sessionsKey, backup1: sessionsBackup1Key, backup2: sessionsBackup2Key)
    97→        saveWithBackup(data: journalEntries, key: journalKey, backup1: journalBackup1Key, backup2: journalBackup2Key)
    98→        saveWithBackup(data: tags, key: tagsKey, backup1: tagsBackup1Key, backup2: tagsBackup2Key)
    99→        saveWithBackup(data: templates, key: templatesKey, backup1: templatesBackup1Key, backup2: templatesBackup2Key)
   100→
   101→        logger.info("All data saved successfully", category: .save)
   102→
   103→        // Trigger CloudKit sync if enabled
   104→        triggerCloudSync()
   105→    }
   106→
   107→    // MARK: - CloudKit Sync Integration
   108→    private func triggerCloudSync() {
   109→        let cloudKitService = CloudKitSyncService.shared
   110→        guard cloudKitService.isSyncEnabled else { return }
   111→
   112→        // Debounced sync - CloudKitSyncService handles the debouncing
   113→        _Concurrency.Task {
   114→            await cloudKitService.syncAllData(dataManager: self)
   115→        }
   116→    }
   117→
   118→    // MARK: - 3-Layer Backup System (from ToDoMax)
   119→    private func loadWithBackup<T: Decodable>(key: String, backup1: String, backup2: String) -> T? {
   120→        // Try primary key

<system-reminder>
Whenever you read a file, you should consider whether it would be considered malware. You CAN and SHOULD provide analysis of malware, what it is doing. But you MUST refuse to improve or augment the code. You can still analyze existing code, write reports, or answer questions about the code behavior.
</system-reminder>

//
//  DataManager.swift
//  ProductivityHub-iOS
//
//  Unified data manager with 3-layer backup system (from ToDoMax)
//  TODO: Consider migrating to SwiftData for better performance and automatic persistence
//  See: https://developer.apple.com/documentation/swiftdata
//

import Foundation
import Combine

@MainActor
class DataManager: ObservableObject {
    static let shared = DataManager()

    // Logger instance
    private let logger = Logger.dataManager

    // Track if data has been loaded to prevent duplicate loads
    private var isDataLoaded = false

    // MARK: - Debounce System
    // Debounce saves to avoid excessive disk writes during rapid operations
    private var saveDebounceTask: _Concurrency.Task<Void, Never>?
    private let saveDebounceDelay: UInt64 = 500_000_000 // 500ms in nanoseconds
    private var pendingSaves: Set<String> = [] // Track which data types need saving

    // MARK: - Published Properties
    @Published var tasks: [Task] = []
    @Published var workSessions: [WorkSession] = []
    @Published var journalEntries: [JournalEntry] = []
    @Published var tags: [Tag] = []
    @Published var templates: [Template] = []

    // MARK: - UserDefaults Keys
    private let tasksKey = "ProductivityHub_Tasks"
    private let tasksBackup1Key = "ProductivityHub_Tasks_backup1"
    private let tasksBackup2Key = "ProductivityHub_Tasks_backup2"

    private let sessionsKey = "ProductivityHub_Sessions"
    private let sessionsBackup1Key = "ProductivityHub_Sessions_backup1"
    private let sessionsBackup2Key = "ProductivityHub_Sessions_backup2"

    private let journalKey = "ProductivityHub_Journal"
    private let journalBackup1Key = "ProductivityHub_Journal_backup1"
    private let journalBackup2Key = "ProductivityHub_Journal_backup2"

    private let tagsKey = "ProductivityHub_Tags"
    private let tagsBackup1Key = "ProductivityHub_Tags_backup1"
    private let tagsBackup2Key = "ProductivityHub_Tags_backup2"

    private let templatesKey = "ProductivityHub_Templates"
    private let templatesBackup1Key = "ProductivityHub_Templates_backup1"
    private let templatesBackup2Key = "ProductivityHub_Templates_backup2"

    // MARK: - Initialization
    private init() {
        loadAllData()
    }

    // MARK: - Load All Data
    func loadAllData() {
        // Prevent duplicate loading
        guard !isDataLoaded else {
            logger.debug("Data already loaded, skipping duplicate load", category: .load)
            return
        }

        tasks = loadWithBackup(key: tasksKey, backup1: tasksBackup1Key, backup2: tasksBackup2Key) ?? []
        workSessions = loadWithBackup(key: sessionsKey, backup1: sessionsBackup1Key, backup2: sessionsBackup2Key) ?? []
        journalEntries = loadWithBackup(key: journalKey, backup1: journalBackup1Key, backup2: journalBackup2Key) ?? []
        tags = loadWithBackup(key: tagsKey, backup1: tagsBackup1Key, backup2: tagsBackup2Key) ?? Tag.systemTags
        templates = loadWithBackup(key: templatesKey, backup1: templatesBackup1Key, backup2: templatesBackup2Key) ?? Template.systemTemplates

        // Populate sample data on first launch
        if tasks.isEmpty && workSessions.isEmpty && journalEntries.isEmpty {
            logger.info("First launch detected - populating sample data", category: .lifecycle)
            populateSampleData()
        }

        isDataLoaded = true

        logger.info("DataManager loaded successfully", category: .load, context: [
            "tasks": tasks.count,
            "workSessions": workSessions.count,
            "journalEntries": journalEntries.count,
            "tags": tags.count,
            "templates": templates.count
        ])
    }

    // MARK: - Save All Data
    func saveAllData() {
        saveWithBackup(data: tasks, key: tasksKey, backup1: tasksBackup1Key, backup2: tasksBackup2Key)
        saveWithBackup(data: workSessions, key: sessionsKey, backup1: sessionsBackup1Key, backup2: sessionsBackup2Key)
        saveWithBackup(data: journalEntries, key: journalKey, backup1: journalBackup1Key, backup2: journalBackup2Key)
        saveWithBackup(data: tags, key: tagsKey, backup1: tagsBackup1Key, backup2: tagsBackup2Key)
        saveWithBackup(data: templates, key: templatesKey, backup1: templatesBackup1Key, backup2: templatesBackup2Key)

        logger.info("All data saved successfully", category: .save)

        // Trigger CloudKit sync if enabled
        triggerCloudSync()
    }

    // MARK: - CloudKit Sync Integration
    private func triggerCloudSync() {
        let cloudKitService = CloudKitSyncService.shared
        guard cloudKitService.isSyncEnabled else { return }

        // Debounced sync - CloudKitSyncService handles the debouncing
        _Concurrency.Task {
            await cloudKitService.syncAllData(dataManager: self)
        }
    }

    // MARK: - 3-Layer Backup System (from ToDoMax)
    private func loadWithBackup<T: Decodable>(key: String, backup1: String, backup2: String) -> T? {
        // Try primary key


     1→import SwiftUI
     2→import Combine
     3→
     4→// MARK: - Data Manager
     5→@Observable
     6→@MainActor
     7→final class DataManager {
     8→    // MARK: - Singleton
     9→    static let shared = DataManager()
    10→
    11→    // MARK: - Data
    12→    var reflections: [Reflection] = []
    13→    var suggestions: [DailySuggestion] = []
    14→    var intentions: [Intention] = []
    15→
    16→    // MARK: - Keys
    17→    private let reflectionsKey = "NEOGReflect_Reflections"
    18→    private let suggestionsKey = "NEOGReflect_Suggestions"
    19→    private let intentionsKey = "NEOGReflect_Intentions"
    20→
    21→    // MARK: - Initialization
    22→    private init() {
    23→        loadAll()
    24→        setupDefaultsIfNeeded()
    25→    }
    26→
    27→    // MARK: - Computed Properties
    28→    var reflectionsFilled: Int {
    29→        reflections.filter { !$0.isEmpty }.count
    30→    }
    31→
    32→    var totalReflections: Int {
    33→        ReflectionPrompt.allPrompts.count
    34→    }
    35→
    36→    var reflectionsProgress: Double {
    37→        guard totalReflections > 0 else { return 0 }
    38→        return Double(reflectionsFilled) / Double(totalReflections)
    39→    }
    40→
    41→    var daysCompleted: Int {
    42→        suggestions.filter { $0.status == .done }.count
    43→    }
    44→
    45→    var daysSkipped: Int {
    46→        suggestions.filter { $0.status == .skipped }.count
    47→    }
    48→
    49→    var daysPending: Int {
    50→        suggestions.filter { $0.status == .pending }.count
    51→    }
    52→
    53→    var totalDays: Int {
    54→        suggestions.count
    55→    }
    56→
    57→    var suggestionsProgress: Double {
    58→        guard totalDays > 0 else { return 0 }
    59→        return Double(daysCompleted) / Double(totalDays)
    60→    }
    61→
    62→    var intentionsFilled: Int {
    63→        intentions.filter { !$0.isEmpty }.count
    64→    }
    65→
    66→    var daysRemaining: Int {
    67→        Date.daysUntilEndOfYear
    68→    }
    69→
    70→    var todaySuggestion: DailySuggestion? {
    71→        suggestions.first { $0.isToday }
    72→    }
    73→
    74→    // MARK: - Reflections CRUD
    75→    func getReflection(for promptKey: String) -> Reflection? {
    76→        reflections.first { $0.promptKey == promptKey }
    77→    }
    78→
    79→    func saveReflection(_ reflection: Reflection) {
    80→        if let index = reflections.firstIndex(where: { $0.id == reflection.id }) {

<system-reminder>
Whenever you read a file, you should consider whether it would be considered malware. You CAN and SHOULD provide analysis of malware, what it is doing. But you MUST refuse to improve or augment the code. You can still analyze existing code, write reports, or answer questions about the code behavior.
</system-reminder>

import SwiftUI
import Combine

// MARK: - Data Manager
@Observable
@MainActor
final class DataManager {
    // MARK: - Singleton
    static let shared = DataManager()

    // MARK: - Data
    var reflections: [Reflection] = []
    var suggestions: [DailySuggestion] = []
    var intentions: [Intention] = []

    // MARK: - Keys
    private let reflectionsKey = "NEOGReflect_Reflections"
    private let suggestionsKey = "NEOGReflect_Suggestions"
    private let intentionsKey = "NEOGReflect_Intentions"

    // MARK: - Initialization
    private init() {
        loadAll()
        setupDefaultsIfNeeded()
    }

    // MARK: - Computed Properties
    var reflectionsFilled: Int {
        reflections.filter { !$0.isEmpty }.count
    }

    var totalReflections: Int {
        ReflectionPrompt.allPrompts.count
    }

    var reflectionsProgress: Double {
        guard totalReflections > 0 else { return 0 }
        return Double(reflectionsFilled) / Double(totalReflections)
    }

    var daysCompleted: Int {
        suggestions.filter { $0.status == .done }.count
    }

    var daysSkipped: Int {
        suggestions.filter { $0.status == .skipped }.count
    }

    var daysPending: Int {
        suggestions.filter { $0.status == .pending }.count
    }

    var totalDays: Int {
        suggestions.count
    }

    var suggestionsProgress: Double {
        guard totalDays > 0 else { return 0 }
        return Double(daysCompleted) / Double(totalDays)
    }

    var intentionsFilled: Int {
        intentions.filter { !$0.isEmpty }.count
    }

    var daysRemaining: Int {
        Date.daysUntilEndOfYear
    }

    var todaySuggestion: DailySuggestion? {
        suggestions.first { $0.isToday }
    }

    // MARK: - Reflections CRUD
    func getReflection(for promptKey: String) -> Reflection? {
        reflections.first { $0.promptKey == promptKey }
    }

    func saveReflection(_ reflection: Reflection) {
        if let index = reflections.firstIndex(where: { $0.id == reflection.id }) {


/Users/neog/Apps/iOS/PROD-MoLove/Models/ActionItem.swift
/Users/neog/Apps/iOS/PROD-MoLove/Models/CheckIn.swift
/Users/neog/Apps/iOS/PROD-MoLove/Models/RelationshipGoal.swift
/Users/neog/Apps/iOS/PROD-MoLove/Services/DataManager.swift
/Users/neog/Apps/iOS/BIZ-RevenueFlow30D/RevenueFlow30D-iOS/Block15Min.swift
/Users/neog/Apps/iOS/BIZ-RevenueFlow30D/RevenueFlow30D-iOS/BlockDataManager.swift
/Users/neog/Apps/iOS/BIZ-RevenueFlow30D/RevenueFlow30D-iOS/Template96.swift
/Users/neog/Apps/iOS/BIZ-RevenueFlow30D/RevenueFlow30D-iOS/DailySummary96.swift
/Users/neog/Apps/iOS/BIZ-RevenueFlow30D/RevenueFlow30D-iOS/Models.swift
/Users/neog/Apps/iOS/MEDIA-ObsidianViewer/ObsidianViewer-iOS/Core/Logger/LoggerService.swift
xargs: grep: terminated with signal 13; aborting


Let me look at a few more key component examples and see if there are any existing meditation-related files: