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

# Collection & Rankings Flow

> The complete collection management and ELO ranking flow — status tracking, head-to-head comparisons, ranking emergence, and cross-feature integration.

## Overview

The collection and rankings system tracks every strain a user has encountered and uses an ELO algorithm to determine their personal favorites through head-to-head comparisons. This flow documents how strains enter the collection, how rankings are built, and how the system integrates with other features.

## Collection Entry Points

```mermaid theme={null}
graph TD
    A{How does a strain enter the collection?} --> B[Add to Stash]
    A --> C[Strain Profile Action]
    A --> D[Order Import]
    A --> E[Gmail Import]
    A --> F[Ask AI Action]

    B --> G[Auto-Status: Owned]
    C --> H{User Selects Status}
    D --> I[Auto-Status: Owned]
    E --> J[Historical: Tasted]
    F --> K[Via AI Tool]

    H --> H1[Owned]
    H --> H2[Tasted]
    H --> H3[Wanted - Wishlist]
    H --> H4[Disliked]

    G --> L[Collection Updated]
    H1 --> L
    H2 --> L
    H3 --> L
    H4 --> L
    I --> L
    J --> L
    K --> L

    L --> M[Achievement Check]
    M --> M1[Core Collection Progress]
    M --> M2[Strain Variety Progress]
    M --> M3[Collection Curator Progress]
```

## Collection Status State Machine

```mermaid theme={null}
stateDiagram-v2
    [*] --> NotInCollection
    NotInCollection --> Owned: Add to Stash
    NotInCollection --> Tasted: Mark as Tried
    NotInCollection --> Wanted: Add to Wishlist
    NotInCollection --> Disliked: Mark as Disliked

    Owned --> Tasted: Mark Empty (still tasted)
    Owned --> Disliked: Didn't like it
    Tasted --> Owned: Re-purchase
    Tasted --> Disliked: Changed mind
    Wanted --> Owned: Purchased
    Wanted --> Tasted: Tried at friend's
    Wanted --> Disliked: Tried and disliked
    Disliked --> Wanted: Give it another chance
    Disliked --> Tasted: Tried different batch

    Owned --> [*]: Remove from collection
    Tasted --> [*]: Remove from collection
    Wanted --> [*]: Remove from collection
    Disliked --> [*]: Remove from collection

    note right of Owned : Can also be Favorited (separate flag)
    note right of Tasted : Eligible for ELO ranking
```

**Multi-status note:** A strain can hold multiple statuses simultaneously (e.g., Owned + Tasted). The Owned status is auto-set when a strain is in the active stash.

## ELO Ranking Flow

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

    Note over U,DB: Prerequisite: 3+ experienced strains (owned or tasted)

    U->>App: Tap "Start Ranking"
    App->>DB: Fetch eligible strains
    DB-->>App: Strains with ELO scores

    App->>App: Select comparison pair
    Note over App: Algorithm picks highest-value pairs

    loop Ranking Session
        App->>U: Show Strain A vs Strain B
        U->>App: Choose preference

        alt Strain A Wins
            App->>App: Update A's ELO (increase)
            App->>App: Update B's ELO (decrease)
        else Strain B Wins
            App->>App: Update B's ELO (increase)
            App->>App: Update A's ELO (decrease)
        else Tie
            App->>App: Minimal ELO adjustment for both
        else Skip
            App->>App: No ELO change
        end

        App->>DB: Save comparison result
        App->>U: Show updated rankings

        App->>App: Select next pair
    end

    U->>App: End ranking session
    App->>DB: Save session summary
    App->>U: Show ranking overview
```

### ELO Score Mechanics

```mermaid theme={null}
graph TD
    A[New Strain Added to Collection] --> B[Initial ELO: 1200]
    B --> C[First Comparison]

    C --> D{Outcome}
    D -->|Win against higher ELO| E[Large ELO Gain]
    D -->|Win against lower ELO| F[Small ELO Gain]
    D -->|Loss to higher ELO| G[Small ELO Loss]
    D -->|Loss to lower ELO| H[Large ELO Loss]
    D -->|Tie| I[Minimal Adjustment]

    E --> J[Updated Rankings]
    F --> J
    G --> J
    H --> J
    I --> J

    J --> K{Convergence Check}
    K -->|3-5 comparisons per strain| L[Rankings Stable]
    K -->|Fewer comparisons| M[Rankings Still Emerging]
```

### Pair Selection Algorithm

The system selects comparison pairs to maximize ranking information:

| Priority | Selection Strategy | When Used                                        |
| -------- | ------------------ | ------------------------------------------------ |
| 1st      | Uncompared pairs   | Strains that have never been compared            |
| 2nd      | Close ELO scores   | Strains with similar ratings (resolve ambiguity) |
| 3rd      | High uncertainty   | Strains with few total comparisons               |
| 4th      | Random             | When all other strategies exhausted              |

## Collection Screen Navigation

```mermaid theme={null}
graph TD
    A[Open Collection] --> B{Tab Filter}

    B -->|All| C[Every Strain]
    B -->|Favs| D[Favorited Strains]
    B -->|Owned| E[Currently in Stash]
    B -->|Tasted| F[Previously Tried]
    B -->|Wish| G[Wishlist]
    B -->|Dislike| H[Disliked Strains]

    C --> I{Sort Order}
    I -->|Ranking| J[By ELO Position #1, #2, #3...]
    I -->|Name| K[Alphabetical]
    I -->|Most Consumed| L[By Total Quantity]

    C --> M{Card Variant}
    M --> N[Collection / Mascot / Strain / Split / Condensed / Compact]

    C --> O{Actions}
    O -->|Tap Card| P[Strain Profile]
    O -->|Long Press| Q[Quick Action Menu]
    Q --> Q1[Change Status]
    Q --> Q2[Start Comparison]
    Q --> Q3[Remove from Collection]
```

## Favorites vs. Collection Integration

```mermaid theme={null}
graph TD
    A[Strain Interaction] --> B{Action Type}

    B -->|Tap Heart| C[Toggle Favorite]
    C --> C1[Quick Bookmark]
    C --> C2[Separate from Collection Status]
    C --> C3[Collection Curator Achievement]

    B -->|Set Collection Status| D[Collection Management]
    D --> D1[Owned/Tasted/Wanted/Disliked]
    D --> D2[Enables ELO Ranking]
    D --> D3[Core Collection Achievement]

    C1 --> E[Both Can Coexist]
    D1 --> E

    E --> F[Strain can be Favorited + Owned + Tasted]
```

## Rankings Visibility

Rankings data surfaces across multiple screens:

```mermaid theme={null}
graph TD
    A[Rankings Data] --> B[Collection Screen]
    B --> B1[Sort by Ranking]
    B --> B2[ELO Position Badge on Cards]

    A --> C[Home Dashboard]
    C --> C1[Rankings Preview Card]
    C --> C2[Top 5 Ranked Strains]

    A --> D[Stats Dashboard]
    D --> D1[My Strains Tab]
    D --> D2[Ranking Position Per Strain]

    A --> E[My Rankings Screen]
    E --> E1[Dedicated Full View]
    E --> E2[ELO Scores Visible]
    E --> E3[Comparison Stats]

    A --> F[Ask AI]
    F --> F1[My Collection Tool]
    F --> F2[AI Knows Your Top Strains]
```

## Edge Cases

| Scenario                                  | Behavior                                                        |
| ----------------------------------------- | --------------------------------------------------------------- |
| Less than 3 strains in collection         | Rankings disabled, "Add more strains" prompt                    |
| All strains compared, no new pairs        | "All comparisons complete" message                              |
| Strain removed mid-ranking session        | Skip that pair, continue with remaining                         |
| Same strain compared multiple times       | Each comparison updates ELO (can change over time)              |
| Tied ELO scores                           | Same rank displayed for both                                    |
| Very large collection (100+ strains)      | Lazy loading, pair selection prioritizes meaningful comparisons |
| Strain marked Disliked after ranking high | ELO preserved, Disliked status shown as overlay                 |
| Wishlist strain appears at dispensary     | Shopping Agent flags with "Wanted" tag                          |

## Related Flows

<CardGroup cols={2}>
  <Card title="Strain Discovery" icon="magnifying-glass" href="/help/user-flows/strain-discovery">
    How strains are found before adding to collection.
  </Card>

  <Card title="Stash Management" icon="box" href="/help/user-flows/stash-management">
    Stash items auto-populate the collection.
  </Card>

  <Card title="Shopping Agent" icon="cart-shopping" href="/help/user-flows/shopping-agent">
    Wishlisted strains flagged during menu scans.
  </Card>

  <Card title="Achievement System" icon="medal" href="/help/user-flows/achievements">
    Collection and ranking-related achievements.
  </Card>
</CardGroup>
