reference

Workout Window AI Users System

Overview

The AI Users system generates synthetic users to populate workout window teams and squads. This allows:

  • Testing the system with users spread across the U.S.
  • Ensuring full teams and squads even with low real user adoption
  • Real users can naturally replace AI users over time as they join

Database Schema

Migration: 026_add_ai_users.sql

  • profiles.is_ai: Boolean flag marking AI users
  • workout_window_ai_users: Table storing AI user configuration
    • Region, city, state, timezone
    • Activity type and time window
    • Check-in probability (default 85%)
    • Active status

AI User Generation

Default Configuration

  • Regions: 5 U.S. regions with major cities

    • West Coast (25%): LA, SF, Seattle, San Diego, Portland
    • East Coast (30%): NYC, Boston, Philly, DC, Miami
    • Midwest (20%): Chicago, Detroit, Minneapolis, KC, Milwaukee
    • South (15%): Atlanta, Dallas, Houston, Nashville, Austin
    • Mountain West (10%): Denver, Phoenix, Salt Lake City, Las Vegas
  • Activity Distribution:

    • Cardio: 30%
    • Strength: 25%
    • Walk: 20%
    • Meditation: 10%
    • Reading: 10%
    • Homework: 3%
    • Other: 2%
  • Time Windows: Distributed across day

    • Early morning (6-8am): 15%
    • Morning (8-10am): 10%
    • Lunch (12-2pm): 20%
    • Afternoon (2-4pm): 15%
    • Evening (4-6pm): 25%
    • Late evening (6-8pm): 15%
  • Check-in Probability: 85% (configurable)

API Endpoints

Admin Only (Super Admin)

  • POST /api/workout-window/admin/ai-users/generate

    • Generate AI users
    • Body: { count: number, config?: Partial<AIGenerationConfig> }
    • Returns: { created, failed, users, errors }
  • GET /api/workout-window/admin/ai-users

    • Get all AI users with profiles
  • DELETE /api/workout-window/admin/ai-users/:id

    • Delete an AI user (removes all associated data)
  • PUT /api/workout-window/admin/ai-users/:id/toggle

    • Toggle active status
    • Body: { isActive: boolean }
  • GET /api/workout-window/admin/teams/:date

    • Get team and squad breakdown showing AI vs real users
    • Shows Red/Blue teams, squads, and member breakdown

Admin UI

Accessible via Admin Panel → Workout Window tab.

Features

  1. Generate AI Users

    • Specify count (1-1000)
    • Users distributed across U.S. regions
    • Automatically creates:
      • Auth user account
      • Profile with display name
      • Workout window configuration
      • Location data
      • AI user record
  2. View AI Users

    • List all AI users
    • Shows: name, location, activity, time window, status
    • Actions: activate/deactivate, delete
  3. Team Breakdown

    • View teams and squads for any date
    • Shows AI vs real user counts
    • Color-coded indicators:
      • 🤖 Blue dot = AI user
      • 👤 Green dot = Real user
    • Check-in status (✓ for completed)
  4. Squad Breakdown

    • View all 3-person squads
    • Shows team color (Red/Blue)
    • Member breakdown with AI/real indicators

Integration with Chain Matching

AI users are automatically included in chain matching because:

  • They have workout_windows entries with is_active = true
  • They have workout_window_locations entries with coordinates
  • Chain matching queries all active workout windows

No special handling needed - AI users are treated like real users in the matching algorithm.

AI User Replacement

As real users join:

  1. Daily chain regeneration includes all active users (AI + real)
  2. Real users naturally get matched into chains/squads
  3. Over time, real users replace AI users as the system grows
  4. AI users can be deactivated as real user density increases

Best Practices

  1. Initial Population: Generate 50-100 AI users to ensure full teams
  2. Geographic Distribution: AI users are automatically distributed across U.S.
  3. Activity Variety: Mix of activity types and time windows
  4. Gradual Replacement: As real users join, deactivate AI users in high-density areas
  5. Monitoring: Use team breakdown to track AI vs real user ratios

Check-in Behavior

AI users have an 85% check-in probability. This means:

  • Most AI users will check in daily
  • Some will "miss" check-ins (simulating real behavior)
  • Battle chips are earned based on actual check-ins

Future Enhancements

  • Automatic Check-ins: Option to auto-check-in AI users based on probability
  • Smart Replacement: Automatically deactivate AI users when real users join nearby
  • Regional Targeting: Generate AI users in specific regions
  • Activity Patterns: More sophisticated activity and time window patterns
  • Performance Metrics: Track AI user participation rates
WORKOUT WINDOW AI USERS — Docs | HiveJournal