AI fashion try-on · Founder

Tryl: AI Fashion Try-On

Try on clothes from any shopping page, with slow AI generation queued in the background.

Full Stack Engineer (solo) · Solo · Mar – Jun 2026

5–30 s
Try-on generation per image, moved off the request path
4
Apps in one monorepo (web, extension, API, worker)
Live
On the Chrome Web Store since Apr 2026
Tryl try-on flow
Tryl try-on flow
Tryl product detection
Tryl product detection
Tryl generated try-on result
Tryl generated try-on result

Context

AI try-on takes 5–30 seconds per image, which is far too slow for a synchronous API response.

The problem

Generation is too slow to hold a request open, and product images live behind inconsistent DOM structures on every storefront. The product needed an async job pipeline plus product detection that does not depend on brittle CSS selectors.

What I owned

I built the whole monorepo alone: the Chrome extension, the React web app, the FastAPI backend and the Redis worker.

Frontend

ReactTypeScriptChrome Extension (MV3)

Backend

FastAPIPython

Data

PostgreSQLRedis

Tooling

pnpm workspaces

Architecture

The extension finds the product, FastAPI queues a job in Redis, and a worker generates and archives the try-on image.

Monorepo: Chrome Ext + Web → FastAPI → Redis → Worker → S3 + PostgreSQL

swipe
UserChrome Extension(MV3)React Web AppFastAPI BackendJWT AuthPostgreSQL(profiles)Redis Job QueueTry-On WorkerS3 Image Archive
  1. Critical path
  2. Chrome Extension (MV3)
  3. →FastAPI Backend
  4. →Redis Job Queue
  5. →Try-On Worker
  6. →S3 Image Archive

Highlighted: one try-on, from product detection to the archived result.

Key decisions

Three choices keep the pipeline simple: a blocking queue, a single status column and an `og:image`-first detector.

Decision 1

Redis BRPOP instead of a polling worker

Problem
Workers need to pick up jobs immediately without burning CPU while idle.
Options
  • A sleep-poll loop
  • A blocking brpop on a Redis list
Decision
Workers block on brpop, and the API creates the job and returns its status immediately.
Result
No CPU burn between jobs, FIFO ordering, and scaling out is just more worker containers.
Trade-off
A plain Redis list has no built-in acknowledgement, so a crashed worker needs a watchdog to re-queue its job.

Decision 2

One status column instead of event tables

Problem
Clients poll for job progress, and the lifecycle has to be easy to query.
Options
  • Event sourcing / separate tables
  • A single status column (queued / processing / completed / failed) with updated_at
Decision
Job lifecycle lives in one row, with error_message filled when a job fails.
Result
It is simpler to query, index and reason about for an MVP.
Trade-off
There is no history of transitions, only the current state.

Decision 3

`og:image` first, heuristics second

Problem
Site-specific scrapers break every time a storefront is redesigned.
Options
  • Per-site structured scrapers
  • Heuristic DOM selectors with an og:image fallback
Decision
Prefer og:image, which site owners set for sharing, then fall back to heuristic selectors, then manual URL input.
Result
A stable, high-quality product image on Zara, the first supported storefront, without depending on its DOM structure.
Trade-off
og:image describes the page rather than the selected variant, so colour or size variants can be missed.

Reliability

A failed job always ends in a readable `failed` state, never a silent hang.

  • CI runs web lint and build, the extension build and 19 API tests against Postgres 16 and Redis 7 on every push; storefront flows on Zara are checked by hand.
  • Prometheus + Grafana track API p50 / p95 / p99, job duration, retries, failure ratio and queue backlog (tryon_job_duration_seconds, redis_key_size).
  • The worker wraps each job in try/except, and any unhandled error sets status = "failed" with the message stored in error_message.
  • FastAPI dependencies validate auth and profile ownership before a job is created, returning 403 on a mismatch.
  • The extension's service worker catches fetch failures and shows readable messages in the popup instead of raw status codes.
Edge cases covered (5)
  • Retryable failure: job re-queued with backoff up to the retry limit; CONFIG: errors are not retried
  • Extension on SPA (React/Next.js storefront): MutationObserver detects route changes and re-runs product detection on navigation
  • User submits duplicate job: idempotency check on (profile_id, product_image_url) returns the existing job_id
  • No og:image and no matching selector: extension shows "Could not detect product image" with a manual URL input fallback
  • Auth token expired while polling: 401 triggers a silent refresh, and polling continues after the new token is issued

Limits and scale

The MVP's queue and testing work at demo scale and would need hardening for real traffic.

Todaybrpop removes a job before it is processed, so a worker crash mid-job loses it; only failures the worker catches are re-queued through the DB retry count.

At scale—

TodayClients poll for job status.

At scale—

TodayOnly the API has automated tests; the worker, extension and storefront flows are tested by hand, and only Zara has an adapter.

At scale—

TodayExtension job state lives in an in-memory Map in the MV3 service worker, which Chrome can suspend between events.

At scale—

Engineering deep divePipelines, code flow and implementation notes

0. Monorepo Structure (pnpm workspaces)

markdown
tryl/
  ├─ apps/
  │    ├─ web/          React + TypeScript — auth, fitting profiles, archive
  │    ├─ extension/    Chrome MV3 — product detection on shopping pages
  │    ├─ api/          FastAPI — REST API for profiles, jobs, archive
  │    └─ worker/       Python — async try-on job processor
  ├─ packages/
  │    ├─ shared-types/ TypeScript types shared by web + extension
  │    └─ config/       Shared ESLint + TS config
  └─ pnpm-workspace.yaml

1. Try-On Job Pipeline — create → queue → process → archive

markdown
POST /api/tryon/jobs  { profile_id, product_image_url, product_metadata }
  │
  ├─ Validate profile exists + user owns it
  ├─ Resolve product: download image → store to S3-compatible store
  ├─ INSERT job { status: "queued", profile_id, product_image_key }
  │
  └─ redis.lpush("tryon:queue", job_id)   ← enqueue
       │
       ▼  [Worker process — separate container]
  redis.brpop("tryon:queue")              ← blocking pop
       │
       ├─ UPDATE job { status: "processing" }
       ├─ Fetch fitting profile image + product image
       ├─ Call try-on AI model API (async httpx)
       │    └─ Poll / stream until result image ready
       ├─ Store result image
       ├─ UPDATE job { status: "completed", result_image_key }
       │
       └─ On any error:
            UPDATE job { status: "failed", error_message }

GET /api/tryon/jobs/{job_id}   → { status, result_image_url? }
GET /api/tryon/archive         → paginated completed jobs

2. Chrome Extension — product detection across storefronts

markdown
Content script injected on shopping page load
  │
  ├─ DOM scan: heuristic selectors for product images
  │    ├─ meta[property="og:image"]           ← most reliable
  │    ├─ [data-testid*="product"] img         ← framework apps (Next.js)
  │    ├─ .pdp-image, .product-image img       ← legacy CSS patterns
  │    └─ largest visible <img> (fallback)
  │
  ├─ Inject "Try with Tryl" button adjacent to detected image
  │
  └─ On button click:
       ├─ Send product_image_url + page_url to background service worker
       ├─ background → POST /api/tryon/jobs (with auth cookie / token)
       ├─ Receive job_id → open popup with job status polling
       │    └─ GET /api/tryon/jobs/{job_id} every 3 s
       └─ On "completed" → display result image in popup overlay

More design notes

pnpm workspaces over separate repos: shared TypeScript types (shared-types) flow straight to both web and extension with no publish step. The cost is a slightly more complex CI matrix, because build order matters.
Chrome MV3: MV3 service workers replace the persistent background pages Chrome is retiring.

← All projects