# User Seeder

This seeder creates 10 diverse users with complete profiles and astrology charts for testing and development purposes.

## Overview

The seeder generates 10 users with:

- **Diverse Profiles**: Different subscription tiers, verification statuses, and completion states
- **Realistic Data**: Proper names, emails, and user attributes
- **Astrology Charts**: Complete birth charts with planetary positions, house cusps, and aspects
- **Admin User**: One admin user for testing administrative functions

## Features

### User Diversity

- **Subscription Tiers**: FREE_TIER, HEALING, THERAPY
- **Verification Status**: Mix of verified and unverified users
- **Profile Completion**: Some users have incomplete profiles
- **User Types**: Regular users and one admin user

### Astrology Integration

- **Birth Charts**: Each regular user gets a complete astrology chart
- **Realistic Data**: Birth dates between 1980-2005 with random times
- **Global Locations**: 10 major cities worldwide with accurate coordinates
- **Planetary Positions**: All 10 planets with realistic sign placements
- **House Cusps**: All 12 astrological houses
- **Aspects**: Major astrological aspects between planets

## User Profiles

### Regular Users (9)

1. **John Doe** - john.doe@example.com (FREE_TIER, Verified, Complete)
2. **Sarah Wilson** - sarah.wilson@example.com (HEALING, Verified, Complete)
3. **Michael Chen** - michael.chen@example.com (THERAPY, Verified, Complete)
4. **Emma Rodriguez** - emma.rodriguez@example.com (FREE_TIER, Unverified, Incomplete)
5. **David Kim** - david.kim@example.com (HEALING, Verified, Complete)
6. **Lisa Thompson** - lisa.thompson@example.com (THERAPY, Verified, Complete)
7. **Alex Brown** - alex.brown@example.com (FREE_TIER, Verified, Incomplete)
8. **Maria Garcia** - maria.garcia@example.com (HEALING, Unverified, Complete)
9. **James Taylor** - james.taylor@example.com (THERAPY, Verified, Complete)

### Admin User (1)

10. **Admin User** - admin@schematics.com (THERAPY, Verified, Complete, ADMIN)

## Usage

### Prerequisites

- Database must be migrated and up to date
- Prisma client must be generated

### Running the Seeder

```bash
# Run the user seeder
npm run db:users:seed

# Or run all seeders
npm run db:seed
```

### What Gets Created

For each user:

1. **User Record** with complete profile data
2. **Astrology Chart** (for regular users only)
3. **10 Planetary Positions** (Sun, Moon, Mercury, Venus, Mars, Jupiter, Saturn, Uranus, Neptune, Pluto)
4. **12 House Cusps** (one for each astrological house)
5. **Multiple Aspects** (aspects between planets)

## Data Structure

### User Attributes

- **Email**: Unique email addresses
- **Password**: All users have `password123`, admin has `admin123`
- **Full Name**: Realistic names
- **Subscription Tier**: FREE_TIER, HEALING, or THERAPY
- **Verification Status**: Mix of verified/unverified
- **Profile Completion**: Mix of complete/incomplete profiles
- **User Type**: USER or ADMIN

### Astrology Data

- **Birth Dates**: Random dates between 1980-2005
- **Birth Times**: Random times throughout the day
- **Birth Locations**: 10 major cities worldwide
- **Sun Signs**: Random zodiac signs
- **Planetary Positions**: Realistic astrological patterns
- **House Cusps**: All 12 houses with sign and degree data
- **Aspects**: Major aspects between planets

## Birth Locations

The seeder uses 10 major cities worldwide:

- New York, NY, USA
- Los Angeles, CA, USA
- London, UK
- Paris, France
- Tokyo, Japan
- Sydney, Australia
- Mumbai, India
- São Paulo, Brazil
- Cairo, Egypt
- Moscow, Russia

## Login Credentials

### Regular Users

- **Email**: As listed in user profiles above
- **Password**: `password123`

### Admin User

- **Email**: admin@schematics.com
- **Password**: `admin123`

## Example Output

```
👥 Starting user seeding...
🧹 Clearing 0 existing users...
✅ Created user: john.doe@example.com (USER)
📊 Created astrology chart for john.doe@example.com: ARIES Sun, CANCER Moon, LEO Rising
✅ Created user: sarah.wilson@example.com (USER)
📊 Created astrology chart for sarah.wilson@example.com: TAURUS Sun, VIRGO Moon, SCORPIO Rising
...
✅ Created user: admin@schematics.com (ADMIN)

✅ Successfully created 10 users:
   - Complete user profiles with realistic data
   - Astrology charts for regular users
   - Planetary positions, house cusps, and aspects
   - Diverse subscription tiers and verification statuses

📋 User Summary:
   1. John Doe (john.doe@example.com) - FREE_TIER - USER
   2. Sarah Wilson (sarah.wilson@example.com) - HEALING - USER
   ...

🔑 Login Credentials:
   All users have password: password123
   Admin user has password: admin123
```

## Database Impact

The seeder will:

- **Clear existing users** (except admin@schematics.com) before creating new ones
- **Preserve other data** in the database
- **Create relationships** between users and their astrology charts
- **Use transactions** to ensure data consistency

## Customization

To modify the seeder:

1. **Add More Users**: Extend the `USER_DATA` array
2. **Change User Attributes**: Modify the user data structure
3. **Add More Locations**: Extend the `BIRTH_LOCATIONS` array
4. **Modify Astrology Logic**: Update the planetary position generation
5. **Change Passwords**: Update the password hashing logic

## Troubleshooting

### Common Issues

1. **Database Connection**: Check your DATABASE_URL environment variable
2. **Migration Issues**: Run `npx prisma migrate dev` before seeding
3. **Permission Errors**: Ensure database user has CREATE/INSERT permissions
4. **Duplicate Users**: The seeder checks for existing users before creating

### Verification

After running the seeder, you can verify the data:

```sql
-- Check users created
SELECT email, "full_name", "subscriptionTier", "user_type", "is_verified" FROM users;

-- Check astrology charts
SELECT COUNT(*) FROM astrology_charts;

-- Check planetary positions
SELECT COUNT(*) FROM planetary_positions;

-- Check house cusps
SELECT COUNT(*) FROM house_cusps;

-- Check aspects
SELECT COUNT(*) FROM aspects;
```

## Notes

- The seeder is idempotent - running it multiple times will clear and recreate the data
- All passwords are hashed using bcrypt with 12 rounds
- Astrology charts are only created for regular users, not admin
- The seeder preserves the existing admin user if it exists
- All charts are automatically approved and ready for use

## Related Files

- `prisma/user-seeders.ts` - Main seeder file
- `prisma/schema.prisma` - Database schema
- `package.json` - Contains the seeder script
- `prisma/seed.ts` - Main astrology chart seeder
