major-domo-database/app/services/CLAUDE.md
Cal Corum bcdde572e8 docs: Add subdirectory CLAUDE.md files for routers, stratplay, and services
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>
2026-02-17 17:32:25 -06:00

905 B

Services Layer

Business logic extracted from routers for testability. Uses dependency injection.

Architecture

  • interfaces.py — Protocol classes (AbstractPlayerRepository, AbstractTeamRepository, AbstractCacheService)
  • base.pyBaseService 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