repository-pattern

Community

Type-safe Dexie repos for offline data.

Authoralexanderop
Version1.0.0
Installs0

System Documentation

What problem does it solve?

This Skill provides a structured approach to implementing the repository pattern over Dexie/IndexedDB, delivering type-safe interfaces, consistent CRUD operations, and robust error handling for offline data persistence.

Core Features & Use Cases

  • Type-safe interfaces and a standard CRUD API across repositories (getAll, getById, create, update, delete).
  • Dexie-based implementations with a clear, layered architecture: Interfaces → Implementations → Provider → Public API.
  • Support for converters between Db* database types and domain models, plus migration strategies and error handling patterns (tryCatch, createDatabaseError).
  • Examples and integration points for common repositories in this app (SettingsRepository, WorkoutsRepository, TemplatesRepository, CustomExercisesRepository, BenchmarksRepository, ActiveWorkoutRepository).
  • Patterns such as transactions for atomic updates, timestamp management, ID generation, bulk operations, and soft deletes.

Quick Start

  • Step 1: Define the repository interface in src/db/interfaces.ts with getAll, getById, create, update, delete.
  • Step 2: Add a Db* schema in src/db/schema.ts using Db prefixes and null for missing values.
  • Step 3: Update the database class in src/db/implementations/dexie/database.ts to include stores and indexes.
  • Step 4: Implement a Dexie repository in src/db/implementations/dexie/[entity].ts using the tryCatch pattern and generateId for new records.
  • Step 5: Register the repository in the Dexie provider at src/db/implementations/dexie/index.ts.
  • Step 6: Export a public getter in src/db/index.ts, e.g., getEntityRepository(), and use it in features.

Dependency Matrix

Required Modules

None required

Components

Standard package

💻 Claude Code Installation

Recommended: Let Claude install automatically. Simply copy and paste the text below to Claude Code.

Please help me install this Skill:
Name: repository-pattern
Download link: https://github.com/alexanderop/workoutTracker/archive/main.zip#repository-pattern

Please download this .zip file, extract it, and install it in the .claude/skills/ directory.
View Source Repository

Agent Skills Search Helper

Install a tiny helper to your Agent, search and equip skill from 223,000+ vetted skills library on demand.