# Astrology Charts Seeder

This seeder creates comprehensive astrology chart data for testing and development purposes.

## Overview

The seeder generates 10 complete astrology charts with:

- **Birth Data**: Realistic birth dates, times, and locations from major cities worldwide
- **Planetary Positions**: All 10 planets (Sun, Moon, Mercury, Venus, Mars, Jupiter, Saturn, Uranus, Neptune, Pluto) with realistic sign placements
- **House Cusps**: All 12 astrological houses with sign and degree information
- **Aspects**: Major astrological aspects between planets (conjunction, sextile, square, trine, opposition)
- **Interpretations**: Realistic chart interpretations based on astrological knowledge

## Features

### Realistic Astrological Data

- **Sun Sign Logic**: Planetary positions follow realistic astrological patterns
  - Sun stays in the designated sun sign
  - Moon often appears near the sun sign
  - Mercury typically within 1 sign of the sun
  - Venus usually within 2 signs of the sun
  - Outer planets can be in any sign

### Birth Locations

The seeder uses 10 major cities worldwide with accurate coordinates:

- 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

### Chart Interpretations

Each chart includes:

- **Sun Sign Interpretation**: Based on traditional astrological knowledge
- **Astrologer Notes**: Detailed analysis combining sun, moon, and rising signs
- **Realistic Birth Data**: Random dates between 1950-2005 with random birth times

## Usage

### Prerequisites

- Ensure the user with ID `cmex64qxm0004ezl47f635p0c` exists in the database
- Database must be migrated and up to date

### Running the Seeder

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

# Or reset database and seed
npm run db:reset
```

### What Gets Created

For each of the 10 charts:

1. **AstrologyChart** record with birth data and interpretations
2. **10 PlanetaryPosition** records (one for each planet)
3. **12 HouseCusp** records (one for each house)
4. **Multiple Aspect** records (aspects between planets)

## Data Structure

### Chart Types

- All charts are created as `NATAL` charts
- Charts are automatically approved (`isApproved: true`)

### Planetary Data

- **Planets**: Sun, Moon, Mercury, Venus, Mars, Jupiter, Saturn, Uranus, Neptune, Pluto
- **Signs**: All 12 zodiac signs (Aries through Pisces)
- **Degrees**: Random degrees within each sign (0-30°)
- **Houses**: Random house placements (1-12)
- **Retrograde**: 30% chance of retrograde motion

### Aspects

- **Types**: Conjunction, Sextile, Square, Trine, Opposition
- **Orbs**: Random orbs up to 8 degrees
- **Exact Aspects**: Orbs less than 1 degree marked as exact

## Customization

To modify the seeder:

1. **Change Number of Charts**: Modify the loop in `main()` function
2. **Add More Locations**: Extend the `BIRTH_LOCATIONS` array
3. **Modify Interpretations**: Update the `CHART_INTERPRETATIONS` object
4. **Adjust Planetary Logic**: Modify the `generatePlanetaryPositions()` function
5. **Change User ID**: Update the `DEFAULT_USER_ID` constant

## Example Output

```
🌙 Starting astrology chart seeding...
✅ Found user: admin@mailinator.com
🧹 Cleared existing astrology charts
📊 Created chart 1: Cancer Sun, Pisces Moon, Aquarius Rising
📊 Created chart 2: Aquarius Sun, Taurus Moon, Capricorn Rising
...
✅ Successfully created 10 astrology charts with complete data:
   - Planetary positions for all 10 planets
   - House cusps for all 12 houses
   - Astrological aspects between planets
   - Realistic birth data and interpretations
```

## Database Impact

The seeder will:

- **Clear existing charts** for the specified user before creating new ones
- **Preserve other data** in the database
- **Create relationships** between all related models
- **Use transactions** to ensure data consistency

## Troubleshooting

### Common Issues

1. **User Not Found**: Ensure the user ID exists in the database
2. **Database Connection**: Check your DATABASE_URL environment variable
3. **Migration Issues**: Run `npx prisma migrate dev` before seeding
4. **Permission Errors**: Ensure database user has CREATE/INSERT permissions

### Verification

After running the seeder, you can verify the data:

```sql
-- Check charts created
SELECT COUNT(*) FROM astrology_charts WHERE "userId" = 'cmex64qxm0004ezl47f635p0c';

-- 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 uses realistic astrological patterns but generates random data
- Birth dates are randomly distributed between 1950-2005
- All charts are created for the same user ID as specified
- The seeder is idempotent - running it multiple times will clear and recreate the data
