Provide targeted context for each app subdirectory so Claude Code understands local patterns without relying on the root CLAUDE.md. Also simplifies root CLAUDE.md dev/prod environment sections. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
18 lines
905 B
Markdown
18 lines
905 B
Markdown
# Services Layer
|
|
|
|
Business logic extracted from routers for testability. Uses dependency injection.
|
|
|
|
## Architecture
|
|
|
|
- `interfaces.py` — Protocol classes (`AbstractPlayerRepository`, `AbstractTeamRepository`, `AbstractCacheService`)
|
|
- `base.py` — `BaseService` with lazy-loaded default repos (imports from `db_engine` on first access)
|
|
- `mocks.py` — Mock implementations for testing without DB/Redis
|
|
- `player_service.py`, `team_service.py` — Domain services (class methods, no instance needed for reads)
|
|
|
|
## Key Patterns
|
|
|
|
- Services use `@staticmethod`/`@classmethod` for read operations (no instantiation needed)
|
|
- Default repos are created lazily inside `@property` methods to avoid circular imports with `db_engine`
|
|
- For testing: pass mock repos via `ServiceConfig` or constructor kwargs
|
|
- Only `players` and `teams` routers currently use the service layer; others call `db_engine` directly
|