Skip to content

[Feature] : [Issue Proposal] : Refactor Redundant Scheduler Architecture and Remove Mock Production Services#152

Open
hrshjswniii wants to merge 12 commits into
vanshaggarwal27:mainfrom
hrshjswniii:feature/Refactor-Redundant-Scheduler
Open

[Feature] : [Issue Proposal] : Refactor Redundant Scheduler Architecture and Remove Mock Production Services#152
hrshjswniii wants to merge 12 commits into
vanshaggarwal27:mainfrom
hrshjswniii:feature/Refactor-Redundant-Scheduler

Conversation

@hrshjswniii

Copy link
Copy Markdown
Contributor

Problem


The backend scheduler architecture contains multiple overlapping implementations, causing production reminder workflows to be unreliable and difficult to maintain. The application currently initializes a redundant scheduler layer while parallel scheduler and notification services exist in separate directories with duplicated responsibilities.

This creates several issues:

  • Multiple scheduler implementations make it unclear which workflow is actually responsible for production reminder execution.
  • Notification providers (Twilio and ElevenLabs) are duplicated across different service layers, increasing maintenance overhead and risk of inconsistent behavior.
  • Mock or legacy scheduling components remain alongside production implementations, making onboarding and debugging difficult.
  • Startup lifecycle management is fragmented, preventing a clear, centralized orchestration flow for background jobs.
  • The application still relies on older startup initialization patterns instead of a modern lifecycle-based architecture.


Solution


This PR refactors the backend architecture by consolidating scheduling and notification responsibilities into a single production-ready service layer.

The refactor:

  • Promotes the production scheduler as the sole scheduler implementation used by the application.
  • Consolidates Twilio, ElevenLabs, progress-checking, and scheduling logic into a unified services layer.
  • Removes redundant, duplicated, and mock scheduler implementations.
  • Establishes a clear execution flow between application startup, scheduler orchestration, progress monitoring, and notification delivery.
  • Modernizes application startup and shutdown handling through a centralized lifecycle management approach.
  • Improves maintainability by reducing duplicated code paths and simplifying dependency relationships.


Files Affected


Added

  • backend/services/scheduler.py
  • backend/services/progress_checker.py
  • backend/services/twilio_service.py
  • backend/services/elevenlabs_service.py

Modified

  • backend/main.py
  • backend/ruff.toml
  • backend/tests/conftest.py

Removed

  • backend/alerts/ (entire directory)
  • backend/services/reminder_scheduler.py
  • backend/services/call_service.py
  • backend/services/voice_service.py
  • backend/utils/progress_checker.py


User Stories


  • As a developer, I want a single scheduler architecture so that reminder workflows are easier to understand and maintain.
  • As a maintainer, I want notification providers centralized in one location so that future integrations and fixes only need to be implemented once.
  • As a contributor, I want a clear service dependency structure so that debugging background jobs becomes straightforward.
  • As a platform user, I want reminder and notification workflows to run consistently in production without relying on inactive or mock scheduler components.


Acceptance Criteria


  • Only one production scheduler implementation is responsible for reminder execution.
  • Twilio functionality is consolidated into a single service module.
  • ElevenLabs functionality is consolidated into a single service module.
  • Legacy mock scheduler implementations are removed.
  • Duplicate progress-checking logic is removed.
  • Application startup initializes the production scheduler through the centralized lifecycle flow.
  • Background jobs start and stop gracefully during application lifecycle events.
  • Existing automated tests pass without regressions.
  • Reminder and notification workflows continue functioning correctly after the refactor.


Contribution Interest


Hiii @vanshaggarwal27 , i've implemented the issue assigned to me
please do review the PR and feel free to merge it
fixes issue #134

@vanshaggarwal27

Copy link
Copy Markdown
Owner

Please resovle merge conflict

@vanshaggarwal27

Copy link
Copy Markdown
Owner

@hrshjswniii all tests are passed please resolve merge conflict so that i can merge this branch

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.

2 participants