Implement storage architecture from ai_blueprint.md

Primary sync: replace PersistenceActor JSON file with SwiftData + CloudKit
- Add SavedCardModel (@Model class) and PersistenceController (ModelContainer
  with .automatic CloudKit, fallback to local). BackgroundPersistenceActor
  (@ModelActor) handles all DB I/O off the main thread.
- One-time migration imports user_collection.json into SwiftData and renames
  the original file to prevent re-import.
- Inject modelContainer into SwiftUI environment in IYmtgApp.

Image storage: Documents/UserContent/ subfolder (blueprint requirement)
- ImageManager.dir now targets iCloud Documents/UserContent/ (or local equiv).
- migrateImagesToUserContent() moves existing JPGs to the new subfolder on
  first launch; called during the SwiftData migration.

Firebase: demoted to optional manual backup (metadata only, no images)
- Remove all automatic CloudEngine.save/delete/batchUpdatePrices calls from
  CollectionViewModel mutations.
- Add backupAllToFirebase() for user-triggered metadata sync.
- Add isFirebaseBackupEnabled to AppConfig (default false).
- Add Cloud Backup section in Library settings with iCloud vs Firebase
  explanation and "Backup Metadata to Firebase Now" button.

Also: full modular refactor (Data/, Features/, Services/ directories) and
README updated with CloudKit setup steps and revised release checklist.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-05 12:13:17 -05:00
parent b993ef4020
commit 24dcb44af4
38 changed files with 2786 additions and 2105 deletions

41
ai_blueprint.md Normal file
View File

@@ -0,0 +1,41 @@
# AI Blueprint
This document outlines the architecture and plan for development tasks. It is intended to be used by the development team to guide implementation.
## Instructions for the Architect AI
1. **Understand the Goal:** Your primary role is to understand the user's request and create a detailed, step-by-step plan for another AI (Claude) to execute. You do not write code.
2. **Analyze the codebase:** Use the available tools to explore the existing files and understand the current state of the project.
3. **Create a Plan:** Based on the user's request and your analysis, create a comprehensive plan. This plan should be broken down into clear, actionable steps. Each step should include:
* A description of the task.
* The specific files to be modified.
* The high-level changes required.
4. **Update this Blueprint:** Overwrite this `ai_blueprint.md` file with the generated plan.
5. **Include README and Commit Steps:** The plan must always include steps for:
* Updating the `README.md` if the changes affect the project's description, setup, or usage.
* Creating a Git commit with a descriptive message to save the changes.
6. **Delegate Implementation:** After creating the plan, your job is complete. Another AI will take over to implement the plan.
## Development Plan
> **Note to the Architect AI:** Replace this section with the actual plan for the user's request.
### 1. Analyze Existing Code
- **File:** `[Path to relevant file]`
- **Description:** Briefly describe the purpose of the file and the area to be modified.
### 2. Implement Changes
- **File:** `[Path to file to be created or modified]`
- **Description:** Detail the changes to be made. For new files, describe the file's purpose and structure.
### 3. Update Documentation
- **File:** [`README.md`](README.md)
- **Description:** Update the README to reflect the new changes, features, or bug fixes.
### 4. Commit Changes
- **Action:** Create a Git commit.
- **Commit Message:** `feat: [A brief, descriptive message of the changes]`