# SPRINT 10.10 — PRODUCTION DEPLOYMENT

## METADATA
- Execution: Hodina 10
- Prerekvizity: Sprint 10.9 COMPLETE (E2E testy prošly)
- Deliverables: Production deploy na S3 + CloudFront, DNS setup
- Estimated time: 45-55 min
- Output folder: Deploy scripts + docs

## AWS ENVIRONMENT
```
AWS_ACCESS_KEY_ID=AKIA[REDACTED_SEE_AWS_CONSOLE]
AWS_SECRET_ACCESS_KEY=[REDACTED_SEE_SECRETS_MANAGER]
AWS_DEFAULT_REGION=us-east-1
CloudFront Distribution (skynet.genisys.online): E38SDADAYZHW29
S3 Bucket target: skymailbox.net (nebo skymailbox subfolder)
```

## OBJECTIVES
Deploy SkyMailbox na production:
1. Build React app s production API URLs
2. Upload do S3 bucket
3. CloudFront distribuce pro skymailbox.net
4. DNS A record → CloudFront
5. SSL certifikát (ACM)
6. Propojit se SKYNET ekosystémem (shared header link)
7. Update Blueprint + Sprint roadmap

## STEP-BY-STEP INSTRUCTIONS

### Krok 1: Production build
```bash
cd /mnt/outputs/SKYMAILBOX_SPRINTS/SPRINT_10.3_FRONTEND_SETUP/skymailbox

# Set production API URLs
cat > .env.production << 'EOF'
VITE_AUTH_API_URL=<auth lambda function url>
VITE_EMAIL_API_URL=<email lambda function url>
EOF

npm run build
```

### Krok 2: S3 bucket setup
```bash
# Create bucket (pokud neexistuje)
aws s3 mb s3://skymailbox.net --region us-east-1 2>/dev/null || true

# Enable static website hosting
aws s3 website s3://skymailbox.net \
  --index-document index.html \
  --error-document index.html

# Bucket policy pro veřejný přístup
aws s3api put-bucket-policy --bucket skymailbox.net --policy '{
  "Version": "2012-10-17",
  "Statement": [{
    "Sid": "PublicRead",
    "Effect": "Allow",
    "Principal": "*",
    "Action": "s3:GetObject",
    "Resource": "arn:aws:s3:::skymailbox.net/*"
  }]
}'
```

### Krok 3: Upload build output
```bash
# Upload s cache control
aws s3 sync dist/ s3://skymailbox.net/ \
  --delete \
  --cache-control "max-age=31536000" \
  --exclude "index.html" \
  --exclude "*.json"

# Upload index.html s no-cache
aws s3 cp dist/index.html s3://skymailbox.net/index.html \
  --content-type "text/html; charset=utf-8" \
  --cache-control "no-cache, no-store, must-revalidate"

# Upload manifest/json files
aws s3 cp dist/ s3://skymailbox.net/ \
  --recursive \
  --exclude "*" \
  --include "*.json" \
  --content-type "application/json" \
  --cache-control "no-cache"
```

### Krok 4: CloudFront distribuce
Pokud CloudFront distribuce pro skymailbox.net ještě neexistuje:
```bash
# Vytvořit distribuce
aws cloudfront create-distribution \
  --origin-domain-name skymailbox.net.s3-website-us-east-1.amazonaws.com \
  --default-root-object index.html \
  --query 'Distribution.{ID:Id,Domain:DomainName}'
```

Pokud existuje — pouze invalidovat cache:
```bash
DIST_ID=$(aws cloudfront list-distributions \
  --query "DistributionList.Items[?contains(Aliases.Items,'skymailbox.net')].Id" \
  --output text)

aws cloudfront create-invalidation \
  --distribution-id $DIST_ID \
  --paths "/*"
```

### Krok 5: DNS (Route53)
Zkontrolovat Route53 záznamy pro skymailbox.net:
```bash
ZONE_ID=$(aws route53 list-hosted-zones \
  --query "HostedZones[?Name=='skymailbox.net.'].Id" --output text | cut -d'/' -f3)

# List current records
aws route53 list-resource-record-sets --hosted-zone-id $ZONE_ID
```

Pokud A record chybí → vytvořit ALIAS na CloudFront distribuce.

### Krok 6: SSL certifikát
Ověřit ACM certifikát pro skymailbox.net:
```bash
aws acm list-certificates --region us-east-1 \
  --query "CertificateSummaryList[?contains(DomainName,'skymailbox')]"
```

### Krok 7: Update SKYNET ecosystem
1. Přidat link na skymailbox.net do skynet.genisys.online index.html navigace
2. Update Blueprint v6 s SkyMailbox info
3. Update sprints.html — W8 sprint jako "in progress" nebo "ready"

```bash
# Upload updated index.html
aws s3 cp index.html s3://skynet.genisys.online/index.html \
  --content-type "text/html; charset=utf-8"

aws cloudfront create-invalidation \
  --distribution-id E38SDADAYZHW29 \
  --paths "/index.html"
```

### Krok 8: Smoke test production
```bash
# Test main page loads
curl -s -o /dev/null -w "%{http_code}" https://skymailbox.net

# Test auth API
curl -s -X POST https://<auth-url>/register \
  -H "Content-Type: application/json" \
  -d '{"email":"prod-test@skymailbox.net","password":"ProdTest123!","username":"prodtest"}'

# Test email API
# (login first, get token, then test inbox)
```

### Krok 9: Completion documentation
Vytvořit finální dokumentaci:
- Architecture diagram (text-based)
- API endpoint reference
- Deployment runbook
- Known issues / limitations

## COMPLETION CHECKLIST
- [ ] Production build OK
- [ ] S3 bucket vytvořen a nakonfigurován
- [ ] Soubory uploadovány do S3
- [ ] CloudFront distribuce aktivní
- [ ] DNS nastaveno (skymailbox.net → CloudFront)
- [ ] SSL certifikát platný
- [ ] https://skymailbox.net načítá app
- [ ] Register flow funguje na production
- [ ] Login flow funguje na production
- [ ] Email send/receive funguje
- [ ] SKYNET ecosystem links updatovány
- [ ] Blueprint/Sprint roadmap updatován
- [ ] Smoke test prošel

## DELIVERABLES LIST
1. `deploy_frontend.sh` — deployment script
2. `SPRINT_10.10_README.md` — deployment runbook
3. `ARCHITECTURE.md` — final architecture overview
4. `SPRINT_10.10_COMPLETE.md` — completion report
5. `WATERFALL_COMPLETE.md` — celkový waterfall completion report

## COMPLETION REPORT TEMPLATE
```markdown
# ✅ SPRINT 10.10 — DEPLOYMENT — COMPLETE

## Timestamp
[ISO datetime]

## Production URLs
- Frontend: https://skymailbox.net
- Auth API: [Lambda Function URL]
- Email API: [Lambda Function URL]

## AWS Resources Created
| Resource | ID/ARN |
|----------|--------|
| S3 Bucket | skymailbox.net |
| CloudFront | [distribution ID] |
| Lambda (auth) | skymailbox-auth |
| Lambda (email) | skymailbox-email |
| DynamoDB (users) | skymailbox-users |
| DynamoDB (emails) | skymailbox-emails |

## Smoke Test
- Homepage loads: PASS/FAIL
- Register: PASS/FAIL
- Login: PASS/FAIL
- Send email: PASS/FAIL
- Read email: PASS/FAIL

## SKYNET Integration
- Index.html link: ADDED/PENDING
- Blueprint updated: YES/NO
- Sprint roadmap: UPDATED/PENDING

## Known Issues
[List any remaining issues]

## 🎉 WATERFALL COMPLETE
All 10 sprints finished. SkyMailbox is live!
```

---

# 🎉 WATERFALL COMPLETE TEMPLATE

Po dokončení tohoto sprintu vytvořit `WATERFALL_COMPLETE.md`:

```markdown
# 🎉 SKYMAILBOX WATERFALL — ALL SPRINTS COMPLETE

## Summary
10/10 sprints completed successfully.
SkyMailbox email client is live at https://skymailbox.net

## Timeline
| Sprint | Name | Status | Duration |
|--------|------|--------|----------|
| 10.1 | Auth Backend | ✅ COMPLETE | ~Xmin |
| 10.2 | Email API | ✅ COMPLETE | ~Xmin |
| 10.3 | Frontend Setup | ✅ COMPLETE | ~Xmin |
| 10.4 | Login UI | ✅ COMPLETE | ~Xmin |
| 10.5 | Inbox UI | ✅ COMPLETE | ~Xmin |
| 10.6 | Email Reader | ✅ COMPLETE | ~Xmin |
| 10.7 | Compose Email | ✅ COMPLETE | ~Xmin |
| 10.8 | Folders & Search | ✅ COMPLETE | ~Xmin |
| 10.9 | Integration | ✅ COMPLETE | ~Xmin |
| 10.10 | Deployment | ✅ COMPLETE | ~Xmin |

## Architecture
- Frontend: React + Vite + Tailwind → S3 + CloudFront
- Auth API: Lambda (Python 3.11) + DynamoDB
- Email API: Lambda (Python 3.11) + DynamoDB + SES
- Domain: skymailbox.net

## Total Files Created
[count]

## Next Steps
- Integrate with SKYNET SSO (cross-domain JWT)
- Add Hugh AI widget
- Implement GENOM encoding for emails
- Mobile responsive improvements
- QuickMailbox temp email feature
```
