What it is
FitSnap is a web app for choosing clothes that fit. A user enters age, height and weight and gets a size estimate. The user can also open another person's outfit post (a "fit"), take a photo, and see the outfit overlaid on that photo. A four-person team built it at HackX 3.0.
The problem
The repository describes FitSnap as a clothing size predictor for t-shirts, shirts and pants. The app adds a second question: how a specific outfit looks on the user. It answers the first with a size estimate from body data and the second with an overlay on the user's photo. Fits come from other users, who browse them by swiping.
How it works
The project has two services in one repository.
| Path | Service | Role |
|---|---|---|
frontend/ | Next.js 15 app (App Router) | Sign-in, swiping, leaderboard, camera capture, results |
backend/ | FastAPI app (Python) | Size estimation and the try-on overlay |
Frontend
- Better Auth handles email and password and Google sign-in.
- Prisma stores users, fits and swipes in PostgreSQL. A
Fitholds an image URL, tags and a description. ASwiperecords a Like or Dislike. Swiping right records a Like, and any other direction records a Dislike. - UploadThing hosts images. Uploads require a signed-in user and allow one image up to 32 MB.
- The leaderboard page ranks fits by swipe count and groups them by the tags Oversized, Formal, Casual and Gothic.
- A Serwist service worker makes the app installable as a PWA (progressive web app).
Backend endpoints
| Endpoint | Input | Output |
|---|---|---|
POST /predict-size-metrics/ | Age, height, weight | One or two candidate sizes |
POST /predict-size/ | URL of the user's photo, URL of the fit image | Shirt and pants size, fit descriptions, URL of the overlay image |
GET /public/images/{image} | File name | The generated overlay PNG |
Size from body data
backend/models/metrics-predictor.ipynb trains a scikit-learn linear regression on a CSV of weight, age, height and size. The notebook fills missing age and height with the median and maps sizes XXS through XXXL to the numbers 1 to 7. The fitted model is saved as size_predictor_model.joblib and loaded at startup.
The endpoint rounds the numeric prediction back to a size. If the value is close to the next size, the endpoint returns the larger size. If it falls in the middle, it returns both neighboring sizes.
Try-on pipeline
- The frontend sends the user's photo to UploadThing and passes both image URLs to the backend.
- MediaPipe selfie segmentation finds the body outline. The code measures its width at about 25% and 45% of body height, and scales those widths and maps them to shirt and pants size cutoffs.
- MediaPipe Pose Landmarker returns 3D shoulder positions. The code uses the ratio of 2D to 3D shoulder distance to correct for a turned body.
- A U2NET cloth-segmentation network, loaded from a checkpoint, cuts the garment out of the fit image.
- The backend aligns the garment to the user's shoulders. It rotates, scales and shifts the cutout so the shoulder lines match, then blends it onto the photo with OpenCV.
- The backend saves the result under a random UUID and returns its URL.
What I built
I added U²-Net garment segmentation and pose processing to the shared Python backend. I then built the database-backed leaderboard. Jay built authentication, uploads, the detection and results pages, profiles and the PWA setup. Sundaram built the swipe and outfit interface and its actions, plus the landing page and dashboard. A teammate (kryyo1441) built the size model and made large changes to the shared pose and overlay backend.
Design decisions
Two estimators with different inputs. The regression needs only typed numbers, so it always runs. The image pipeline runs only when the user opens a fit and takes a photo. A user without a camera still gets a size.
Shoulder landmarks for alignment. The overlay uses two points, the shoulders, to compute rotation, scale and translation. This is a single affine transform, which is cheap and simple. The cost is that it ignores arm position, body shape and fabric drape, so it suits front-facing photos.
A separate Python service for vision. MediaPipe, OpenCV, PyTorch and scikit-learn are Python libraries, which likely explains why the backend runs as its own FastAPI service. The frontend calls it through the NEXT_PUBLIC_BACKEND_URL setting.
Rule-based sizing from silhouette width. Size thresholds are fixed pixel-scale cutoffs rather than a trained model. This needs no training data, but the result depends on camera distance and framing.
Known limits
These come from reading the code.
- The size and fit rules use hard-coded thresholds and have no stated accuracy measurement in the repository.
- The fit-description helpers create a second U2NET with
U2NET(in_ch=3, out_ch=1)and do not load weights for it. Their output is therefore not trained. - The backend writes intermediate files to fixed names in
output/, so two simultaneous requests would overwrite each other. - The leaderboard counts every swipe, including Dislike swipes.
Run it locally
Requirements: Node.js, Python 3, a PostgreSQL database, a Google OAuth client and an UploadThing account.
-
Start the backend from the
backend/directory.cd backend pip install -r requirements.txt uvicorn app.main:app --reloadThe Pose Landmarker model file must exist at
backend/models/pose_landmarker_heavy.task; the repository does not include it. The cloth-segmentation checkpoint downloads tobackend/models/cloth_segm.pthon first use. -
In
frontend/, create a.envfile withDATABASE_URL,NEXT_PUBLIC_BACKEND_URL,BETTER_AUTH_URL,GOOGLE_CLIENT_ID,GOOGLE_CLIENT_SECRETand your UploadThing token. -
Install the frontend, create the tables and start it:
cd frontend npm install npx prisma db push npm run dev -
Open
http://localhost:3000.
Reference
| Area | Choice | Used for |
|---|---|---|
| Frontend | Next.js 15, React 19, TypeScript | Pages and server actions |
| UI | Tailwind CSS, shadcn/ui, Framer Motion | Layout, swipe animation, result view |
| Auth | Better Auth | Email and Google sign-in |
| Database | PostgreSQL with Prisma 6 | Users, fits, swipes |
| Uploads | UploadThing | Photo and outfit hosting |
| API | FastAPI, Uvicorn | Size and try-on endpoints |
| Vision | MediaPipe, OpenCV, PyTorch (U2NET) | Segmentation, pose landmarks, overlay |
| Sizing model | scikit-learn linear regression, joblib | Size from age, height and weight |
| PWA | Serwist | Installable app |
Outcome
FitSnap won second place at HackX 3.0, a 24-hour hackathon at NMIMS Navi Mumbai on 22 February 2025. The prize was 15,000 INR and a mechanical keyboard.
The repository was created on 22 February 2025. Most commits are from 22 and 23 February 2025, and the latest commit, from 2 June 2025, adds a Prisma schema file.