Skip to content

Case study · AI decision support

Verdict

Verdict helps someone decide whether a garment is right for them and for an occasion before they buy it. A vision model rates the garment on six dimensions; the application checks those ratings against a strict schema and turns them into a verdict with fixed rules.

Individual project

Fig. 01Where the model stops and the code decides

Model outputUntrusted

  • Occasion fit
  • Formality
  • Style preference match
  • Color harmony
  • Seasonality
  • Style consistency

Each: a rating, a reason, and a confidence

Zod strict schema

Application logicFixed rules

  1. Weight five ratings
  2. One score
  3. Three thresholds
  1. Highly Recommended
  2. Recommended
  3. Consider Alternatives
  4. Not Recommended
Role
Sole developer, working with AI coding assistants
Context
Built during OpenAI Build Week
Status
Hackathon build with a public demo
Stack
  • Next.js
  • TypeScript
  • OpenAI Responses API
  • Zod
  • Tailwind CSS
  • Jest

01Problem and goal

A purchase question has more than one part

Shopping online means guessing how a garment will look on you, whether it suits the occasion, and whether it matches how you dress.

A garment can suit the occasion and still clash with someone's coloring, or match their style and be wrong for the season. A single opinion, or a single score, hides which of those failed and why.

Verdict's goal is to split the decision into named dimensions, give a reason and a confidence for each, and derive the overall verdict from them in a way a person can follow and question.

02System architecture

From two photos to a verdict

One request path. The model sits in the middle with code on both sides of it, and the API key and the model call stay on the server.

Fig. 02One analysis request, end to end
  • BrowserNext.js pages
  • API routePOST /api/analyze
  • OpenAIResponses API
  1. Choose the inputsPerson

    Three steps: your photo, the garment, and the occasion.

  2. Attach saved profilesData

    Style preferences and Style DNA are read from localStorage and sent with the form when present.

  3. Check the inputsCode

    JPEG, PNG, or WebP, at most 10 MB, and at least 512 × 512 px, read from the file's own bytes. An invalid Style DNA is dropped rather than failing the request.

  4. Build the model requestApp

    A server-only module adds the system prompt, the context, and both images. The API key never reaches the browser.

  5. Rate six dimensionsModel

    A rating, a reason, and a confidence for each, or an answer that the photos can't be analyzed.

  6. Model output is untrusted until it passes this check

    Validate with ZodCode

    A strict schema. Wrong values, an empty reason, or an extra field such as a model-made verdict end the request with an error. Nothing is repaired.

  7. Calculate the verdictCode

    Fixed weights turn the ratings into a score, and fixed thresholds map the score to one of four verdicts.

  8. Check the extrasCode

    Shopping alternatives are validated separately and offered only with Style DNA. Invalid ones are dropped; the verdict is unaffected.

  9. Show the reportResult

    The verdict, a reason per dimension, things to consider, and what the analysis did not consider.

Fig. 03Style DNA, created once from a separate photo
  1. One photoData

    Chosen on the profile page

  2. Profile modelModel

    Describes coloring, proportions, and style signals

  3. Strict schemaCode

    Rejects any field outside it, such as an attractiveness score or an estimated age

  4. This browserData

    Saved to localStorage as schema version 1.0

03Engineering decisions

Four decisions that shape the system

Each card separates what the code does from why. A reason that isn't written down in the repository is marked as inferred from the code.

  1. D1

    Use a vision model for the judgment calls

    Implemented

    Both photos go to the OpenAI Responses API at high image detail, with the occasion and any saved profiles as text. The model is chosen by an environment variable, and the request times out after 20 seconds.

    Why · Inferred from the code

    Occasion fit, color harmony, and formality depend on how the garment and the person look together, which a form can't capture.

    Trade-off

    Each analysis depends on an external service. It adds cost and waiting time, and the same photos can get different ratings on different runs.

  2. D2

    Validate every model response against a schema

    Implemented

    The model is asked for JSON, which is parsed and checked by a strict Zod schema: either a complete analysis with all six dimensions, or an explicit “unable to analyze”. Ratings and confidence levels must be exact values, and every reason must be non-empty. A failure returns an error the user can retry.

    Why · Documented in the repository

    The README sets the rule that model output is never rendered without being checked first.

    Trade-off

    A strict schema also rejects responses that are almost right, so some analyses fail outright instead of showing a partial result.

  3. D3

    Keep the verdict out of the model's hands

    Implemented

    The prompt tells the model it does not decide the verdict, and the strict schema rejects a response that includes one. computeVerdict weights five ratings (occasion fit 30%, formality 25%, style preference 20%, color 15%, seasonality 10%), and fixed thresholds map the score to one of four verdicts. Style consistency is shown but not scored.

    Why · Documented in the repository

    The README states that the final verdict comes from deterministic rules rather than the model, so that it stays transparent and consistent.

    Trade-off

    The same ratings always give the same verdict, but the ratings still come from the model. The weights and thresholds are product choices, not calibrated against real outcomes.

  4. D4

    Keep Style DNA in the browser

    Implemented

    Two profiles live in localStorage: manual style preferences, and the generated Style DNA (schema version 1.0). Style DNA is validated with Zod whenever it is read, and a corrupt or outdated copy is deleted. The server validates it again on every analysis and ignores an invalid one instead of failing.

    Why · Documented in the repository

    The README lists local, user-controlled storage of Style DNA as a privacy goal.

    Trade-off

    The profile doesn't follow the user to another browser or device, and clearing site data deletes it.

04User journey

Input, analysis, validation, verdict

What a person sees at each step, and what the system does behind it. A walkthrough of the interface, not a live run.

Fig. 04What a person sees, and what runs behind it
  1. 01InputPerson

    On screen
    Three short steps: a current photo, the garment, and an occasion picked from grouped lists such as Work and Social.
    Behind it
    Saved preferences and Style DNA are attached automatically. The server rejects unsupported, oversized, or small images before any model call.
    app/dashboard/analysis/page.tsx (source on GitHub, opens in a new tab)
  2. 02AnalysisModel

    On screen
    A loading state while the request runs.
    Behind it
    The vision model rates six dimensions, each with a reason and a confidence, or reports that the photos can't be analyzed.
    lib/services/openai/openAIAnalysisService.ts (source on GitHub, opens in a new tab)
  3. 03ValidationCode

    On screen
    If the response fails, an error with a retry button. Never a partial report.
    Behind it
    Zod checks the response's shape and allowed values, and that nothing extra was added.
    lib/services/openai/openAIAnalysisSchema.ts (source on GitHub, opens in a new tab)
  4. 04VerdictResult

    On screen
    The verdict and its score, a reason and confidence per dimension, things to consider, and what was not considered.
    Behind it
    Code calculates the verdict. Shopping alternatives appear only when Style DNA is saved.
    components/fashion/DecisionReport.tsx (source on GitHub, opens in a new tab)

Walkthrough of the interface · not a live model run

05My engineering approach

The model observes; the code decides

The model does the part that needs vision. Everything that has to be consistent, checkable, or private is application code.

  1. Give the model a narrow job

    The prompt asks only for a rating, a reason, and a confidence per dimension, and states that the application calculates the verdict.

  2. Treat its output as untrusted input

    The response is parsed and validated before any code uses it. A response that fails is an error, not something to repair or guess around.

  3. Fail closed on the core, degrade on the extras

    The verdict needs a valid analysis; optional parts don't. An invalid Style DNA is ignored, and invalid shopping suggestions are dropped without changing the verdict.

  4. Keep secrets and decisions on the server

    The OpenAI call lives in a server-only module. The browser sends the form to the API route and receives the finished result.

  5. Test the deterministic parts

    The repository's Jest suites cover image validation, the Style DNA schema and storage, the shopping-suggestion schema, retail links, and that suggestions never change the verdict.

Fig. 05Try the verdict rule

Choose a rating for each dimension to see the score and verdict the app would give. This runs the same weights, thresholds, and rounding as the app’s code; the ratings are yours, not a model’s. Samples A and B are the fixed ratings the app returns in its mock mode.

Occasion fit30% weight
Formality25% weight
Style preference match20% weight
Color harmony15% weight
Seasonality10% weight
Style consistencyShown, not scored

Points: Excellent 5, Good 4, Fair 3, Poor 2. “Unable to evaluate” is left out, and the remaining weights are rescaled.

Weighted score

Score 4.0. Verdict: Recommended.

  1. 4.5 and aboveHighly Recommended
  2. 3.5 to 4.4Recommended
  3. 2.5 to 3.4Consider Alternatives
  4. Below 2.5Not Recommended

Working

(0.30 × 4 + 0.25 × 4 + 0.20 × 4 + 0.15 × 4 + 0.10 × 4) ÷ 1.00 = 4.00, rounded to 4.0

06Limitations and next steps

What it can't promise yet

Known gaps in the current code, then possible next steps. Nothing in the second list is built.

Current codeKnown limitations

  • The ratings can vary

    Each analysis is a single model call, and the same photos can get different ratings on different runs. The fixed rules make the verdict traceable to its ratings, not stable across runs.

  • No published evaluation

    The repository's benchmark notes report results, but the test images and runs behind them aren't published, so this page cites no accuracy figure.

  • Weights are product choices

    The weights and thresholds were set by hand and haven't been calibrated against what people actually bought or kept.

  • Photos leave the device

    Each analysis sends both photos to the server and on to OpenAI. The app doesn't save them and sets store: false on the request, but users have to trust both services.

  • Prompt rules aren't guarantees

    The prompt tells the model not to judge attractiveness, infer health, or comment on the person's body beyond how the garment works with it. The Style DNA schema enforces part of this by rejecting fields such as an estimated age, but free-text reasons are only checked for being present.

Not builtPossible next steps

  • A reproducible evaluation setProposed here

    Consented test photos with expected ratings, run repeatedly to measure how often each dimension's rating agrees with the expectation and how much it varies.

  • Schema-constrained outputProposed here

    Use the Responses API's JSON-schema output format, so the model is held to the schema while it generates, and keep Zod as the final check.

  • Calibrated weightsProposed here

    Adjust the weights and thresholds using feedback on past verdicts.

  • Accounts and profile syncFrom the project README

    User accounts and cloud sync for Style DNA, from the README's future enhancements.

  • Comparison and historyFrom the project README

    Comparing several garments at once and keeping an outfit history. The history page is a placeholder today.

07Technical summary

At a glance

Project
Individual project, built during OpenAI Build Week
Application
Next.js App Router, React, TypeScript, Tailwind CSS
Model API
OpenAI Responses API, called with fetch from a server-only module: two images in, JSON out. The model is set by OPENAI_MODEL; the README names GPT-4.1
Validation
Strict Zod schemas for the analysis, Style DNA, and shopping suggestions
Decision logic
computeVerdict: a weighted average of five ratings and three thresholds
Storage
Browser localStorage. The analysis and profile routes use no database
Testing
Jest with ts-jest
Hosting
Vercel
Built with
AI coding assistants. The README credits Codex, and the earliest commits came from the Emergent platform's agent

Links

Checked against commit 012504c (opens in a new tab) from , on . Links to source files point at that commit.