Implemented with Repository Protocol pattern for offline fork support: - CollectionService with PostgresCollectionRepository - DeckService with PostgresDeckRepository - DeckValidator with DeckConfig + CardService injection - Starter deck definitions (5 types: grass, fire, water, psychic, lightning) - Pydantic schemas for collection and deck APIs - Unit tests for DeckValidator (32 tests passing) Architecture follows pure dependency injection - no service locator patterns. Added CLAUDE.md documenting DI requirements and patterns. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
32 lines
859 B
Python
32 lines
859 B
Python
"""Repository layer for Mantimon TCG.
|
|
|
|
This package defines repository protocols (interfaces) and their implementations.
|
|
Repositories handle pure data access (CRUD operations), while services contain
|
|
business logic.
|
|
|
|
The protocol pattern enables:
|
|
- Easy testing with mock repositories
|
|
- Multiple storage backends (PostgreSQL, SQLite, JSON files)
|
|
- Offline fork support without rewriting service layer
|
|
|
|
Usage:
|
|
from app.repositories import CollectionRepository, DeckRepository
|
|
from app.repositories.postgres import PostgresCollectionRepository
|
|
|
|
# In production (dependency injection)
|
|
repo = PostgresCollectionRepository(db_session)
|
|
|
|
# In tests
|
|
repo = MockCollectionRepository()
|
|
"""
|
|
|
|
from app.repositories.protocols import (
|
|
CollectionRepository,
|
|
DeckRepository,
|
|
)
|
|
|
|
__all__ = [
|
|
"CollectionRepository",
|
|
"DeckRepository",
|
|
]
|