> ## 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.

# Stash Management Flow

> The complete stash management user flow — adding strains, tracking consumption, inventory lifecycle, sorting, card variants, and bulk operations.

## Overview

Stash management is the core data backbone of High IQ. Every strain the user owns, consumes, or finishes passes through the stash lifecycle. This flow documents the complete stash item journey from creation through consumption to archival, including all interactions and edge cases.

## Stash Item Lifecycle

```mermaid theme={null}
stateDiagram-v2
    [*] --> Created: Add Strain
    Created --> Active: Has Quantity
    Created --> Active: No Quantity (unknown amount)

    Active --> PartiallyConsumed: Log Consumption
    PartiallyConsumed --> PartiallyConsumed: Log More Consumption
    PartiallyConsumed --> Empty: Mark Empty
    PartiallyConsumed --> Empty: Quantity Reaches 0

    Active --> Empty: Mark Empty Directly
    Active --> Updated: Edit Details
    Updated --> Active: Save Changes

    Empty --> Archived: Auto-archived
    Archived --> Active: Restock (Re-add)

    Active --> Deleted: User Deletes
    PartiallyConsumed --> Deleted: User Deletes
    Deleted --> [*]
```

## Adding a Strain — All Entry Points

```mermaid theme={null}
graph TD
    A{How is the strain added?} --> B[Manual Add from Stash Screen]
    A --> C[Receipt Photo Upload]
    A --> D[Gmail Import]
    A --> E[Strain Profile - Add to Stash]
    A --> F[Label Scanner - Add to Stash]
    A --> G[Ask AI Action]
    A --> H[Dashboard Quick Actions]

    B --> I[Search Strain Database]
    I --> I1{Found?}
    I1 -->|Yes| J[Select Strain - Full Profile Linked]
    I1 -->|No| K[Custom Name Entry]

    J --> L[Configure Details]
    K --> L

    L --> L1[Quantity: g, 1/8, 1/4, 1/2, oz, mg, ml]
    L --> L2[Product Type: flower, pre-roll, edible, concentrate, vape, tincture]
    L --> L3[Dispensary: search or create]
    L --> L4[Price: optional]
    L --> L5[Notes: optional]
    L --> L6[Rating: optional]

    L1 --> M[Save to Convex]
    L2 --> M
    L3 --> M
    L4 --> M
    L5 --> M
    L6 --> M

    C --> N[AI Extracts Items]
    N --> O[Each Item → Stash]

    D --> P[Historical Orders]
    P --> P1[Does NOT add to active stash]

    E --> Q[Strain Pre-selected]
    Q --> L

    F --> R[Terpene Data Pre-filled]
    R --> L

    G --> S[AI Adds to Stash via Tool]
    H --> B

    M --> T[Stash Item Created]
    T --> U[Dashboard Updates]
    T --> V[Achievement Check]
    T --> W[Collection Status: Owned]
```

## Consumption Tracking Flow

```mermaid theme={null}
sequenceDiagram
    participant U as User
    participant App as High IQ
    participant DB as Convex

    U->>App: Tap strain in stash
    App->>U: Show strain detail view

    alt Update Quantity
        U->>App: Navigate to Update Stash
        U->>App: Enter new quantity
        App->>App: Calculate consumed amount
        App->>DB: Update quantity
        App->>DB: Log consumption event
        DB-->>App: Updated
        App->>U: Show updated card
    else Mark Empty
        U->>App: Tap "Mark Empty"
        App->>U: Confirmation prompt
        U->>App: Confirm
        App->>DB: Set quantity to 0
        App->>DB: Log empty event
        App->>DB: Archive item
        DB-->>App: Archived
        App->>U: Item moves to history
    else Quick Actions (Swipe)
        U->>App: Swipe left on card
        App->>U: Show action buttons
        U->>App: Tap action (edit/delete/empty)
    end

    App->>DB: Check achievement progress
    DB-->>App: Achievement status

    opt Achievement Earned
        App->>U: Show celebration
    end
```

## Stash Screen Interaction Flow

```mermaid theme={null}
graph TD
    A[Open Stash Tab] --> B[Stash Hero Card]
    B --> B1[Total Grams]
    B --> B2[Active Strain Count]
    B --> B3[Supply Forecast]
    B --> B4{Composition Lens}
    B4 -->|Type| B5[Sativa/Hybrid/Indica Bar]
    B4 -->|Time| B6[High Family Bar]
    B4 -->|Form| B7[Product Form Bar]

    A --> C[Quick Actions Row]
    C -->|Orders| C1[Orders Library Screen]
    C -->|History| E[Stash History Screen]
    C -->|Collection| C2[Collection Screen]

    A --> D[Active Inventory List]

    D --> F{Sort Selection}
    F -->|Recent| G[Most Recently Added]
    F -->|A-Z| H[Alphabetical]
    F -->|Type| I[Sativa/Hybrid/Indica Groups]
    F -->|Terpene| J[Dominant Terpene Groups]
    F -->|Time| K[High Family Time of Day]
    F -->|Amount| L[By Remaining Quantity]

    D --> M{Card Variant}
    M -->|Mascot| N[Two-Column Mascot Grid]
    M -->|Strain| O[Photography Cards]
    M -->|Split| P[Side-by-Side Layout]
    M -->|Condensed| Q[Compact Grid]
    M -->|Compact| R[Minimal List]

    D --> S{Interactions}
    S -->|Tap Card| T[Strain Detail View]
    S -->|Long Press| U[Quick Action Sheet]
    S -->|Swipe Left| V[Inline Actions]
    S -->|Pull Down| W[Refresh All Data]
    S -->|Tap +| X[Add New Strain]

    E --> E1[Quick Stats: Strains / Orders / Favorites]
    E --> E2[Search Full Archive]
    E --> E3{Filter Tabs}
    E3 -->|All / Orders / Stash / Favorites| Y
    E3 -->|Dislikes / Collection / Rankings| Y
    E --> Y[Chronological Events]
    Y --> Y1[Stash Added]
    Y --> Y2[Stash Updated]
    Y --> Y3[Stash Consumed]
    Y --> Y4[Stash Marked Empty]
    Y --> Y5[Order Uploaded]
    Y --> Y6[Favorite Toggled]
    Y --> Y7[Collection Changed]
    Y --> Y8[Comparison Recorded]
```

## Bulk Operations Flow

```mermaid theme={null}
graph TD
    A[Enter Edit Mode] --> B[Tap Edit Button in Header]
    B --> C[Multi-Select Mode Active]
    C --> D[Tap Items to Select]
    D --> E{Bulk Action}

    E -->|Mark Empty| F[Confirm Bulk Empty]
    F --> G[All Selected Items Archived]
    G --> H[Batch Achievement Check]

    E -->|Delete| I[Confirm Bulk Delete]
    I --> J[All Selected Items Removed]

    E -->|Cancel| K[Exit Edit Mode]

    H --> L{Achievements Earned?}
    L -->|4+| M[Batch Summary Screen]
    L -->|2-3| N[Swipeable Achievement Modal]
    L -->|1| O[Toast Notification]
    L -->|None| P[Return to Stash]
```

## Restock Prediction Flow

```mermaid theme={null}
graph TD
    A[Consumption Preferences Set] --> B[Track Daily Usage Rate]
    B --> C[Calculate Days Remaining Per Strain]

    C --> D{Alert Level}
    D -->|Normal| E[No Alert]
    D -->|Low| F[Yellow Warning Banner]
    D -->|Critical| G[Red Alert Banner]
    D -->|Empty| H[Item Marked for Archival]

    F --> I[Days Until Empty Shown]
    G --> I

    I --> J{User Action}
    J -->|Ignore| K[Continue Tracking]
    J -->|Restock| L[Add New Stash Entry]
    J -->|Mark Empty Now| M[Archive Item]
```

## Edge Cases

| Scenario                                    | Behavior                                        |
| ------------------------------------------- | ----------------------------------------------- |
| Add duplicate strain (same name)            | Allowed — creates separate stash entry          |
| Add strain with 0 quantity                  | Allowed — shows "unknown amount"                |
| Change quantity to higher value             | Allowed — no consumption event logged           |
| Delete last stash item                      | Empty state shown with "Add First Strain" CTA   |
| Offline when adding                         | Queued locally, Convex syncs when online        |
| Add strain that was previously marked empty | Creates new entry, separate from archived one   |
| Edit strain name after adding               | Changes display name, does not re-link database |
| Very large stash (100+ items)               | Lazy loading, smooth scrolling maintained       |
| Switch card variant                         | Preference persisted across sessions            |
| Sort + variant combined                     | Both applied simultaneously                     |
| Pull to refresh with no changes             | Toast confirms "Up to date"                     |

## Related Flows

<CardGroup cols={2}>
  <Card title="Order Upload" icon="receipt" href="/help/user-flows/order-upload">
    How orders add items to your stash.
  </Card>

  <Card title="Notebooks" icon="sparkles" href="/help/user-flows/notebooks">
    Generating notebooks from stash data.
  </Card>

  <Card title="Collection & Rankings" icon="trophy" href="/help/user-flows/collection-rankings">
    How stash feeds into collection and ELO rankings.
  </Card>

  <Card title="Stats Dashboard" icon="chart-pie" href="/help/user-flows/stats-analytics">
    Stash data powering analytics.
  </Card>
</CardGroup>
