An app that allows users to try on an ugly winter jumper, virtually! Built with Workers and Replicate
Virtual Try On — AI-Powered Clothing Preview
Upload a photo and see yourself wearing a virtual outfit, powered by Replicate models running through Cloudflare AI Gateway.
About Virtual Try On
Virtual Try On lets you upload a photo and virtually try on clothing. The app sends your image along with a garment photo to an AI model that composites the outfit onto your body. Two model endpoints are available: Google’s nano-banana-pro and OpenAI’s gpt-image-1.5, each producing different results you can compare.
The backend runs on Cloudflare Workers with Hono for routing. API calls to Replicate go through Cloudflare AI Gateway, which adds logging, rate limiting, and caching to model requests. Generated images are stored in R2, and session state is managed through KV.
Frameworks & Technologies Used
- Frontend: React with Vite (photo upload and result display)
- Backend: Cloudflare Workers with Hono (API routing)
- AI Models: Replicate via Cloudflare AI Gateway (image generation)
- Framework: TanStack Start (full-stack React)
Why Cloudflare for This Project?
- AI Gateway for Model Requests: All Replicate API calls route through Cloudflare AI Gateway. This gives you request logging, caching for repeated prompts, and rate limiting without adding middleware to the Worker.
- R2 for Image Storage: Source photos and generated try-on results are stored in R2. Users can revisit results without re-running the model.
- KV for Session State: Lightweight session data lives in KV, keeping the Worker stateless while preserving user context across requests.