← Selected work

UGC Content Studio — AI Media Generation Pipeline

An authenticated image studio that combines product and person references through OpenAI image edits, persists project state in PostgreSQL, and retains output when Cloudinary storage is unavailable.

The problem

Combine product and person reference uploads into a promotional image while tracking account credits, project processing state, and saved results.

My contribution

Engineered authenticated image-generation endpoints, two-reference OpenAI requests, storage fallback, and failure-path credit restoration around account-scoped project records.

UGC Content Studio generation workspace showing reference inputs, saved output, and generation status

Product features

  • Clerk-authenticated image generation from two uploaded references
  • OpenAI image edits and Cloudinary storage with database data-URL fallback
  • Prisma and PostgreSQL user, credit, and project records
  • Generation state and credit restoration after caught provider failures; unavailable video requests rejected before charging
Explore workspace

Engineering work

  • Reference-conditioned generation: Sent product and person uploads together to OpenAI image edits, persisting processing state, generated images, and failure diagnostics in PostgreSQL.
  • Credit accounting & failure recovery: Applied Prisma credit mutations and restoration paths for caught generation failures, retaining project errors for recovery in the interface.
  • Identity-scoped media persistence: Bound project access to Clerk identity, attempted Cloudinary uploads, and retained image data URLs in existing database fields when storage failed.

Outcome

Coordinated authenticated reference uploads, generated-media delivery, and recoverable project state in one pipeline, with credit restoration paths for caught generation failures.

Architecture & tech stack

Design decision

Persist project status and media URLs around the provider workflow, with compensating credit increments in caught failure paths.

Persisted status and error fields let the interface recover the latest job state after a reload. Credit compensation handles caught provider errors, while interrupted or concurrent requests need separate safeguards.

Failure handling & recovery

Caught image-generation errors restore credits and persist project error state.

Data flow Product/model references + prompt → generation request

Implementation Product and model references, prompt fields, and generation UI state

Authenticated generation requests with media storage and relational project state.
Read the complete data flow
React asset upload
Product and model references, prompt fields, and generation UI state
Product/model references + prompt → generation request
Express + Clerk
Authenticated identity, multipart inputs, and account-scoped project lookup
Clerk identity + project identifier → account-scoped project
OpenAI image edits
Both reference images condition one low-quality image edit; new video generation is unavailable
Two reference images + prompt → generated PNG
Cloudinary / fallback
Cloudinary delivery URLs, with image data URLs retained if uploads fail
Media upload → delivery URL or database data URL
Prisma / PostgreSQL
User/project relations, integer credits, and persisted error state
Generation result → credits, media URL, processing/error state