> ## Documentation Index
> Fetch the complete documentation index at: https://docs.highailabs.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Label Scanner Flow

> The complete label scanning user flow — camera capture, batch scanning, AI analysis, terpene extraction, High Family classification, and database matching.

## Overview

The label scanner transforms physical product packaging into structured digital data using AI vision. This flow covers every step from opening the scanner to acting on results, including single and batch scanning modes.

## Complete Scanner Flow

```mermaid theme={null}
sequenceDiagram
    participant U as User
    participant App as High IQ
    participant API as Hono API
    participant AI as Gemini 3 Flash

    U->>App: Open Label Scanner
    App->>App: Check camera permission

    alt Permission Not Granted
        App->>U: Request camera permission
        U->>App: Grant permission
    end

    alt Single Scan
        U->>App: Capture label image
    else Batch Scan
        U->>App: Capture image 1
        U->>App: Optionally label as "front"
        U->>App: Capture image 2
        U->>App: Optionally label as "COA"
        Note over U,App: Up to 4 images
    end

    App->>App: Resize images (max 1920px)
    App->>App: Convert to base64
    App->>API: POST /scanner/analyze-label

    API->>AI: Send images + extraction prompt
    AI-->>API: Extracted data JSON
    API->>API: Classify into High Family

    alt Strain Name Extracted
        API->>API: Search strain database
        alt Match Found
            API-->>App: Results + strain profile link
        else No Match
            API-->>App: Results + "Submit for research" option
        end
    else No Strain Name
        API-->>App: Partial results + warning
    end

    App->>U: Display analysis results
```

## Camera Interaction Flow

```mermaid theme={null}
graph TD
    A[Open Scanner] --> B{Camera Permission}

    B -->|Granted| C[Camera View Active]
    B -->|Not Granted| D[Permission Request]
    B -->|Denied Previously| E[Settings Redirect]

    D --> D1{User Response}
    D1 -->|Allow| C
    D1 -->|Deny| F[Photo Library Fallback]

    E --> E1[Guide to iOS Settings]

    C --> G{Capture Mode}
    G -->|Single| H[Tap Capture Button]
    G -->|Batch| I[Tap Capture + Add More]

    H --> J[Single Image Captured]
    I --> K[Multiple Images: 1-4]

    F --> L[Select From Library]
    L --> J
```

## Batch Scanning Flow

```mermaid theme={null}
graph TD
    A[Start Batch Scan] --> B[Capture Image 1]
    B --> C{Add More?}

    C -->|Yes| D[Capture Image 2]
    D --> E{Add More?}

    E -->|Yes| F[Capture Image 3]
    F --> G{Add More?}

    G -->|Yes| H[Capture Image 4 - Max]
    G -->|No| I[Label Images Optional]

    C -->|No| I
    E -->|No| I
    H --> I

    I --> I1[Label: Front]
    I --> I2[Label: Back]
    I --> I3[Label: COA]
    I --> I4[Label: Side]

    I --> J[Start Analysis]
    J --> K[AI Merges Data from All Images]

    K --> K1[Terpenes: Max value across images]
    K --> K2[Cannabinoids: Prefer COA source]
    K --> K3[Strain Name: Highest confidence]
```

## Classification Tiers

```mermaid theme={null}
graph TD
    A[Data Extracted] --> B{What Was Found?}

    B -->|Complete terpene %| C[Tier 1: 80-95% Accuracy]
    C --> C1[Direct cluster matching]

    B -->|Dominant terpene + type| D[Tier 2: 60-80% Accuracy]
    D --> D1[Primary terpene mapping]

    B -->|Type + effects only| E[Tier 3: 40-60% Accuracy]
    E --> E1[Type-based heuristics]

    B -->|Type only| F[Tier 4: 20-40% Accuracy]
    F --> F1[Fallback classification]

    B -->|Nothing useful| G[No Classification]
    G --> G1[Friendly error message]

    C1 --> H[High Family Result + Confidence Score]
    D1 --> H
    E1 --> H
    F1 --> H
```

## Results Screen Actions

```mermaid theme={null}
graph TD
    A[Analysis Results] --> B[Extracted Data Display]
    B --> B1[Strain Name]
    B --> B2[THC/CBD Percentages]
    B --> B3[Terpene Profile Bars]
    B --> B4[High Family Badge + Confidence]
    B --> B5[Brand/Producer]
    B --> B6[Product Type]

    A --> C{Strain in Database?}
    C -->|Yes| D[View Full Profile Link]
    D --> D1[Tap to Navigate]

    C -->|No| E[Submit for Research Option]
    E --> E1[Queue via Trigger.dev]

    A --> F{User Actions}
    F --> F1[Add to Stash]
    F --> F2[Save Scan Results]
    F --> F3[Scan Another Label]
    F --> F4[Share Results]
```

## Error Handling Flow

```mermaid theme={null}
graph TD
    A[Image Submitted] --> B{Validation}

    B -->|Not Cannabis Label| C[Friendly Error]
    C --> C1[What types of images work]
    C --> C2[Tips for better results]

    B -->|Too Blurry| D[Retake Prompt]
    D --> D1[Photography tips shown]

    B -->|Image Too Dark| E[Lighting Tips]

    B -->|Image Too Large| F[Auto-Resize]
    F --> G[Proceed with Resized]

    B -->|Valid Image| G[AI Analysis]

    G --> H{Extraction Quality}
    H -->|Full Data| I[Complete Results]
    H -->|Partial Data| J[Results + Warning Banner]
    H -->|No Data Extracted| K[Manual Entry Suggestion]

    J --> J1[Classification attempted with available data]
    J --> J2[Lower confidence displayed]

    K --> K1[Add strain manually instead]
```

## Edge Cases

| Scenario                          | Behavior                                                   |
| --------------------------------- | ---------------------------------------------------------- |
| Not a cannabis label              | "This doesn't appear to be a cannabis label" with examples |
| Blurry/dark image                 | Retake prompt with photography tips                        |
| Curved glass label (partial text) | Use batch mode with multiple angles                        |
| COA lab sticker                   | Best results — complete terpene data extracted             |
| Retail packaging only (THC/CBD)   | Tier 2-3 classification, lower confidence                  |
| Multiple products in one image    | AI extracts primary product, may miss secondary            |
| Label in non-English language     | Partial extraction, terpene names often universal          |
| Very small label text             | Auto-zoom suggestion, batch mode recommended               |
| Duplicate scan of same product    | Each scan independent, results may vary slightly           |
| Network offline                   | Error: scanner requires connectivity                       |
| HEIC image format (iOS)           | Supported, auto-converted                                  |
| Scan rate limit reached           | "Try again in X minutes" message                           |

## Related Flows

<CardGroup cols={2}>
  <Card title="Stash Management" icon="box" href="/help/user-flows/stash-management">
    Adding scanned strains to your stash.
  </Card>

  <Card title="Strain Discovery" icon="magnifying-glass" href="/help/user-flows/strain-discovery">
    Viewing full profiles for matched strains.
  </Card>

  <Card title="Onboarding" icon="right-to-bracket" href="/help/user-flows/onboarding">
    Label scanning as a first-time user action.
  </Card>

  <Card title="Order Upload" icon="receipt" href="/help/user-flows/order-upload">
    Alternative data ingestion methods.
  </Card>
</CardGroup>
