{"slug": "how-we-built-stylesense-ai-virtual-try-on-powered-by-amazon-aurora-vercel", "title": "How We Built StyleSense: AI Virtual Try-On Powered by Amazon Aurora & Vercel", "summary": "A developer built StyleSense, an AI-powered virtual try-on tool, in 72 hours using Amazon Aurora PostgreSQL and Vercel. The system allows users to upload a selfie and see themselves wearing clothes from any product URL, addressing the $816 billion annual cost of online clothing returns. The architecture uses Aurora Serverless v2 with IAM authentication for passwordless database access and Vercel edge middleware for seamless auth.", "body_md": "Online clothing returns cost the industry over $816 billion a year. The root cause is simple: shoppers can't see how clothes look on *their* body before buying. We built **StyleSense** to fix that — an AI-powered virtual wardrobe where you upload a selfie, add clothes from any product URL, and instantly see yourself wearing them.\n\nHere's how we built it, and why Amazon Aurora PostgreSQL and Vercel were the right choices for a 72-hour hackathon build.\n\nWe needed a database that could handle:\n\nAurora Serverless v2 solved all three. It scales to zero between test runs, scales up instantly under load, and supports **IAM authentication** — meaning our FastAPI backend never stores a database password.\n\nInstead of a static `DATABASE_URL`\n\nwith a password, we use boto3 to mint a short-lived token at connection time:\n\n``` python\nimport boto3\n\ndef get_iam_token():\n    client = boto3.client(\"rds\", region_name=\"ap-south-1\")\n    return client.generate_db_auth_token(\n        DBHostname=\"stylesense.cluster-c9cswq8kqykn.ap-south-1.rds.amazonaws.com\",\n        Port=5432,\n        DBUsername=\"stylesense_app\",\n        Region=\"ap-south-1\",\n    )\n```\n\nWe wire this into SQLAlchemy's connection pool via a custom `creator`\n\nfunction that refreshes the token before each new connection — tokens expire in 15 minutes, so this is essential:\n\n``` python\nfrom sqlalchemy import create_engine\n\nengine = create_engine(\n    \"postgresql+psycopg2://\",\n    creator=lambda: psycopg2.connect(\n        host=AURORA_HOST,\n        port=5432,\n        dbname=\"stylesense\",\n        user=\"stylesense_app\",\n        password=get_iam_token(),\n        sslmode=\"require\",\n    )\n)\n```\n\nNo password in `.env`\n\n. No password in CI. No password in the repo. Just an IAM role.\n\nWe kept it lean — 4 core tables in Aurora:\n\n| Table | What it stores |\n|---|---|\n`users` |\nSelfie URLs, stylized avatar URLs, body analysis |\n`wardrobe_items` |\nClothing images, categories, colors, source URLs |\n`try_on_results` |\nGenerated try-on images, event scenes, video URLs |\n`outfits` |\nSaved outfit combinations |\n\nAuth and social (friendships, chat threads) stay in Supabase, which already has Row-Level Security and Realtime built in. Aurora handles the data that benefits from SQL joins and full ACID transactions — like \"show me all try-ons for items in category X that this user saved as outfits.\"\n\nOur Next.js frontend deploys to Vercel with three environment variables and zero configuration files. The things that made the biggest difference:\n\n**Edge middleware for auth**: Supabase session refresh runs at the edge on every request, so protected pages never flash unauthenticated content. This is one `middleware.ts`\n\nfile:\n\n``` js\n// middleware.ts\nimport { createServerClient } from \"@supabase/ssr\";\nimport { NextResponse } from \"next/server\";\n\nexport async function middleware(request: NextRequest) {\n  // Refreshes the Supabase session cookie on every request\n  // Redirects to /login if the user is not authenticated\n}\n```\n\n**Mumbai region**: We deployed both the Vercel frontend (`bom1`\n\n) and Aurora (`ap-south-1`\n\n) in Mumbai, keeping API latency under 20ms for the database round-trip.\n\n**The one gotcha**: Runway ML requires all image URLs to be public HTTPS. Localhost URLs fail silently. Every selfie and wardrobe image gets re-hosted to Supabase Storage before being passed to any Runway API call — Vercel's environment variables made switching between dev and prod URLs painless.\n\nThe \"wow moment\" flow that we demoed:\n\nThe entire pipeline is async. FastAPI fires each Runway task and returns a task ID; the frontend polls via Zustand store state that survives page navigation.\n\n**Aurora IAM token refresh in connection pools**: SQLAlchemy's connection pool reuses connections, so a token minted at startup expires mid-session. The fix: use `NullPool`\n\nor override the `creator`\n\nso a fresh token is minted for every logical connection. We went with the `creator`\n\napproach and a short pool recycle time.\n\n**Runway image URL requirement**: Every image URL sent to Runway must be a public HTTPS URL. During development this means all local uploads get re-hosted to Supabase Storage before the Runway call — an extra round-trip but essential.\n\n**Credit budget discipline**: Runway gen4.5 video costs 60-100 credits per 5 seconds. With a 50,000-credit budget, we used gen4_image_turbo (2 credits) for all dev testing and reserved the full quality models for demo recordings.\n\nThe full source is on GitHub. The live demo runs on Vercel at [[https://style-sense-steel.vercel.app/](https://style-sense-steel.vercel.app/)].\n\nBuilt in 72 hours for the **H0: Hack the Zero Stack with Vercel v0 and AWS Databases** hackathon.\n\n*#H0Hackathon*", "url": "https://wpnews.pro/news/how-we-built-stylesense-ai-virtual-try-on-powered-by-amazon-aurora-vercel", "canonical_source": "https://dev.to/ihddirmas/how-we-built-stylesense-ai-virtual-try-on-powered-by-amazon-aurora-vercel-dgf", "published_at": "2026-06-29 23:49:03+00:00", "updated_at": "2026-06-30 00:19:24.328663+00:00", "lang": "en", "topics": ["artificial-intelligence", "generative-ai", "developer-tools", "ai-products", "ai-infrastructure"], "entities": ["StyleSense", "Amazon Aurora", "Vercel", "Supabase", "Runway ML", "FastAPI", "Next.js", "SQLAlchemy"], "alternates": {"html": "https://wpnews.pro/news/how-we-built-stylesense-ai-virtual-try-on-powered-by-amazon-aurora-vercel", "markdown": "https://wpnews.pro/news/how-we-built-stylesense-ai-virtual-try-on-powered-by-amazon-aurora-vercel.md", "text": "https://wpnews.pro/news/how-we-built-stylesense-ai-virtual-try-on-powered-by-amazon-aurora-vercel.txt", "jsonld": "https://wpnews.pro/news/how-we-built-stylesense-ai-virtual-try-on-powered-by-amazon-aurora-vercel.jsonld"}}