# aryanmashalkar/skin_ai architecture

> Architecture diagram of the GitHub repository aryanmashalkar/skin_ai, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/aryanmashalkar/skin_ai
- Repository: https://github.com/aryanmashalkar/skin_ai

## Overview

MIROIR combines selfie-based skincare analysis with personal-colour styling and apparel try-on. The main journey runs from a skin scan to a concern report and tailored product/routine recommendations, then uses the same profile to rank garments and support virtual try-on and side-by-side colour proof. The README documents these capabilities; sampled source and the SOURCE INDEX support many internal links, but not every UI request path or unsampled implementation detail.

Main entry points: [`src/lib/store.ts`](https://github.com/aryanmashalkar/skin_ai/blob/main/src/lib/store.ts) (Persisted app state), [`src/app/api/skin/analyze/route.ts`](https://github.com/aryanmashalkar/skin_ai/blob/main/src/app/api/skin/analyze/route.ts) (Skin analysis API), [`src/app/fashion/page.tsx`](https://github.com/aryanmashalkar/skin_ai/blob/main/src/app/fashion/page.tsx) (Fashion collection), [`src/components/ScanModal.tsx`](https://github.com/aryanmashalkar/skin_ai/blob/main/src/components/ScanModal.tsx) (Selfie scan)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_skincare["Skincare journey"]
  node_scan["Selfie scan<br/>[ScanModal.tsx]"]
  node_skin_api["Skin analysis API<br/>[route.ts]"]
  node_youcam_skin["YouCam Skin API"]
  node_skin_domain["Skin profile model<br/>[skin.ts]"]
  node_report["Skin report<br/>[SkinReport.tsx]"]
  node_catalog["Skincare catalog<br/>[products.ts]"]
  node_matching["Concern matching<br/>[matching.ts]"]
  node_routine["Routine planner<br/>[RoutineSection.tsx]"]
  node_progress["Progress tracking"]
end

subgraph group_colour["Colour and styling"]
  node_appearance["Appearance sampling"]
  node_color_engine["Colour measurements<br/>[color.ts]"]
  node_season["Season classification<br/>[season.ts]"]
  node_styling["Season styling<br/>[styling.ts]"]
end

subgraph group_fashion["Fashion experience"]
  node_fashion_page["Fashion collection<br/>[page.tsx]"]
  node_garments["Garment catalog<br/>[products.ts]"]
  node_garment_card["Garment cards<br/>[GarmentCard.tsx]"]
  node_tryon["Virtual try-on<br/>[TryOnModal.tsx]"]
  node_photo["Photo preparation<br/>[photo.ts]"]
  node_proof["Colour proof"]
  node_recolor["Garment recolouring<br/>[recolor.ts]"]
  node_tryon_api["Try-on API<br/>[route.ts]"]
  node_youcam_vto["YouCam Apparel VTO"]
end

subgraph group_shared["Shared state and services"]
  node_app_state[("Persisted app state<br/>[store.ts]")]
  node_cart["Unified cart<br/>[cart.ts]"]
  node_cart_drawer["Cart drawer<br/>[CartDrawer.tsx]"]
  node_rate_limit["Request limiting<br/>[rate-limit.ts]"]
end

node_shopper(("Shopper"))

node_shopper -->|"provides selfie"| node_scan
node_scan -.->|"submits scan"| node_skin_api
node_scan -->|"samples appearance"| node_appearance
node_scan -->|"updates profile"| node_app_state
node_skin_api -->|"requests analysis"| node_youcam_skin
node_skin_api -->|"parses results"| node_skin_domain
node_skin_api -->|"checks limits"| node_rate_limit
node_skin_api -->|"derives season"| node_season
node_skin_api -.->|"returns profile"| node_shopper
node_appearance -->|"converts samples"| node_color_engine
node_color_engine -->|"classifies season"| node_season
node_season -->|"provides tone"| node_skin_domain
node_skin_domain -->|"stores profile"| node_app_state
node_app_state -->|"supplies profile"| node_report
node_report -->|"ranks products"| node_matching
node_matching -.->|"scores products"| node_catalog
node_report -->|"renders routine"| node_routine
node_report -->|"renders progress"| node_progress
node_shopper -->|"browses apparel"| node_fashion_page
node_fashion_page -->|"loads collection"| node_garments
node_fashion_page -->|"renders garments"| node_garment_card
node_fashion_page -->|"reads profile"| node_app_state
node_fashion_page -->|"derives recommendations"| node_styling
node_styling -->|"uses skin profile"| node_skin_domain
node_styling -->|"uses colour analysis"| node_color_engine
node_garment_card -->|"shows styling"| node_styling
node_tryon -->|"prepares photo"| node_photo
node_tryon -.->|"requests try-on"| node_tryon_api
node_tryon_api -->|"resolves garment"| node_garments
node_tryon_api -->|"renders garment"| node_youcam_vto
node_proof -->|"prepares photo"| node_photo
node_proof -->|"recolours garment"| node_recolor
node_proof -->|"requests both renders"| node_tryon_api
node_app_state -->|"manages cart lines"| node_cart
node_cart_drawer -->|"reads and updates"| node_app_state
node_cart_drawer -->|"changes quantities"| node_cart
node_app_state -->|"accepts products"| node_catalog
node_app_state -->|"accepts garments"| node_garments

click node_scan "https://github.com/aryanmashalkar/skin_ai/blob/main/src/components/ScanModal.tsx"
click node_skin_api "https://github.com/aryanmashalkar/skin_ai/blob/main/src/app/api/skin/analyze/route.ts"
click node_skin_domain "https://github.com/aryanmashalkar/skin_ai/blob/main/src/lib/skin.ts"
click node_report "https://github.com/aryanmashalkar/skin_ai/blob/main/src/components/SkinReport.tsx"
click node_catalog "https://github.com/aryanmashalkar/skin_ai/blob/main/src/lib/products.ts"
click node_matching "https://github.com/aryanmashalkar/skin_ai/blob/main/src/lib/matching.ts"
click node_routine "https://github.com/aryanmashalkar/skin_ai/blob/main/src/components/RoutineSection.tsx"
click node_progress "https://github.com/aryanmashalkar/skin_ai/blob/main/src/components/ProgressSection.tsx"
click node_appearance "https://github.com/aryanmashalkar/skin_ai/blob/main/src/lib/appearance-sample.ts"
click node_color_engine "https://github.com/aryanmashalkar/skin_ai/blob/main/src/lib/color.ts"
click node_season "https://github.com/aryanmashalkar/skin_ai/blob/main/src/lib/season.ts"
click node_styling "https://github.com/aryanmashalkar/skin_ai/blob/main/src/lib/fashion/styling.ts"
click node_fashion_page "https://github.com/aryanmashalkar/skin_ai/blob/main/src/app/fashion/page.tsx"
click node_garments "https://github.com/aryanmashalkar/skin_ai/blob/main/src/lib/fashion/products.ts"
click node_garment_card "https://github.com/aryanmashalkar/skin_ai/blob/main/src/components/fashion/GarmentCard.tsx"
click node_tryon "https://github.com/aryanmashalkar/skin_ai/blob/main/src/components/fashion/TryOnModal.tsx"
click node_photo "https://github.com/aryanmashalkar/skin_ai/blob/main/src/lib/fashion/photo.ts"
click node_proof "https://github.com/aryanmashalkar/skin_ai/blob/main/src/components/fashion/ColorProofModal.tsx"
click node_recolor "https://github.com/aryanmashalkar/skin_ai/blob/main/src/lib/fashion/recolor.ts"
click node_tryon_api "https://github.com/aryanmashalkar/skin_ai/blob/main/src/app/api/tryon/route.ts"
click node_app_state "https://github.com/aryanmashalkar/skin_ai/blob/main/src/lib/store.ts"
click node_cart "https://github.com/aryanmashalkar/skin_ai/blob/main/src/lib/cart.ts"
click node_cart_drawer "https://github.com/aryanmashalkar/skin_ai/blob/main/src/components/CartDrawer.tsx"
click node_rate_limit "https://github.com/aryanmashalkar/skin_ai/blob/main/src/lib/rate-limit.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_scan,node_skin_api,node_youcam_skin,node_skin_domain,node_report,node_catalog,node_matching,node_routine,node_progress toneBlue
class node_appearance,node_color_engine,node_season,node_styling toneAmber
class node_fashion_page,node_garments,node_garment_card,node_tryon,node_photo,node_proof,node_recolor,node_tryon_api,node_youcam_vto toneMint
class node_app_state,node_cart,node_cart_drawer,node_rate_limit toneRose
class node_shopper toneIndigo
```

## Components

### Skincare journey

- [Selfie scan](https://github.com/aryanmashalkar/skin_ai/blob/main/src/components/ScanModal.tsx): `src/components/ScanModal.tsx`
- [Skin analysis API](https://github.com/aryanmashalkar/skin_ai/blob/main/src/app/api/skin/analyze/route.ts): `src/app/api/skin/analyze/route.ts`
- **YouCam Skin API**
- [Skin profile model](https://github.com/aryanmashalkar/skin_ai/blob/main/src/lib/skin.ts): `src/lib/skin.ts`
- [Skin report](https://github.com/aryanmashalkar/skin_ai/blob/main/src/components/SkinReport.tsx): `src/components/SkinReport.tsx`
- [Skincare catalog](https://github.com/aryanmashalkar/skin_ai/blob/main/src/lib/products.ts): `src/lib/products.ts`
- [Concern matching](https://github.com/aryanmashalkar/skin_ai/blob/main/src/lib/matching.ts): `src/lib/matching.ts`
- [Routine planner](https://github.com/aryanmashalkar/skin_ai/blob/main/src/components/RoutineSection.tsx): `src/components/RoutineSection.tsx`
- [Progress tracking](https://github.com/aryanmashalkar/skin_ai/blob/main/src/components/ProgressSection.tsx): `src/components/ProgressSection.tsx`

### Colour and styling

- [Appearance sampling](https://github.com/aryanmashalkar/skin_ai/blob/main/src/lib/appearance-sample.ts): `src/lib/appearance-sample.ts`
- [Colour measurements](https://github.com/aryanmashalkar/skin_ai/blob/main/src/lib/color.ts): `src/lib/color.ts`
- [Season classification](https://github.com/aryanmashalkar/skin_ai/blob/main/src/lib/season.ts): `src/lib/season.ts`
- [Season styling](https://github.com/aryanmashalkar/skin_ai/blob/main/src/lib/fashion/styling.ts): `src/lib/fashion/styling.ts`

### Fashion experience

- [Fashion collection](https://github.com/aryanmashalkar/skin_ai/blob/main/src/app/fashion/page.tsx): `src/app/fashion/page.tsx`
- [Garment catalog](https://github.com/aryanmashalkar/skin_ai/blob/main/src/lib/fashion/products.ts): `src/lib/fashion/products.ts`
- [Garment cards](https://github.com/aryanmashalkar/skin_ai/blob/main/src/components/fashion/GarmentCard.tsx): `src/components/fashion/GarmentCard.tsx`
- [Virtual try-on](https://github.com/aryanmashalkar/skin_ai/blob/main/src/components/fashion/TryOnModal.tsx): `src/components/fashion/TryOnModal.tsx`
- [Photo preparation](https://github.com/aryanmashalkar/skin_ai/blob/main/src/lib/fashion/photo.ts): `src/lib/fashion/photo.ts`
- [Colour proof](https://github.com/aryanmashalkar/skin_ai/blob/main/src/components/fashion/ColorProofModal.tsx): `src/components/fashion/ColorProofModal.tsx`
- [Garment recolouring](https://github.com/aryanmashalkar/skin_ai/blob/main/src/lib/fashion/recolor.ts): `src/lib/fashion/recolor.ts`
- [Try-on API](https://github.com/aryanmashalkar/skin_ai/blob/main/src/app/api/tryon/route.ts): `src/app/api/tryon/route.ts`
- **YouCam Apparel VTO**

### Shared state and services

- [Persisted app state](https://github.com/aryanmashalkar/skin_ai/blob/main/src/lib/store.ts): `src/lib/store.ts`
- [Unified cart](https://github.com/aryanmashalkar/skin_ai/blob/main/src/lib/cart.ts): `src/lib/cart.ts`
- [Cart drawer](https://github.com/aryanmashalkar/skin_ai/blob/main/src/components/CartDrawer.tsx): `src/components/CartDrawer.tsx`
- [Request limiting](https://github.com/aryanmashalkar/skin_ai/blob/main/src/lib/rate-limit.ts): `src/lib/rate-limit.ts`

### Other components

- **Shopper**

## Connections

- Shopper → Selfie scan: provides selfie
- Selfie scan → Skin analysis API: submits scan
- Selfie scan → Appearance sampling: samples appearance (evidence: `src/components/ScanModal.tsx`)
- Selfie scan → Persisted app state: updates profile (evidence: `src/components/ScanModal.tsx`)
- Skin analysis API → YouCam Skin API: requests analysis
- Skin analysis API → Skin profile model: parses results (evidence: `src/app/api/skin/analyze/route.ts`)
- Skin analysis API → Request limiting: checks limits (evidence: `src/app/api/skin/analyze/route.ts`)
- Skin analysis API → Season classification: derives season (evidence: `src/app/api/skin/analyze/route.ts`)
- Skin analysis API → Shopper: returns profile
- Appearance sampling → Colour measurements: converts samples (evidence: `src/lib/appearance-sample.ts`)
- Colour measurements → Season classification: classifies season (evidence: `src/lib/color.ts`)
- Season classification → Skin profile model: provides tone (evidence: `src/app/api/skin/analyze/route.ts`)
- Skin profile model → Persisted app state: stores profile (evidence: `src/lib/store.ts`)
- Persisted app state → Skin report: supplies profile (evidence: `src/components/SkinReport.tsx`)
- Skin report → Concern matching: ranks products (evidence: `src/components/SkinReport.tsx`)
- Concern matching → Skincare catalog: scores products
- Skin report → Routine planner: renders routine (evidence: `src/components/SkinReport.tsx`)
- Skin report → Progress tracking: renders progress (evidence: `src/components/SkinReport.tsx`)
- Shopper → Fashion collection: browses apparel
- Fashion collection → Garment catalog: loads collection (evidence: `src/app/fashion/page.tsx`)
- Fashion collection → Garment cards: renders garments (evidence: `src/app/fashion/page.tsx`)
- Fashion collection → Persisted app state: reads profile (evidence: `src/app/fashion/page.tsx`)
- Fashion collection → Season styling: derives recommendations (evidence: `src/app/fashion/page.tsx`)
- Season styling → Skin profile model: uses skin profile (evidence: `src/lib/fashion/styling.ts`)
- Season styling → Colour measurements: uses colour analysis (evidence: `src/lib/fashion/styling.ts`)
- Garment cards → Season styling: shows styling (evidence: `src/components/fashion/GarmentCard.tsx`)
- Virtual try-on → Photo preparation: prepares photo (evidence: `src/components/fashion/TryOnModal.tsx`)
- Virtual try-on → Try-on API: requests try-on
- Try-on API → Garment catalog: resolves garment (evidence: `src/app/api/tryon/route.ts`)
- Try-on API → YouCam Apparel VTO: renders garment
- Colour proof → Photo preparation: prepares photo (evidence: `src/components/fashion/ColorProofModal.tsx`)
- Colour proof → Garment recolouring: recolours garment (evidence: `src/components/fashion/ColorProofModal.tsx`)
- Colour proof → Try-on API: requests both renders (evidence: `src/components/fashion/ColorProofModal.tsx`)
- Persisted app state → Unified cart: manages cart lines (evidence: `src/lib/store.ts`)
- Cart drawer → Persisted app state: reads and updates (evidence: `src/components/CartDrawer.tsx`)
- Cart drawer → Unified cart: changes quantities (evidence: `src/components/CartDrawer.tsx`)
- Persisted app state → Skincare catalog: accepts products (evidence: `src/lib/store.ts`)
- Persisted app state → Garment catalog: accepts garments (evidence: `src/lib/store.ts`)
