Skip to content

Create CoreDataItemRepository #91

@DrunkOnJava

Description

@DrunkOnJava

📋 Sub-task of #86

Description

Replace the in-memory DefaultItemRepository with a Core Data backed implementation.

Current Implementation

  • DefaultItemRepository.swift uses DispatchQueue and array storage
  • All data is lost on app restart

Implementation Tasks

  • Create CoreDataItemRepository conforming to ItemRepository protocol
  • Implement all CRUD operations using Core Data
  • Add batch operations for performance
  • Implement fuzzy search using Core Data predicates
  • Add proper error handling and recovery
  • Optimize fetch requests with proper indexes

Key Methods to Implement

  • fetchAll() - with pagination support
  • fetch(id:) - optimized single item fetch
  • save(_:) - with conflict resolution
  • delete(_:) - with cascade handling
  • search(query:) - full text search
  • fetchByCategory(_:) - filtered queries
  • fetchByLocation(_:) - relationship queries

Performance Requirements

  • Fetch 10,000 items < 100ms
  • Save batch of 100 items < 500ms
  • Search response < 50ms

Migration Path

  • Create parallel implementation
  • Add feature flag for gradual rollout
  • Implement data migration from existing storage
  • Deprecate DefaultItemRepository

Testing Requirements

  • Unit tests for all CRUD operations
  • Performance tests with large datasets
  • Concurrent access tests
  • Error recovery tests

Estimated Effort: 3-4 days

Metadata

Metadata

Assignees

No one assigned

    Labels

    P0Production blocker - must fix immediatelycore-dataCore Data framework relateddata-persistenceData storage and persistence issuesenhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions