- Add UserRepository and LinkedAccountRepository protocols to protocols.py - Add UserEntry and LinkedAccountEntry DTOs for service layer decoupling - Implement PostgresUserRepository and PostgresLinkedAccountRepository - Refactor UserService to use constructor-injected repositories - Add get_user_service factory and UserServiceDep to API deps - Update auth.py and users.py endpoints to use UserServiceDep - Rewrite tests to use FastAPI dependency overrides (no monkey patching) This follows the established repository pattern used by DeckService and CollectionService, enabling future offline fork support. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
37 lines
1.0 KiB
Python
37 lines
1.0 KiB
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, UserRepository
|
|
from app.repositories.postgres import PostgresCollectionRepository, PostgresUserRepository
|
|
|
|
# In production (dependency injection)
|
|
repo = PostgresCollectionRepository(db_session)
|
|
user_repo = PostgresUserRepository(db_session)
|
|
|
|
# In tests
|
|
repo = MockCollectionRepository()
|
|
"""
|
|
|
|
from app.repositories.protocols import (
|
|
CollectionRepository,
|
|
DeckRepository,
|
|
LinkedAccountRepository,
|
|
UserRepository,
|
|
)
|
|
|
|
__all__ = [
|
|
"CollectionRepository",
|
|
"DeckRepository",
|
|
"LinkedAccountRepository",
|
|
"UserRepository",
|
|
]
|