Skip to content

Latest commit

 

History

History
58 lines (47 loc) · 1.92 KB

File metadata and controls

58 lines (47 loc) · 1.92 KB

Service Refactoring Plan

Analysis

MockStellarService.js (860+ lines)

Current Responsibilities:

  1. Wallet management (create, balance, funding)
  2. Transaction operations (send, verify, history)
  3. Failure simulation (network errors, timeouts, rate limits)
  4. Validation (public keys, secret keys, amounts)
  5. Stream management (listeners, notifications)
  6. Configuration management

Proposed Breakdown:

  1. MockStellarService.js - Main service (orchestrator)
  2. stellar/MockWalletManager.js - Wallet operations
  3. stellar/MockTransactionManager.js - Transaction operations
  4. stellar/MockFailureSimulator.js - Failure simulation logic
  5. stellar/StellarValidator.js - Validation utilities
  6. stellar/MockStreamManager.js - Stream management

RecurringDonationScheduler.js (400+ lines)

Current Responsibilities:

  1. Schedule processing
  2. Retry logic with exponential backoff
  3. Execution logging
  4. Failure handling
  5. Status reporting

Proposed Breakdown:

  1. RecurringDonationScheduler.js - Main scheduler (orchestrator)
  2. scheduler/ScheduleExecutor.js - Execute individual schedules
  3. scheduler/RetryManager.js - Retry logic and backoff
  4. scheduler/ExecutionLogger.js - Logging operations

Benefits

  1. Improved Readability: Smaller files are easier to understand
  2. Better Testability: Each module can be tested independently
  3. Easier Maintenance: Changes are isolated to specific modules
  4. Reusability: Extracted modules can be reused elsewhere
  5. Single Responsibility: Each module has one clear purpose

Implementation Strategy

  1. Create new directory structure
  2. Extract modules one at a time
  3. Maintain backward compatibility
  4. Update tests incrementally
  5. Verify no breaking changes

Acceptance Criteria

  • ✅ All existing tests pass
  • ✅ No breaking changes to public API
  • ✅ Each file < 300 lines
  • ✅ Clear separation of concerns
  • ✅ Improved code documentation