refactor: split SqliteMovieRepository fat repo into per-port structs #2

Closed
opened 2026-06-10 09:02:04 +00:00 by GKaszewski · 0 comments
Owner

Problem

SqliteMovieRepository implements four unrelated port traits — MovieRepository, ReviewRepository, DiaryRepository, StatsRepository — while every other entity (users, watchlist, import_session, etc.) gets its own dedicated struct. The inconsistency makes the codebase harder to navigate: the name gives no hint it owns review/diary/stats logic, and wire() has to clone the same Arc four times with different coercions.

Proposed fix

Split into four structs, each implementing exactly one port trait and holding a pool clone:

  • SqliteMovieRepositoryMovieRepository
  • SqliteReviewRepositoryReviewRepository
  • SqliteDiaryRepositoryDiaryRepository
  • SqliteStatsRepositoryStatsRepository

Private helper methods on the fat struct that are shared across these domains move into whichever repo actually owns them. wire() becomes uniform — every port maps to exactly one dedicated struct.

Impact

  • crates/adapters/sqlite/src/lib.rs (primary)
  • crates/adapters/postgres/src/ (same pattern likely applies)
  • wire() in both sqlite and postgres adapters
## Problem `SqliteMovieRepository` implements four unrelated port traits — `MovieRepository`, `ReviewRepository`, `DiaryRepository`, `StatsRepository` — while every other entity (users, watchlist, import_session, etc.) gets its own dedicated struct. The inconsistency makes the codebase harder to navigate: the name gives no hint it owns review/diary/stats logic, and `wire()` has to clone the same `Arc` four times with different coercions. ## Proposed fix Split into four structs, each implementing exactly one port trait and holding a pool clone: - `SqliteMovieRepository` → `MovieRepository` - `SqliteReviewRepository` → `ReviewRepository` - `SqliteDiaryRepository` → `DiaryRepository` - `SqliteStatsRepository` → `StatsRepository` Private helper methods on the fat struct that are shared across these domains move into whichever repo actually owns them. `wire()` becomes uniform — every port maps to exactly one dedicated struct. ## Impact - `crates/adapters/sqlite/src/lib.rs` (primary) - `crates/adapters/postgres/src/` (same pattern likely applies) - `wire()` in both sqlite and postgres adapters
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: GKaszewski/movies-diary#2