Capability - in-browser ad editor

From a one-line idea to a published creative

A layered editor in the browser, AI image generation behind a provider gateway, and a server-side renderer that turns the layer tree into a flat image ready to publish.

Generate

prompt

Marketer idea

A raw line like "a family at a cafe table, candid".

enhance

Claude rewrite

Optional: structures the prompt, appends an Avoid: line.

guard

Cost reservation

Reserve-then-settle spend so concurrent calls can't blow the cap.

model

Provider gateway

Imagen / gpt-image / Flux behind one uniform adapter contract.

The gateway strips operator-typed "saying: ..." clauses and appends an anti-text / anti-watermark Avoid: line, because diffusion models render legible text badly and baking it in fights the editor's own text layers.

Compose & publish

edit

Layered canvas

Text / image / shape layers, drag-resize, magic-resize across 8 export formats.

render

Headless Chromium

compose.mjs builds HTML from the layer tree and screenshots it. Child process per render, hard timeout.

store

Private GCS

Saved to a private bucket; external consumers get a time-limited signed URL.

ship

Publish to Meta

Single image or a 2-10 card carousel template.

Render isolation: a crashed or hung Chromium is SIGKILL-able by the parent without taking the API server down. The trade-off is cold-start latency per render; a singleton browser pool is the documented next optimisation.
Relay - anonymized engineering case study. Code in ../src/creative-studio.