Files
main_backend/query_codex.md
2026-03-17 18:11:23 +03:00

18 lines
1.2 KiB
Markdown

The user wants to refactor a backend project following DRY and KISS, keeping it developer-readable without hidden abstractions.
The user explicitly rejected a plan that did "in-place cleanup" of `cpv3/modules/tasks/service.py` and instead wants a different approach.
Currently, `tasks/service.py` is a 1600+ line monolith that:
1. Defines Dramatiq actors
2. Orchestrates job creation and duplication-checks
3. Has `submit_X` methods (e.g. `submit_media_probe`, `submit_transcription_generate`)
4. Has a giant `record_webhook_event` that updates the `Job` state
5. Contains domain-specific artifact saving (e.g. `_save_transcription_artifacts`, `_save_convert_artifacts`)
6. Handles cancellation logic.
Constraints:
1. Must use the exact module structure: `models.py`, `schemas.py`, `repository.py`, `service.py`, `router.py` (no subdirectories within modules).
2. Explicit, local helpers over hidden abstractions (no generic handler registries).
What is the best architectural approach to distribute these responsibilities across `jobs`, `tasks`, and domain modules (`media`, `transcription`, `captions`)?
Provide a concrete file-by-file blueprint on where each responsibility belongs and how the cross-module calls would look like, avoiding circular dependencies.