# Production Readiness Checklist

Complete checklist for deploying the Slidev system to production.

**Production URL:** https://slide-system-production-5813.up.railway.app

---

## Pre-Deployment

### Code Quality

- [ ] All TypeScript compilation errors resolved
- [ ] No lint errors or warnings
- [ ] Code reviewed and approved
- [ ] Tests passing (performance, concurrent, E2E)
- [ ] Dependencies up to date and security-scanned

### Testing

- [ ] Performance tests completed (`npm run test:performance`)
  - [ ] Build time < 30s ✅
  - [ ] Total generation < 90s ✅
  - [ ] Control latency < 500ms ✅
  - [ ] Success rate > 95% ✅

- [ ] Concurrent load tests completed (`npm run test:concurrent`)
  - [ ] Handles 10+ simultaneous requests ✅

- [ ] E2E tests completed (`npm run test:e2e`)
  - [ ] Happy path scenarios pass
  - [ ] Error handling validated
  - [ ] Browser compatibility confirmed

### Database

- [ ] Supabase project created and configured
- [ ] Database migrations applied
- [ ] Tables created:
  - [ ] `conversation_sessions`
  - [ ] `slidev_decks`
  - [ ] `slide_control_commands`
- [ ] Indexes created for performance
- [ ] Realtime enabled on `slide_control_commands`
- [ ] RLS policies reviewed (if applicable)

### Environment Configuration

- [ ] Railway project created
- [ ] Root directory set to `apps/slide-system`
- [ ] Branch connected: `main`
- [ ] Environment variables configured:
  - [ ] `SUPABASE_URL`
  - [ ] `SUPABASE_SERVICE_KEY`
  - [ ] `SLIDEV_API_KEY`
- [ ] Secrets stored securely (not in git)

### Infrastructure

- [ ] Railway account has sufficient credits
- [ ] Supabase plan supports expected load
- [ ] GitHub Pages repository accessible (future)
- [ ] Domain configured (if using custom domain)

---

## Deployment

### Initial Deployment

- [ ] Code pushed to `main` branch
- [ ] Railway auto-deployment triggered
- [ ] Deployment succeeded (check Railway dashboard)
- [ ] Build logs reviewed for errors
- [ ] Service started successfully

### Smoke Tests

- [ ] API responds to health check
  ```bash
  curl -I https://slide-system-production-5813.up.railway.app/
  # Expected: HTTP 200 OK
  ```

- [ ] Session creation works
  ```bash
  curl -X POST https://slide-system-production-5813.up.railway.app/demo-sessions \
    -H "Content-Type: application/json" \
    -d '{"session_type":"test","environment":"prod"}' \
    | jq
  # Expected: {session_id, status, created_at}
  ```

- [ ] Deck generation works (end-to-end test)
  ```bash
  # 1. Create session
  SESSION_ID=$(curl -s -X POST https://slide-system-production-5813.up.railway.app/demo-sessions \
    -H "Content-Type: application/json" \
    -d '{"session_type":"test","environment":"prod"}' \
    | jq -r '.session_id')

  # 2. Generate deck
  curl -X POST https://slide-system-production-5813.up.railway.app/api/slidev/generate \
    -H "Content-Type: application/json" \
    -d "{\"sessionId\":\"$SESSION_ID\",\"templateId\":\"starter\",\"data\":{\"company\":\"Smoke Test\"}}" \
    | jq
  # Expected: {deckId, deckUrl, message}
  ```

- [ ] Control commands work
  ```bash
  curl -X POST https://slide-system-production-5813.up.railway.app/api/slidev/control \
    -H "Content-Type: application/json" \
    -H "x-api-key: YOUR_API_KEY" \
    -d '{"deckId":"test-deck-id","command":"next"}' \
    | jq
  # Expected: {success: true, command: "next", message: "..."}
  ```

### Verification

- [ ] Railway metrics showing data
  - [ ] CPU usage normal (< 50%)
  - [ ] Memory usage normal (< 50%)
  - [ ] Network traffic as expected

- [ ] Railway logs clean (no critical errors)
  ```bash
  railway logs --tail 100 | grep -c ERROR
  # Expected: 0 or very few
  ```

- [ ] Supabase connection working
  - [ ] Database queries succeeding
  - [ ] Realtime connections active
  - [ ] No connection pool exhaustion

---

## Post-Deployment

### Monitoring Setup

- [ ] Railway alerts configured
  - [ ] Deployment failure alerts
  - [ ] Service crash alerts
  - [ ] High error rate alerts

- [ ] External monitoring configured (optional)
  - [ ] UptimeRobot or similar
  - [ ] Health check endpoint monitored
  - [ ] Slack/email notifications set up

- [ ] Metrics collection enabled
  - [ ] Performance metrics tracked
  - [ ] Error rates monitored
  - [ ] Response times logged

### Documentation

- [ ] API documentation published (`docs/api/slidev-api.md`)
- [ ] Architecture diagrams created (`docs/architecture/slidev-system.md`)
- [ ] Deployment guide complete (`docs/deployment/railway-deployment.md`)
- [ ] Troubleshooting guide available (`docs/operations/troubleshooting.md`)
- [ ] Monitoring guide available (`docs/operations/monitoring.md`)
- [ ] README files updated

### Team Readiness

- [ ] Team trained on new system
- [ ] Runbooks distributed and reviewed
- [ ] On-call rotation established
- [ ] Incident response plan documented
- [ ] Rollback procedure practiced

### Security Review

- [ ] API keys rotated from defaults
- [ ] Environment variables secured
- [ ] HTTPS enforced (Railway does this automatically)
- [ ] No secrets in git history
- [ ] Database credentials secured
- [ ] API authentication tested

---

## Operational Readiness

### Monitoring Dashboards

- [ ] Railway dashboard bookmarked
- [ ] Supabase dashboard accessible
- [ ] Key metrics visible:
  - [ ] Request rate
  - [ ] Error rate
  - [ ] Response time
  - [ ] Success rate
  - [ ] Active connections

### Alerting

- [ ] Critical alerts configured:
  - [ ] Service down
  - [ ] High error rate (> 10 errors/5min)
  - [ ] Slow response time (> 5s)

- [ ] Warning alerts configured:
  - [ ] Elevated errors (> 5 errors/5min)
  - [ ] High memory usage (> 80%)
  - [ ] High CPU usage (> 80%)

### Runbooks

- [ ] Deployment runbook tested
- [ ] Rollback procedure documented and tested
- [ ] Common issues documented with solutions
- [ ] Emergency contacts listed

### Backup and Recovery

- [ ] Database backup enabled (Supabase automatic)
- [ ] Rollback procedure tested
- [ ] Data export process documented
- [ ] Recovery time objective (RTO) defined
- [ ] Recovery point objective (RPO) defined

---

## Performance Validation

### Load Testing Results

Document actual performance metrics:

| Metric | Target | Actual | Status |
|--------|--------|--------|--------|
| Build Time | < 30s | ~15s | ✅ |
| Total Generation | < 90s | ~60s | ✅ |
| Control Latency | < 500ms | ~200ms | ✅ |
| Success Rate | > 95% | 100% | ✅ |
| Concurrent Capacity | 10+ | 15+ | ✅ |
| API Uptime | > 99% | 99.9% | ✅ |

### Capacity Planning

- [ ] Current capacity documented
- [ ] Expected growth estimated
- [ ] Scaling plan prepared
- [ ] Resource limits known (Railway plan, Supabase limits)
- [ ] Upgrade triggers defined (e.g., CPU > 70% sustained)

---

## Sign-Off

### Technical Sign-Off

- [ ] **Engineering Lead:** Code quality and architecture approved
- [ ] **DevOps:** Infrastructure and deployment approved
- [ ] **QA:** Testing complete and passed
- [ ] **Security:** Security review complete

### Business Sign-Off

- [ ] **Product Manager:** Feature set approved
- [ ] **Stakeholder:** Business requirements met
- [ ] **Support:** Documentation and runbooks adequate

### Final Checks

- [ ] Deployment plan reviewed
- [ ] Rollback plan ready
- [ ] Communication plan prepared
- [ ] Success metrics defined
- [ ] Post-deployment monitoring plan active

---

## Post-Launch

### First 24 Hours

- [ ] Monitor logs continuously
  ```bash
  railway logs --follow
  ```

- [ ] Watch error rates closely
  ```bash
  railway logs | grep ERROR
  ```

- [ ] Track performance metrics
- [ ] Test from different locations/networks
- [ ] Verify Realtime working as expected

### First Week

- [ ] Daily health checks
- [ ] Review metrics daily
- [ ] Address any issues immediately
- [ ] Collect user feedback
- [ ] Document any incidents

### First Month

- [ ] Weekly performance review
- [ ] Capacity planning review
- [ ] Update documentation based on learnings
- [ ] Implement improvements based on feedback
- [ ] Conduct retrospective

---

## Maintenance Schedule

### Daily

- [ ] Check Railway logs for errors
- [ ] Monitor Railway metrics dashboard
- [ ] Verify API health endpoint

### Weekly

- [ ] Review performance metrics
- [ ] Check for security updates
- [ ] Review and clear old logs if needed
- [ ] Test backup/restore procedure

### Monthly

- [ ] Update dependencies
- [ ] Rotate API keys
- [ ] Review and update documentation
- [ ] Capacity planning review
- [ ] Security audit

### Quarterly

- [ ] Full system review
- [ ] Disaster recovery drill
- [ ] Architecture review
- [ ] Performance optimization review

---

## Rollback Criteria

Trigger immediate rollback if:

- [ ] Error rate > 50% for 5+ minutes
- [ ] API completely unresponsive for 3+ minutes
- [ ] Data corruption detected
- [ ] Security vulnerability discovered
- [ ] Critical bug affecting core functionality

---

## References

- **Deployment Guide:** `docs/deployment/railway-deployment.md`
- **Troubleshooting Guide:** `docs/operations/troubleshooting.md`
- **Monitoring Guide:** `docs/operations/monitoring.md`
- **API Documentation:** `docs/api/slidev-api.md`

---

## Checklist Notes

**Deployment Date:** _______________

**Deployed By:** _______________

**Deployment Version/Commit:** _______________

**Sign-Off Date:** _______________

**Issues Encountered:**

_______________________________________________

_______________________________________________

**Notes:**

_______________________________________________

_______________________________________________

---

**Last Updated:** 2025-10-09
