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.

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
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.