# WhatsApp SaaS Platform

A comprehensive multi-tenant SaaS platform for WhatsApp Business API integration built with Laravel 12.

## 🎯 Features

- **Multi-tenant Architecture** with team-based isolation
- **WhatsApp Integration** via Meta Business API
- **Subscription Plans** (Free, Starter $29, Professional $79, Business $199, Enterprise)
- **Message Management** - Send/receive text, media, documents
- **Contact CRM** - EAV + JSON hybrid custom fields
- **Inbox** - Unified conversation management
- **Broadcasts** - Bulk messaging campaigns
- **Workflows** - Automation engine
- **Webhooks** - Outgoing webhooks with HMAC signatures
- **Media Storage** - Cloudflare R2 integration
- **Usage Metering** - Message/storage quotas with boost packs
- **Rate Limiting** - Per-plan API limits

## 🏗️ Architecture

```
Meta WhatsApp → Cloudflare Worker → Queue → Laravel → Database/Redis/R2
```

## 📋 Requirements

- PHP 8.2+, MySQL 8.0+, Redis 6.0+
- Stripe, Meta WhatsApp Business, Cloudflare accounts

## 🚀 Quick Start

```bash
composer install && npm install
cp .env.example .env
php artisan key:generate
php artisan migrate --seed
php artisan serve
```

## 📊 Database Schema

**Core:** teams, users, plans
**Messaging:** whatsapp_channels, messages, message_media
**CRM:** contacts, tags, contact_fields (EAV), segments
**Automation:** workflows, broadcasts
**Integration:** outgoing_webhooks, webhook_logs

## 🔧 Configuration

Add to `.env`:
- Stripe keys & price IDs
- Meta WhatsApp credentials
- Cloudflare R2 endpoint
- Redis connection

## 📄 License

Proprietary - All rights reserved
