# EasyStream - Quick Start Guide

## 🚀 Get Started in 3 Minutes

### Option 1: Automated Deployment (Recommended)

```powershell
# Test configuration
.\deploy.ps1 -Mode test

# Deploy for development
.\deploy.ps1 -Mode dev

# Deploy for production (after configuring secrets)
.\deploy.ps1 -Mode prod
```

That's it! Access at **http://localhost:8083**

---

### Option 2: Manual Deployment

#### Step 1: Start Services
```bash
docker-compose up -d
```

#### Step 2: Wait for Database (2-3 minutes)
```bash
docker-compose logs -f db
```
Wait until you see: "ready for connections"

#### Step 3: Access Application
- Frontend: http://localhost:8083
- Admin: http://localhost:8083/admin
- Login: `admin` / `admin123` (⚠️ change immediately!)

---

## 📁 Folder Sync (Repos ↔ Docker-Progs)

### One-Time Sync
```bash
.\sync-to-docker-progs.bat
```

### Continuous Sync (Watch Mode)
```bash
.\sync-to-docker-progs.bat watch
```

This keeps `E:\repos\easystream-main` and `E:\docker-progs\easystream-main` in sync automatically.

---

## 🔑 Production Setup

### 1. Generate Secrets
```powershell
.\generate-secrets.ps1
```

### 2. Configure Environment
```bash
copy .env.production .env
# Edit .env with your domain and settings
```

### 3. Deploy
```powershell
.\deploy.ps1 -Mode prod
```

---

## 🛠️ Common Commands

### View Logs
```bash
docker-compose logs -f          # All services
docker-compose logs -f php      # PHP only
docker-compose logs -f db       # Database only
```

### Check Status
```bash
docker-compose ps
docker-compose top
```

### Restart Service
```bash
docker-compose restart php
docker-compose restart caddy
```

### Stop Everything
```bash
docker-compose down
```

### Database Access
```bash
docker-compose exec db mysql -u easystream -peasystream easystream
```

### Backup Database
```bash
docker-compose exec db mysqldump -u easystream -peasystream easystream | gzip > backup.sql.gz
```

---

## 🎥 Streaming Setup

### RTMP URL (for OBS/Streaming Software)
```
Server: rtmp://localhost:1935/live
Stream Key: testkey
```

### View Live Stream
```
HLS: http://localhost:8083/hls/testkey/index.m3u8
```

---

## 📊 What's Included

- ✅ **270+ Database Tables** - Full schema auto-loaded
- ✅ **Default Admin Account** - Ready to use
- ✅ **10 Categories** - Pre-configured
- ✅ **Template Builder** - 7 pre-built components
- ✅ **RTMP + HLS Streaming** - Live streaming ready
- ✅ **Redis Caching** - Performance optimized
- ✅ **Queue System** - Background job processing
- ✅ **Cron Jobs** - Automated tasks

---

## 🔍 Troubleshooting

### Port Already in Use
```bash
# Change port in docker-compose.yml
ports:
  - "8084:80"  # Change 8083 to 8084
```

### Database Not Ready
```bash
# Check health
docker-compose ps

# View initialization progress
docker-compose logs -f db
```

### Upload Not Working
```bash
# Check permissions
docker-compose exec php ls -la /srv/easystream/f_data/uploads

# Fix if needed
docker-compose exec php chown -R www-data:www-data /srv/easystream/f_data
```

---

## 📚 Full Documentation

- **[DOCKER_DEPLOYMENT_GUIDE.md](DOCKER_DEPLOYMENT_GUIDE.md)** - Complete deployment guide
- **[TEMPLATE_BUILDER_GUIDE.md](TEMPLATE_BUILDER_GUIDE.md)** - Template builder documentation
- **[DESIGN_SYSTEM_GUIDE.md](DESIGN_SYSTEM_GUIDE.md)** - Design system usage

---

## ⚠️ Security Checklist

Before going to production:

- [ ] Change default admin password
- [ ] Generate secure secrets (`.\generate-secrets.ps1`)
- [ ] Update `.env` with production values
- [ ] Enable HTTPS/SSL
- [ ] Change database password
- [ ] Configure firewall rules
- [ ] Set up backups
- [ ] Review [DOCKER_DEPLOYMENT_GUIDE.md](DOCKER_DEPLOYMENT_GUIDE.md#security-checklist)

---

## 🆘 Need Help?

1. Check logs: `docker-compose logs -f`
2. Verify services: `docker-compose ps`
3. Review: [DOCKER_DEPLOYMENT_GUIDE.md](DOCKER_DEPLOYMENT_GUIDE.md#troubleshooting)
4. Test configuration: `.\deploy.ps1 -Mode test`

---

**Version**: 2.0 | **Last Updated**: 2025-10-25
