Simplify architecture: remove overengineering, flatten structure

- Remove dead code: cache.py, context_managers.py, decorators.py, flask-limiter
- Replace AudioSource ABC + FakeFile (5 classes) with 4 plain functions
- Replace TempFileManager class with create_temp_file/cleanup_temp_files functions
- Simplify RequestLogger from 233 to 65 lines, remove file reading side-effect
- Convert HistoryLogger and AudioUtils classes to module-level functions
- Remove unused speed_up_audio and audio_speed_factor config
- Flatten single-file directories: shared/, api/, storage/, validation/, async_tasks/, logging/
- Merge logging config + request_logger into single infrastructure/log.py
- Fix request_logging config key (was request_logger)
- Trim CLAUDE.md to high-level only

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Serge Zaigraeff
2026-03-22 05:28:34 +03:00
co-authored by Claude Opus 4.6
parent 38785398b3
commit 2e2bad8255
30 changed files with 556 additions and 1407 deletions
+5 -5
View File
@@ -46,13 +46,13 @@ Non-negotiable. Violation = stop and fix before continuing.
## Audio Processing Rules
* FFmpeg and SoX are external dependencies. Always check subprocess return codes.
* Temp files must be created via `TempFileManager.temp_file()` context manager -- never raw `tempfile.mktemp`.
* Audio pipeline order matters: convert to WAV 16kHz -> normalize -> compress/expand -> speedup -> add silence.
* Temp files must be created via `create_temp_file()` from `app/infrastructure/storage.py` -- never raw `tempfile.mktemp`.
* Audio pipeline order matters: convert to WAV 16kHz -> normalize -> compress/expand -> add silence.
## Flask / API Rules
* New endpoints go in `app/api/routes.py` inside `_register_routes()`.
* All transcription endpoints delegate to `TranscriptionService.transcribe_from_source()`.
* New audio input methods: subclass `AudioSource`, implement `get_audio_file()`.
* New endpoints go in `app/routes.py` inside `_register_routes()`.
* All transcription endpoints delegate to `TranscriptionService.transcribe()`.
* New audio input methods: add a `get_*_file()` function in `sources.py` returning `(temp_path, filename, error)`.
* File validation runs through `FileValidator` -- never validate inline in routes.
* Configuration values accessed via `self.config.get()` with sensible defaults, except critical params which must crash if missing.