ADR-00001 — Direct Upload, Event-Driven Image Pipeline

By Engineering Team•September 21, 2026•5 min read
  • Status: Approved / Implemented
  • Date: 2026-09-21
  • Authors: Engineering Team

Context

As an e-commerce platform, we need to create high-resolution images across Product Catalogs, Banners, Tenant Logos, and User Avatars. This requires generating multi-format assets (WebP + AVIF) at multiple density tiers (base / 2.0x / 3.0x). The architecture must be resilient, highly available, and horizontally scalable.


Decision Drivers (FRs & NFRs)

See SR-001 for the full requirement list.

  • NFR-01 (Gateway Protection): High upload volume must not saturate API Gateway compute or proxy heavy raw file bytes.
  • NFR-03 (Transcoding Scale): CPU-heavy transcoding workloads must scale independently from lightweight, high-QPS URL signing (QPS = Queries Per Second).
  • NFR-06 (Security Isolation): Cryptographic GCS signing keys must be isolated to a memory-safe component with a narrow attack surface.
  • FR-07 (Loose Coupling): Downstream domain consumers (product-catalog, shop-service, tenant-service, user-secure-engine) must consume image-ready events asynchronously without tight coupling to the processing worker.

Options Evaluated

Option 1 — Presigned direct-to-storage upload + event-driven pipeline (CHOSEN)

A dedicated Rust microservice issues short-lived signed URLs for upload and download. Raw uploads land in a staging bucket; a serverless trigger relays the event to an async Go worker via Pub/Sub; the worker transcodes assets using libvips and fans results back out over a second Pub/Sub topic to all interested downstream services.

  • Pros:
    • Zero proxy overhead: API Gateway and application services never handle raw image bytes.
    • Decoupled execution: ingestion is separated from processing; Pub/Sub provides native message redelivery.
    • Zero-coupling fan-out: downstream services subscribe to the processed/removed topics independently — four consumers today (product-catalog, shop-service, tenant-service, user-secure-engine) with zero changes to content-processor for each new one.
    • Security isolation: cryptographic URL signing lives entirely inside a dedicated Rust service.
  • Cons & Accepted Trade-offs:
    • Eventual consistency: the client UI must model a “Processing” state until the background pipeline completes.
    • Tracing complexity: requires strict propagation of traceparent and correlation_id across Pub/Sub boundaries.
    • No bounded retry/dead-letter policy is configured yet on this pipeline’s subscriptions, and CDN caching has only a local dev stand-in, not a production policy — see Technical Debt — Image Pipeline Reliability Gaps.

Option 2 — Synchronous upload directly to Content Processor

Clients upload multipart binaries directly to an HTTP endpoint on content-processor. The processor transcodes images synchronously and makes direct API calls to downstream services.

  • Pros:
    • Simpler request flow to reason about — one HTTP call, an immediate pass/fail response, no “Processing” intermediate state for the client UI to model.
    • No presigned-URL signing service or Pub/Sub fan-out plumbing required at all.
  • Cons (Why Rejected):
    • Processing raw binaries on app endpoints causes memory saturation during peak upload bursts (violates NFR-01).
    • Tightly couples content-processor to every downstream API (violates FR-07’s loose-coupling requirement).

Option 3 — Monolithic signing and transcoding service

Fold presigned URL signing into content-processor or the API Gateway layer instead of maintaining a standalone Rust microservice.

  • Pros:
    • Fewer moving parts to deploy and operate — one service instead of two, with no internal contract to define and maintain between them.
    • A change spanning both signing and transcoding logic ships as a single-service change instead of a coordinated two-service rollout.
  • Cons (Why Rejected):
    • Forces high-QPS signing and CPU-heavy transcoding to share the same compute scaling knobs (violates NFR-03).
    • Spreads sensitive storage signing credentials across broader application codebases (violates NFR-06).

Option 4 — Client-triggered processing (client calls a backend API after upload instead of relying on the storage event)

Rather than firebase-function reacting to GCS’s onObjectFinalized storage event, the client itself would call a dedicated backend endpoint immediately after its presigned-URL upload finishes, explicitly telling the backend to start processing.

  • Pros:
    • Avoids depending on GCS’s storage-event trigger and its own delivery guarantees — processing starts from a direct, synchronous backend call the client controls.
    • Gives the client an immediate acknowledgment that processing has been requested, rather than an implicit trust that the storage event will fire.
  • Cons (Why Rejected):
    • Makes processing initiation dependent on the client successfully completing one more step after the upload itself already succeeded — a dropped connection, a crashed app, or a closed tab between the upload finishing and that confirmation call leaves the raw object sitting in the Staging Bucket with nothing left to trigger processing, unless a separate orphan-scan/reconciliation job is built to catch it. No such job exists in this pipeline today.
    • The chosen design (Option 1) has no such dependency: onObjectFinalized fires as an intrinsic part of the GCS write itself (FR-03) — processing starts regardless of what the client does, or fails to do, the moment the upload completes. This is a resilience property of the storage-event trigger specifically, not just a consequence of being “event-driven” in general.

Final Decision

Option 1 is selected as it is the only architectural candidate that satisfies all performance, security, and extensibility requirements. Its GCS storage-event trigger (vs. a client-orchestrated confirmation call, Option 4) is also the more resilient of the two ingestion-completion signals, since it doesn’t depend on the client remaining connected or well-behaved after the upload itself succeeds.