4.7 KiB
4.7 KiB
Video Clipping Service Planning Prompt
Use this prompt to ask an AI to create a production-grade implementation plan for a Java Spring Boot video clipping microservice.
You are a senior Java/Spring Boot backend architect specializing in large-scale media-processing systems.
Create a production-grade implementation plan for a Java Spring Boot microservice that accepts very large video files and generates 8-second video clips.
Before answering, research current official or primary documentation for:
- Spring Boot and Java supported production versions.
- FFmpeg segmenting behavior and keyframe accuracy.
- Object-storage multipart/resumable upload best practices.
- Queue-based async processing.
- Kubernetes deployment, probes, resource limits, and observability.
- Spring Boot testing and Testcontainers.
Use citations or source links for important version and architecture claims.
Design principles:
- Do not load entire video files into application memory.
- Prefer direct-to-object-storage upload using signed URLs and multipart/resumable upload.
- Separate API service from video-processing workers.
- Use durable job state, retryable queues, idempotency, and cleanup.
- Explain the performance tradeoff between fast keyframe-aligned clipping and exact 8-second frame-accurate clipping.
- Use FFmpeg safely through isolated worker processes, not inline request processing.
Include these sections:
1. Goal and Scope
Define the service, assumptions, non-goals, supported formats, max file size, expected concurrency, and cloud/runtime assumptions.
2. Architecture
Design the full flow:
Client -> API -> signed upload URL -> object storage -> job record -> queue -> worker -> FFmpeg -> generated clips -> object storage -> job status.
Explain API service, worker service, database, queue, object storage, temporary disk, and cleanup responsibilities.
3. Technology Stack
Recommend Java version, Spring Boot version, database, queue, object storage, FFmpeg packaging, container base image, observability tools, and testing tools. Explain each choice.
4. API Contract
Design versioned REST endpoints using noun-based paths:
- Create video asset/upload session.
- Complete upload/register uploaded object.
- Create or start clip-generation job.
- Get job status.
- List generated clips.
- Get signed download URLs.
- Cancel/delete job.
For each endpoint include method, path, auth, idempotency, request schema, response schema, and examples.
5. Validation and Security
Include authn/authz, file size limits, media type checks, video probing, malware scanning, rate limiting, signed URL expiry, object key safety, tenant isolation, sensitive logging rules, and error handling.
6. Video Processing Design
Explain FFmpeg commands and strategy for:
- Fast segmentation using stream copy where acceptable.
- Accurate 8-second segmentation using transcoding/forced keyframes where required.
- Handling the final shorter segment.
- Audio/video sync.
- Variable frame rate videos.
- Corrupt inputs.
- Progress tracking.
- Retry behavior.
- Partial-output cleanup.
7. Data Model
Define tables/entities for video assets, upload sessions, processing jobs, generated clips, and job events. Include indexes, lifecycle states, and timestamps.
8. Performance and Scalability
Cover streaming, object-storage bandwidth, worker concurrency, CPU/memory/disk sizing, queue backpressure, autoscaling, timeout handling, large-file resilience, benchmarking, and cost tradeoffs.
9. Error Model
Use `application/problem+json` for non-2xx errors. Map 400, 401, 403, 404, 409, 413, 415, 422, 429, 500, and 503 with examples.
10. Testing Strategy
Include unit, integration, API contract, FFmpeg, queue, object-storage, large-file, failure/retry, security, load, and end-to-end tests. Use JUnit 5, Spring Boot test support, Testcontainers, realistic video fixtures, and mocked/sandboxed cloud services where appropriate.
11. Deployment and Operations
Include Docker, Kubernetes API and worker deployments, readiness/liveness/startup probes, resource requests/limits, ephemeral storage, horizontal autoscaling, metrics, logs, traces, alerts, dashboards, dead-letter queues, cleanup jobs, and disaster recovery.
12. Project Structure
Propose a clean/hexagonal Spring Boot package structure separating API, application services, domain, persistence, queue, storage, FFmpeg adapter, config, and tests.
13. Implementation Milestones
Break implementation into MVP, production hardening, performance tuning, and operational readiness.
14. Open Questions
List decisions needed before implementation, especially:
- Exact vs keyframe-aligned 8-second clips.
- Maximum file size.
- Supported codecs/containers.
- Cloud provider.
- Auth provider.
- Expected upload and processing volume.
- Retention policy.