$ cat work/cardboard.md
A canvas editor and a signed render API that share one drawing engine.

Problem and constraints
Every blog post, docs page and launch deserves a good social image, but making one means opening a design tool, duplicating last week’s file, retyping a title and exporting a PNG, every time.
I wanted to design the card once and have each page fill in its own title from a URL, the way the rest of a site is generated. The image in the editor had to be exactly the image the API returns, and nobody should be able to put their own words on someone else’s design.
What I built
A canvas editor with text, shapes, images and gradients, snapping, undo and redo, and typing directly on the canvas. Any text or image layer can be marked as a field that changes per page.
A NestJS render API: GET /api/card/:id returns a 1200×630 PNG, signed with the template owner’s key, cached in memory and in Cloudflare R2. And cardboard-url, a small npm package that builds signed links from your own server.
Try it
Type a title and a name. This page signs a Cardboard URL on its own server and the real API renders the card.

Key decisions
Decision 01
One drawScene function for the browser and the server
Why: The editor draws with the Canvas 2D API and the API draws with @napi-rs/canvas, both through the same shared package, so what you design is pixel-for-pixel what gets served.
Trade-off: Fonts have to be bundled and loaded identically on both sides, and text layout is my own code rather than the browser’s.
Decision 02
HMAC-signed URLs instead of API keys in the query string
Why: Card URLs end up in public meta tags. A signature over template, version and fields means the link works for anyone but can’t be edited to say something else.
Trade-off: Links must be built server-side, which is why the cardboard-url package exists.
Decision 03
Cache by content hash in memory, then R2
Why: The same template, version and fields always hash to the same key, so repeat requests from social crawlers never re-render.
Trade-off: Editing a template bumps its version, so old URLs render the old design until pages are rebuilt.
What I'd do next
- Team workspaces
- A Figma import for existing card designs
Screens


Next project
The Hamper World
A luxury gift-hamper catalogue for a Lagos business, edited by the owners and built around enquiries.