Nano Banana 🍌 powered webapp to try out glasses. So, you can look sharp and your look is sharp
LookSharp uses Google Gemini 2.5 Flash Image to quickly and consistently composite frames onto a user’s photo, preserving facial detail and background for natural‑looking results. The speed and consistency of Gemini 2.5 Flash let users try multiple styles fast with reliable quality.
- Requirements: Node.js >= 18.18
- Setup
- Copy
.env.example
to.env.local
and setGEMINI_API_KEY
(required for Try‑On). - Optional: set
BLOB_READ_WRITE_TOKEN
to upload assets to Vercel Blob. Without it, assets can save underpublic/assets/glasses/
locally when allowed. - Database: local dev defaults to SQLite at
.data/dev.sqlite
. For Postgres/Supabase, setPOSTGRES_PRISMA_URL
(orDATABASE_URL
) and runnpm run prisma:push
once.
- Copy
- Install dependencies:
npm install
- Seed data (options below)
- Run the dev server:
npm run dev
and open http://localhost:3000
You have three seeding paths depending on your environment and source of truth.
-
Local dev (SQLite):
npm run db:seed
— inserts a single sample product and a reference asset into.data/dev.sqlite
andpublic/assets/...
.
-
Supabase (labels.csv only):
- Place images and a
labels.csv
file in./.seed_data/
.- Image name should match
key
(e.g.,key=hmt0258_0
→.seed_data/hmt0258_0.jpg|png
). - One-level subfolders are also scanned.
- Image name should match
- Apply the schema to Supabase:
- Bash:
POSTGRES_PRISMA_URL="postgres://..." npm run prisma:push
- PowerShell:
$env:POSTGRES_PRISMA_URL="postgres://..."; npm run prisma:push
- Tip: Prefer a non‑pooling (port 5432) URL for schema pushes when possible.
- Bash:
- Seed from labels only (no AI/inference):
- Bash:
POSTGRES_PRISMA_URL="$POSTGRES_PRISMA_URL" npm run db:seed:pg
- PowerShell:
$env:DATABASE_URL=$env:POSTGRES_PRISMA_URL; npm run db:seed:pg
- Bash:
- Image upload behavior:
- With
BLOB_READ_WRITE_TOKEN
set: images upload to Vercel Blob and the public URL is stored inmedia_assets.cdn_url
. - By default when targeting Postgres, uploads are required. To allow copying into
public/assets/...
instead, setREQUIRE_BLOB_FOR_IMAGES=0
.
- With
- Place images and a
-
Image‑driven seeding (labels preferred, AI fallback):
npm run db:seed:images
- Reads
./.seed_data/labels.csv
when present for authoritative metadata. - If a row is missing in labels, it can infer metadata via Gemini (requires
GEMINI_API_KEY
), then inserts to SQLite or Postgres depending on your env vars. - Image handling matches the rules above for Vercel Blob vs. local
public/
copies.
- Reads
CSV headers are flexible; these are recognized (case‑insensitive):
key, filename, sku, name, brand, style, shape, color, sex, frameWidthMm, lensHeightMm, priceCents, priceUsd, tags, altText
- Required for each row:
sku
,name
(brand defaults toLookSharp
if omitted) tags
can be separated by,
or;
shape
normalizes to one of: aviator, wayfarer, round, rectangle, square, oval, cat-eye, browline, geometriccolor
normalizes to: black, gold, silver, tortoise, clear, gunmetal, brown, blue, green, red, pink, gray, amber, champagne
- Inspect data:
npm run prisma:studio
(tablesglasses
,media_assets
,leads
) - Run app:
npm run dev
- Featured carousel via Vercel Edge Config is supported. If enabling, see
lib/edge-config.ts
.- Read config: set
EDGE_CONFIG
to the Edge Config connection string (Vercel provides it in the Edge Config UI). The homepage will try to read keyfeatured_glasses
. - Write config (optional): to auto‑populate Edge Config from your DB, set:
EDGE_CONFIG
— the Edge Config ID (e.g.,ecfg_...
).VERCEL_API_TOKEN
— a Vercel API token with access to the project/team.- After these are set, the homepage will backfill the
featured_glasses
key (logs show “Writing featured items to Edge Config…” when active).
- Read config: set