maatify/data-repository

Unified Repository Abstraction Layer over MySQL, MongoDB, and Redis using maatify/data-adapters.

Installs: 0

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

Open Issues: 0

pkg:composer/maatify/data-repository

dev-main 2025-11-16 10:30 UTC

This package is auto-updated.

Last update: 2025-11-16 10:31:04 UTC


README

Unified Repository Abstraction Layer for the Maatify Ecosystem

Maatify.dev

Version PHP Build

Monthly Downloads Total Downloads

Stars License Status Code Quality

Changelog Security

๐Ÿงฉ Overview

maatify/data-repository provides a clean, unified repository abstraction layer above maatify/data-adapters.

It standardizes how all MySQL, MongoDB, and Redis operations are performed throughout the Maatify ecosystem by enforcing:

  • Repository-first data interaction
  • DTO-friendly hydration workflow
  • Consistent error handling
  • Shared abstraction for all business modules
  • Zero direct PDO/Mongo/Redis driver usage

This ensures clean architecture, high testability, and full adapter isolation.

๐Ÿš€ Features

โœ… Unified Repository Base Classes

  • BaseMySQLRepository
  • BaseMongoRepository
  • BaseRedisRepository
  • Shared BaseRepository

โœ… Repository Interfaces

  • RepositoryInterface
  • MySQL / Mongo / Redis specific contracts

โœ… DTO Hydration Layer (Phase 4)

  • Simple hydration pipeline
  • Type-safe mapping

โœ… Flexible Database Profiles

Works seamlessly with:

mysql.main
mysql.reporting
mongo.logs
redis.cache

๐Ÿ”ฎ Future Enhancements

  • Repository caching (v1.1.0)
  • Observers (v1.2.0)
  • Unit of Work (v2.0.0)
  • Query Builder integration

๐Ÿ“ฅ Installation

composer require maatify/data-repository

Autoloads into:

Maatify\DataRepository\

๐Ÿ—๏ธ Architecture

src/
  Contracts/
    RepositoryInterface.php
    MySQLRepositoryInterface.php
    MongoRepositoryInterface.php
    RedisRepositoryInterface.php

  Exceptions/
    RepositoryException.php
    NotFoundException.php
    InvalidRepositoryArgumentException.php
    UnsupportedDriverException.php

  Repository/
    BaseRepository.php
    BaseMySQLRepository.php
    BaseMongoRepository.php
    BaseRedisRepository.php   โ† Added in Phase 2

โœ” Clean separation โœ” PSR-12 compliant โœ” No circular dependencies โœ” No business logic inside repositories

๐Ÿง  Usage Examples (After Phase 2)

MySQL Example

$user = $this->userRepository->find(['active' => 1]);

Redis Example

$this->cacheRepository->set('session:123', ['id' => 123], ttl: 3600);

Mongo Example

$logs = $this->auditRepository->find(['level' => 'warning']);

๐Ÿ”ง Composer Scripts

composer test      # PHPUnit
composer analyse   # PHPStan
composer format    # php-cs-fixer

๐Ÿงช Testing

PHPUnit includes:

  • phpunit.xml
  • SmokeTest (Phase 1)
  • Full Base Repository Test Suite (Phase 2)
  • GitHub Actions integration

Run tests:

composer test

๐Ÿ“ Changelog

See CHANGELOG.md Semantic Versioning (SemVer).

๐Ÿ—บ๏ธ Roadmap

v1.0.0

โœ” Phase 1 โ€” Bootstrapping

  • Namespace & structure
  • Contracts
  • Exceptions
  • PHPUnit
  • CI pipeline
  • Initial docs

โœ” Phase 2 โ€” Base Repository Layer (Completed)

  • Base MySQL/Mongo/Redis repositories
  • DatabaseResolver integration
  • Dynamic profile support
  • Fully typed & PHPStan-clean
  • Comprehensive PHPUnit coverage

โณ Phase 3 โ€” Generic Repositories

โณ Phase 4 โ€” DTO Hydration Layer

โณ Release v1.0.0

v1.1.0

  • Repository Caching Layer

v1.2.0

  • Repository Observers (before/after save)

v2.0.0

  • Unit Of Work
  • Entity Tracking
  • Transaction Boundaries

๐Ÿค Contributing

See CONTRIBUTING.md

  • PSR-12
  • Strict typing
  • Mandatory PHPUnit tests
  • No direct driver usage

๐Ÿ” Security

See SECURITY.md

Report vulnerabilities privately at: ๐Ÿ“ง security@maatify.dev

๐Ÿ“œ Code of Conduct

See CODE_OF_CONDUCT.md

๐Ÿ”— Full documentation & release notes: see /docs/README.full.md

๐Ÿชช License

MIT license ยฉ Maatify.dev
Youโ€™re free to use, modify, and distribute this library with attribution.

๐Ÿ‘ค Author

Mohamed Abdulalim โ€” Backend Lead & Technical Architect
๐Ÿ”— https://www.maatify.dev | โœ‰๏ธ mohamed@maatify.dev

๐Ÿค Contributors

Special thanks to the Maatify.dev engineering team and open-source contributors.

Built with โค๏ธ by Maatify.dev โ€” Unified Ecosystem for Modern PHP Libraries