Content-Processor — Image Optimisation Worker
By Engineering Team•September 20, 2026•6 min read
Responsibility
content-processor is the asynchronous image-transcoding stage of the high-resolution-image pipeline. It never talks to a client directly and it does not generate presigned URLs — that’s media-access-service’s job. Its responsibility starts when a raw image lands in the staging bucket and ends when a processed-image event is published for other services to consume.
- Subscribes to the Pub/Sub topic
firebase-functionpublishes to when a new object is finalized in the staging bucket. - Downloads the raw image referenced by the event.
- Transcodes it via libvips (
bimg) into WebP + AVIF, at base / 2.0x / 3.0x pixel densities — six derived assets per source image. - Uploads the derived assets to the asset bucket.
- Records the source→derived-asset mapping (tracking info) in MongoDB, so a later re-process or an audit can trace which processed files came from which upload event.
- Publishes a “processed image” event (image URL + metadata) to a second Pub/Sub topic, fanned out to every domain service that stores a reference to the image (
product-catalog,shop-service,tenant-service, etc.) —content-processorhas no knowledge of who its consumers are, so adding a new one never requires changing this service.
Tech Stack
| Concern | Choice |
|---|---|
| Language | Go |
| Data store | MongoDB (tracking info only — never the image bytes) |
| Object storage | Firebase Storage / GCS (asset bucket) |
| Messaging | Firebase Pub/Sub — subscriber on the upload-event topic, publisher on the processed-image topic |
| Image transcoding | libvips via the bimg binding |
| HTTP framework | Echo (health/internal endpoints only — no public REST surface) |
| Dependency injection | Uber Fx |
| Template | @templates/go-pubsub-service |
Implementation Notes
- The processed-image publish is fire-and-forget:
context.WithoutCancel(ctx)+ a goroutine, per SR-003 FR-12’s background-goroutine rule. This is safe because the source→derived-asset mapping is already persisted to MongoDB (step 5) before the publish runs — a publish failure is logged but never loses data, it only delays fan-out to downstream consumers until Pub/Sub redelivers (there’s currently no bounded retry/DLQ on top of that redelivery — see Technical Debt — Image Pipeline Reliability Gaps, TD-01). - Exposed only at
8000(Nginx/content-processor/admin/api/v1/*) → container8080, and that surface is limited to health/internal endpoints — the real work happens over Pub/Sub, not REST.
Full service reference: content-processor/CLAUDE.md. Pipeline overview: Create high resolution image for different process (ADR).