# Birthday Reminder PWA

A comprehensive Progressive Web Application for managing birthdays and sending automated reminders via WhatsApp and SMS.

## Features

- **Admin Dashboard**: Manage templates, contacts, and notes with full CRUD operations
- **Excel Import/Export**: Bulk import/export contacts via Excel files
- **PWA Frontend**: Mobile-first Progressive Web App for end users
- **Push Notifications**: Daily reminders at 9 AM IST
- **WhatsApp/SMS Integration**: Send birthday wishes with pre-filled templates
- **Image Processing**: Automatic WebP conversion and compression
- **Multi-user Support**: Separate data for each user

## Requirements

- PHP 7.4 or higher
- MySQL 5.7 or higher
- Apache/Nginx with mod_rewrite
- GD Library or Imagick
- Composer
- SSL certificate (for PWA features)

## Installation

1. **Clone the repository**
   ```bash
   git clone <repository-url>
   cd birthday_reminder
   ```

2. **Install dependencies**
   ```bash
   composer install
   ```

3. **Configure database**
   - Create a MySQL database named `birthday_reminder`
   - Update database credentials in `config/config.php`
   - Import the schema:
     ```bash
     mysql -u root -p birthday_reminder < config/schema.sql
     ```

4. **Set up permissions**
   ```bash
   chmod -R 755 uploads/
   chmod -R 755 logs/
   ```

5. **Configure web server**
   - Point document root to `/public` directory
   - Ensure mod_rewrite is enabled
   - For production, enable HTTPS (required for PWA)

6. **Set up cron jobs**
   ```bash
   # Daily notifications at 9 AM IST
   0 9 * * * /usr/bin/php /path/to/cron/send_daily_notifications.php
   
   # Midnight data refresh
   0 0 * * * /usr/bin/php /path/to/cron/refresh_daily_data.php
   ```

## Default Credentials

- **Username**: admin
- **Password**: admin123

**Important**: Change the default password after first login!

## Testing

Run all tests:
```bash
composer test
```

Run unit tests only:
```bash
composer test-unit
```

Run property-based tests only:
```bash
composer test-property
```

## Project Structure

```
birthday_reminder/
├── app/
│   ├── controllers/     # MVC Controllers
│   ├── models/          # MVC Models
│   └── views/           # MVC Views
│       ├── admin/       # Admin dashboard views
│       ├── layouts/     # Layout templates
│       └── pwa/         # PWA frontend views
├── config/              # Configuration files
│   ├── config.php       # Main configuration
│   ├── Database.php     # Database connection class
│   ├── autoload.php     # Class autoloader
│   └── schema.sql       # Database schema
├── public/              # Public web root
│   ├── css/             # Stylesheets
│   ├── js/              # JavaScript files
│   ├── images/          # Static images
│   ├── index.php        # Main entry point
│   └── .htaccess        # Apache rewrite rules
├── uploads/             # User uploads
│   ├── images/          # Uploaded images (WebP)
│   └── excel/           # Excel files
├── cron/                # Cron job scripts
├── tests/               # Test files
│   ├── unit/            # Unit tests
│   └── property/        # Property-based tests
├── logs/                # Application logs
├── composer.json        # Composer dependencies
└── phpunit.xml          # PHPUnit configuration
```

## API Endpoints

### Authentication
- `POST /api/auth/login` - User login
- `POST /api/auth/logout` - User logout

### Contacts
- `GET /api/contacts` - List all contacts
- `POST /api/contacts` - Create contact
- `PUT /api/contacts/:id` - Update contact
- `DELETE /api/contacts/:id` - Delete contact
- `GET /api/contacts/today` - Get today's birthdays
- `GET /api/contacts/search?q=query` - Search contacts

### Templates
- `GET /api/templates` - List all templates
- `GET /api/templates/active` - List active templates
- `POST /api/user-templates/set-default` - Set default template

### Notes
- `GET /api/notes` - List all notes
- `POST /api/notes` - Create note
- `GET /api/notes/today` - Get today's reminders

### Notifications
- `POST /api/notifications/subscribe` - Subscribe to push notifications

## Development

### Running locally with Laragon

1. Place project in `C:\laragon\www\birthday_reminder`
2. Start Laragon
3. Access at `http://localhost/birthday_reminder`

### Database migrations

To reset the database:
```bash
mysql -u root -p birthday_reminder < config/schema.sql
```

## License

Proprietary - All rights reserved

## Support

For issues and questions, please contact the development team.
