Skip to content

Refactor: Split services.rs into dedicated service modules#482

Merged
Lynndabel merged 8 commits into
ChianLojistics:mainfrom
Samuel1505:main
Jun 20, 2026
Merged

Refactor: Split services.rs into dedicated service modules#482
Lynndabel merged 8 commits into
ChianLojistics:mainfrom
Samuel1505:main

Conversation

@Samuel1505

Copy link
Copy Markdown
Contributor

[BA-01] Refactor: Split services.rs into dedicated service modules

Summary

closes #407

  • Extracted ProductService, EventService, UserService, ApiKeyService, SyncService, and RecallService from the 1282-line monolithic services.rs into individual files under backend/src/services/
  • Fixed a correctness issue: cache helper methods (invalidate_product_cache, invalidate_global_stats) were incorrectly placed inside trait impl blocks; they are now in inherent impl blocks where they belong
  • Reduced services.rs to 40 lines of pub mod declarations and pub use re-exports — all existing import paths remain unchanged
  • Added missing re-exports for BatchService, BatchRepository, SupplierService, IoTService, QualityService, and RegulatoryService, which were referenced in handlers but not previously re-exported

New files

File Lines Contents
services/product.rs 266 ProductService + ProductRepository impl
services/event.rs 169 EventService + EventRepository impl
services/user.rs 178 UserService + UserRepository impl
services/api_key.rs 143 ApiKeyService + ApiKeyRepository impl
services/sync.rs 64 SyncService
services/recall.rs 343 RecallService

Test plan

  • cargo check passes with no new errors
  • All handler paths that call into services resolve correctly (no broken imports)
  • crate::services::ApiKeyService::hash_api_key / generate_api_key still callable as static methods
  • crate::services::UserService::hash_password still callable as a static method
  • crate::services::BatchRepository trait is accessible from handlers/batch.rs

Relates to

Closes #407

@vercel

vercel Bot commented Jun 19, 2026

Copy link
Copy Markdown

@Samuel1505 is attempting to deploy a commit to the Ebeleokolo's projects Team on Vercel.

A member of the Team first needs to authorize it.

@Lynndabel

Copy link
Copy Markdown
Collaborator

welldone @Samuel1505

@Lynndabel Lynndabel merged commit 9af3a76 into ChianLojistics:main Jun 20, 2026
3 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BACKEND][BA-01] Service Module: 1 Refactoring

2 participants