- Create ScanService class (src/server/services/scan_service.py)
- Use 'key' as primary series identifier throughout
- Include 'folder' as metadata only for display purposes
- Implement scan progress tracking via ProgressService
- Add callback classes for progress, error, and completion
- Support scan event subscription and broadcasting
- Maintain scan history with configurable limit
- Provide cancellation support for in-progress scans
- Create comprehensive unit tests (tests/unit/test_scan_service.py)
- 38 tests covering all functionality
- Test ScanProgress dataclass serialization
- Test callback classes (progress, error, completion)
- Test service lifecycle (start, cancel, status)
- Test event subscription and broadcasting
- Test key-based identification throughout
- Test singleton pattern
- Update infrastructure.md with ScanService documentation
- Document service overview and key features
- Document components and event types
- Document integration points
- Include usage example
- Update instructions.md
- Mark Task 3.4 as complete
- Mark Phase 3 as fully complete
- Remove finished task definition
Task: Phase 3, Task 3.4 - Update ScanService to Use Key
Completion Date: November 27, 2025
- Added optional 'key' and 'folder' fields to ProgressUpdate dataclass
- key: Primary series identifier (provider key, e.g., 'attack-on-titan')
- folder: Optional series folder name for display (e.g., 'Attack on Titan (2013)')
- Updated start_progress() and update_progress() methods to accept key/folder parameters
- Enhanced to_dict() serialization to include key/folder when present
- Updated all docstrings to clarify identifier usage
- Added 5 new comprehensive unit tests for key/folder functionality
- All 25 ProgressService tests passing
- Updated infrastructure.md with series identifier documentation
- Maintains backward compatibility - fields are optional
- Completed Phase 3, Task 3.3 of identifier standardization initiative
- Enhanced class and method docstrings to clarify 'key' as primary identifier
- Documented that 'folder' is metadata only (display and filesystem operations)
- Updated event handler documentation to show both key and folder are received
- Modernized type hints to Python 3.9+ style (list[dict] vs List[dict])
- Fixed PEP 8 line length violations
- All 18 anime service tests passing
Implementation follows identifier standardization initiative:
- key: Primary series identifier (provider-assigned, URL-safe)
- folder: Metadata for display and filesystem paths only
Task 3.2 completed November 23, 2025
Documented in infrastructure.md and instructions.md
- Updated DownloadService to use 'serie_id' (provider key) for identification
- Changed 'serie_folder' from Optional to required in models (DownloadItem, DownloadRequest)
- Removed incorrect fallback logic that used serie_id as folder name
- Enhanced docstrings to clarify purpose of each identifier field:
* serie_id: Provider key (e.g., 'attack-on-titan') for lookups
* serie_folder: Filesystem folder name (e.g., 'Attack on Titan (2013)') for file operations
- Updated logging to reference 'serie_key' for clarity
- Fixed all unit tests to include required serie_folder field
- All 25 download service tests passing
- All 47 download model tests passing
- Updated infrastructure.md with detailed documentation
- Marked Task 3.1 as completed in instructions.md
Benefits:
- Clear separation between provider identifier and filesystem path
- Prevents confusion from mixing different identifier types
- Consistent with broader series identifier standardization effort
- Better error messages when required fields are missing
- Add scheduler API endpoints for configuration and manual rescan triggers
- Add logging API endpoints for config management and log file operations
- Add diagnostics API endpoints for network and system information
- Extend config API with advanced settings, directory updates, export, and reset
- Update FastAPI app to include new routers
- Update API reference documentation with all new endpoints
- Update infrastructure documentation with endpoint listings
- Add comprehensive API implementation summary
All new endpoints follow project coding standards with:
- Type hints and Pydantic validation
- Proper authentication and authorization
- Comprehensive error handling and logging
- Security best practices (path validation, input sanitization)
Test results: 752/802 tests passing (93.8%)
- Created callback interfaces (ProgressCallback, ErrorCallback, CompletionCallback)
- Defined rich context objects (ProgressContext, ErrorContext, CompletionContext)
- Implemented CallbackManager for managing multiple callbacks
- Integrated callbacks into SerieScanner for scan progress reporting
- Enhanced SeriesApp with download progress tracking via callbacks
- Added error and completion notifications throughout core operations
- Maintained backward compatibility with legacy callback system
- Created 22 comprehensive unit tests with 100% pass rate
- Updated infrastructure.md with callback system documentation
- Removed completed tasks from instructions.md
The callback system provides:
- Real-time progress updates with percentage and phase tracking
- Comprehensive error reporting with recovery information
- Operation completion notifications with statistics
- Thread-safe callback execution with exception handling
- Support for multiple simultaneous callbacks per type
- Add async_download() and async_rescan() methods for non-blocking operations
- Implement ProgressInfo dataclass for structured progress reporting
- Add OperationResult dataclass for operation outcomes
- Introduce OperationStatus enum for state tracking
- Add cancellation support with cancel_operation() method
- Implement comprehensive error handling with callbacks
- Add progress_callback and error_callback support in constructor
- Create 22 comprehensive unit tests for all functionality
- Update infrastructure.md with core logic documentation
- Remove completed task from instructions.md
This enhancement enables web integration with real-time progress updates,
graceful cancellation, and better error handling for long-running operations.
Implemented full JWT-based authentication integration between frontend and backend:
Frontend Changes:
- Updated login.html to store JWT tokens in localStorage after successful login
- Updated setup.html to use correct API payload format (master_password)
- Modified app.js and queue.js to include Bearer tokens in all authenticated requests
- Updated makeAuthenticatedRequest() to add Authorization header with JWT token
- Enhanced checkAuthentication() to verify token and redirect on 401 responses
- Updated logout() to clear tokens from localStorage
API Endpoint Updates:
- Mapped queue API endpoints to new backend structure
- /api/queue/clear → /api/queue/completed (DELETE) for clearing completed
- /api/queue/remove → /api/queue/{item_id} (DELETE) for single removal
- /api/queue/retry payload changed to {item_ids: []} array format
- /api/download/pause|resume|cancel → /api/queue/pause|resume|stop
Testing:
- Created test_frontend_integration_smoke.py with JWT token validation tests
- Verified login returns access_token, token_type, and expires_at
- Tested Bearer token authentication on protected endpoints
- Smoke tests passing for authentication flow
Documentation:
- Updated infrastructure.md with JWT authentication implementation details
- Documented token storage, API endpoint changes, and response formats
- Marked Frontend Integration task as completed in instructions.md
- Added frontend integration testing section
WebSocket:
- Verified WebSocket integration with new backend (already functional)
- Dual event handlers support both old and new message types
- Room-based subscriptions working correctly
This completes Task 7: Frontend Integration from the development instructions.
- Created websocket_client.js: Native WebSocket wrapper with Socket.IO-compatible interface
- Automatic reconnection with exponential backoff
- Room-based subscriptions for targeted updates
- Message queueing during disconnection
- Updated HTML templates (index.html, queue.html):
- Replaced Socket.IO CDN with native websocket_client.js
- No external dependencies needed
- Updated JavaScript files (app.js, queue.js):
- Added room subscriptions on WebSocket connect (scan_progress, download_progress, downloads)
- Added dual event handlers for backward compatibility
- Support both old (scan_completed) and new (scan_complete) message types
- Support both old (download_error) and new (download_failed) message types
- Support both old (queue_updated) and new (queue_status) message types
- Registered anime router in fastapi_app.py:
- Added anime_router import and registration
- All API routers now properly included
- Documentation:
- Created FRONTEND_INTEGRATION.md with comprehensive integration guide
- Updated infrastructure.md with frontend integration section
- Updated instructions.md to mark task as completed
- Testing:
- Verified anime endpoint tests pass (pytest)
- API endpoint mapping documented
- WebSocket message format changes documented
Benefits:
- Native WebSocket API (faster, smaller footprint)
- No external CDN dependencies
- Full backward compatibility with existing code
- Proper integration with backend services
- Real-time updates via room-based messaging
- Add comprehensive REST API for download queue management
- Implement GET /api/queue/status endpoint with queue status and statistics
- Implement POST /api/queue/add for adding episodes to queue with priority support
- Implement DELETE /api/queue/{id} and DELETE /api/queue/ for removing items
- Implement POST /api/queue/start and /api/queue/stop for queue control
- Implement POST /api/queue/pause and /api/queue/resume for pause/resume
- Implement POST /api/queue/reorder for queue item reordering
- Implement DELETE /api/queue/completed for clearing completed items
- Implement POST /api/queue/retry for retrying failed downloads
- Add get_download_service and get_anime_service dependencies
- Register download router in FastAPI application
- Add comprehensive test suite for all endpoints
- All endpoints require JWT authentication
- Update infrastructure documentation
- Remove completed task from instructions.md
Follows REST conventions with proper error handling and status codes.
Tests cover success cases, error conditions, and authentication requirements.
- Add comprehensive download queue models in src/server/models/download.py
- DownloadStatus and DownloadPriority enums for type safety
- EpisodeIdentifier for episode references
- DownloadProgress for real-time progress tracking
- DownloadItem for queue item representation with timestamps and error handling
- QueueStatus for overall queue state management
- QueueStats for aggregated queue statistics
- DownloadRequest/DownloadResponse for API contracts
- QueueOperationRequest and QueueReorderRequest for queue management
- QueueStatusResponse for complete status endpoint responses
- Add comprehensive unit tests (47 tests, all passing)
- Test validation constraints (positive numbers, ranges, etc.)
- Test default values and optional fields
- Test serialization/deserialization
- Test model relationships and nested structures
- Update documentation
- Add download models section to infrastructure.md
- Remove completed task from instructions.md
- Update models package __init__.py
All models follow PEP 8 style guide with proper type hints and validation.