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>
905 B
905 B
Services Layer
Business logic extracted from routers for testability. Uses dependency injection.
Architecture
interfaces.py— Protocol classes (AbstractPlayerRepository,AbstractTeamRepository,AbstractCacheService)base.py—BaseServicewith lazy-loaded default repos (imports fromdb_engineon first access)mocks.py— Mock implementations for testing without DB/Redisplayer_service.py,team_service.py— Domain services (class methods, no instance needed for reads)
Key Patterns
- Services use
@staticmethod/@classmethodfor read operations (no instantiation needed) - Default repos are created lazily inside
@propertymethods to avoid circular imports withdb_engine - For testing: pass mock repos via
ServiceConfigor constructor kwargs - Only
playersandteamsrouters currently use the service layer; others calldb_enginedirectly