Architecture: Image Processing Pipeline

By Engineering Team•September 21, 2026•6 min read

This is the architecture behind the decision recorded in ADR-00001, satisfying the requirements in BRD-001 and SR-001.

Diagram

High-resolution image processing pipeline — component and data flow diagram

Components

Component Language / Runtime Role
media-access-service Rust (Axum) Issues short-lived signed GCS URLs — upload and download — and never touches raw image bytes itself.
Staging Bucket / Asset Bucket GCS Staging holds a raw upload until it’s transcoded; Asset Bucket holds the derived WebP/AVIF variants served by the CDN.
firebase-function Node.js (Firebase Cloud Functions) Fires on GCS onObjectFinalized/onObjectDeleted storage events and republishes them as Pub/Sub messages — no HTTP surface, no Nginx gateway in front of it.
content-processor Go Consumes the upload event, transcodes into WebP/AVIF at 1.0x/2.0x/3.0x via a per-use-case strategy (multi-variant catalog image, single master logo, square avatar crop), uploads the derived assets, records the source→derived mapping in MongoDB, and fans the result back out.
Pub/Sub — product-image-uploads GCP Pub/Sub firebase-function → content-processor. One topic, one subscription — content-processor is its only consumer.
Pub/Sub — product-image-processed / product-image-removed GCP Pub/Sub content-processor → downstream domain services. One topic pair, four independent subscriptions, routed by transaction_name rather than by topic.
Downstream consumers Go / Rust product-catalog (product & variant images — the default, unprefixed subscription), shop-service (shop banners), tenant-service (tenant logos), user-secure-engine (customer avatars). Each owns its own subscription and can be added or removed without any change to content-processor.
CDN — Serves derived assets from the Asset Bucket via the signed download URLs media-access-service issues.

End-to-end flow

  1. A client (seller uploading a product photo, an admin uploading a tenant logo, a shopper setting an avatar, etc.) asks the API Gateway for an upload slot.
  2. media-access-service issues a short-lived, cryptographically signed GCS upload URL scoped to the Staging Bucket (FR-01). Signing credentials never leave this service (NFR-06).
  3. The client PUTs the raw image bytes directly to GCS using that URL — the API Gateway and every application service stay off the raw-binary path entirely (FR-02, NFR-01).
  4. firebase-function’s storage trigger fires on onObjectFinalized for the staging bucket and publishes an ingestion event onto the product-image-uploads Pub/Sub topic, carrying tenant_id/correlation_id/traceparent so the trace begun at the presigned-URL request continues unbroken (FR-03).
  5. content-processor consumes the event, downloads the raw image, and picks the transcoding strategy for the use case it was uploaded for — a multi-density product/variant catalog image, a single master tenant logo, or a square avatar crop — producing WebP and AVIF at 1.0x/2.0x/3.0x (FR-04).
  6. content-processor uploads every derived variant to the Asset Bucket and writes the source-to-derived asset mapping to MongoDB (FR-05).
  7. content-processor publishes a “processing complete” event to product-image-processed (or product-image-removed on delete), carrying the derived asset paths and the same tracing/tenant context (FR-06).
  8. product-catalog, shop-service, tenant-service, and user-secure-engine each hold their own subscription on that topic pair and independently update their own database models — none of them call each other, and none of them are known to content-processor by name (FR-07).
  9. When any of those domain services later needs to render the image, media-access-service issues a signed download URL for the specific asset, and the CDN serves it (FR-08).