Implement server-side job queue for audiobook generation:
- Jobs API (/api/jobs) with GET, POST, DELETE endpoints
- Background job processor that runs without browser open
- Job status tracking (pending, processing, completed, failed, cancelled)
- Real-time progress updates (0-100% with status messages)
- Automatic error recovery - skips problematic sentences
- Integration hooks for TTS and audiobook APIs
Features:
- Create audiobook generation jobs with voice/speed/format selection
- Monitor job progress with detailed status updates
- Cancel in-progress jobs
- Query jobs by ID or status
- Persistent job tracking in IndexedDB
Job processor capabilities:
- Server-side document text extraction
- Sentence-by-sentence TTS generation with progress tracking
- Automatic retry and error handling
- Combines audio chunks into final audiobook file
- Returns bookId for downloading completed audiobook
Next steps for full implementation:
- Integrate with PDF/EPUB text extraction
- Connect to existing /api/audiobook endpoints
- Add UI components for job creation and monitoring
- Implement client-side polling or WebSockets for live updates
Files:
- app/api/jobs/route.ts: RESTful API for job management
- lib/jobProcessor.ts: Background job processing logic
- types/jobs.ts: Job type definitions and interfaces