# 📋 DEPLOYMENT CHECKLIST - TRACKER SYSTEM

## ✅ LOCAL DEVELOPMENT STATUS

### **Phase 1: Core Setup** ✅
- [x] PCMonitorAgent service installed on Windows
- [x] EnvironmentHelper singleton configured
- [x] Dual-environment support (localhost + webhost)
- [x] .env.local configuration
- [x] .env.webhost configuration
- [x] Database schema created (15+ tables)
- [x] API routes configured
- [x] Dashboard basic structure

### **Phase 2: Bug Fixes** ✅
- [x] PCMonitorAgent service path fixed
- [x] Dashboard controllers Config.php includes fixed
- [x] Agent data filter bug removed (WHERE is_active=TRUE)
- [x] .htaccess RewriteBase paths removed
- [x] Environment detection working

### **Phase 3: Feature Implementation** ✅
- [x] **FITUR #1: SCREEN MIRROR**
  - [x] ScreenshotController.php (186 lines) ✅
  - [x] screenshot.php view (145+ lines) ✅
  - [x] API endpoints configured
  - [x] /screenshots/ directory created
  - [x] Base64 encoding/decoding implemented
  - [x] Database integration complete

- [x] **FITUR #2: BANDWIDTH LIMITING**
  - [x] CommandController.php (throttleBandwidth method)
  - [x] bandwidth.php view
  - [x] Database: bandwidth_control table
  - [x] API endpoints ready

- [x] **FITUR #3: SHUTDOWN**
  - [x] CommandController.php (shutdownPC method)
  - [x] Remote commands queuing system
  - [x] Database: remote_commands table
  - [x] API endpoints ready

- [x] **FITUR #4: RUNNING APPLICATIONS**
  - [x] ApplicationsController.php (180+ lines) ✅
  - [x] applications.php view
  - [x] Database: running_applications table
  - [x] CPU/Memory monitoring implemented
  - [x] Process kill functionality ready

- [x] **FITUR #5: MEDIA SOCIAL DETECTION**
  - [x] MediaSocialController.php (150+ lines, full implementation)
  - [x] media-social.php view (just created!)
  - [x] Database: media_social_activity table
  - [x] 13 platforms detected (Facebook, Instagram, TikTok, etc)
  - [x] Multi-method detection (windows, browser, processes)

---

## 🚀 PHASE 4: DEPLOYMENT TO WEBHOST - READY TO START!

### **4.1 Upload Controller Files to Webhost**
```
Source: e:\xampp\htdocs\tracker\api\controllers\
Dest:   /home/lppmunu1/public_html/tracker.lppmunud.id/api/controllers/

Files to upload:
  ✅ ScreenshotController.php
  ✅ ApplicationsController.php
  ✅ MediaSocialController.php
  ✅ CommandController.php (update with new methods)
  ✅ ActivityController.php (update with new routes)
  ✅ AgentController.php
  ✅ ApplicationMonitorController.php
```

**Status:** ⏳ PENDING

---

### **4.2 Upload Dashboard Views to Webhost**
```
Source: e:\xampp\htdocs\tracker\dashboard\views\
Dest:   /home/lppmunu1/public_html/tracker.lppmunud.id/dashboard/views/

Files to upload:
  ✅ screenshot.php
  ✅ applications.php
  ✅ bandwidth.php
  ✅ media-social.php (NEW)
  ✅ dashboard.php (update with feature buttons)
  ✅ agents.php
  ✅ activities.php
```

**Status:** ⏳ PENDING

---

### **4.3 Update API Router**
```
File: api/index.php

Changes needed:
  1. Add ScreenshotController require:
     require_once 'controllers/ScreenshotController.php';

  2. Add ApplicationsController require:
     require_once 'controllers/ApplicationsController.php';

  3. Add MediaSocialController require:
     require_once 'controllers/MediaSocialController.php';

  4. Update handleScreenshot() routing
  5. Update handleActivity() routing for all features
  6. Update handleCommand() routing for all commands

  Current status: LOCALLY COMPLETE ✅
```

**Status:** ⏳ PENDING UPLOAD

---

### **4.4 Update Dashboard Router**
```
File: dashboard/index.php

Navigation links needed:
  - Home (dashboard.php)
  - Agents
  - 📺 Screen Mirror
  - 📦 Running Applications
  - 📱 Media Social Detection
  - 🚫 Bandwidth Control
  - 📋 Activities
  - Settings
```

**Status:** ⏳ TODO

---

### **4.5 Create Required Directories**
```
/home/lppmunu1/public_html/tracker.lppmunud.id/

Directories:
  [x] /screenshots/              ← For screenshot storage
  [x] /screenshots/{agent_id}/   ← Per-agent folders
  [x] /media-files/              ← For media storage
  [x] /database/                 ← For DB backups
  [x] /logs/                     ← For logging
```

**Status:** ⏳ PENDING

---

### **4.6 Database Schema Updates**
```
Database: lppmunu1_tracker@tracker.lppmunud.id

Ensure these tables exist:
  ✅ agents
  ✅ screenshots
  ✅ running_applications
  ✅ media_social_activity
  ✅ remote_commands
  ✅ bandwidth_control
  ✅ pc_activities
  ✅ activity_log
```

**Status:** ⏳ VERIFY & UPDATE

---

### **4.7 File Permissions** 

```
Linux permissions needed:
  /screenshots/          - 755 (directories), 644 (files)
  /media-files/          - 755 (directories), 644 (files)
  /logs/                 - 755
  api/                   - 755
  dashboard/             - 755
  config/.env.webhost    - 600 (readable only)
```

**Status:** ⏳ TODO

---

## 🔨 PHASE 5: AGENT C# IMPLEMENTATION

### **5.1 Screenshot Capture Service**
```
File: agent-csharp/Services/ScreenshotService.cs (NEW)

Tasks:
  - [ ] Capture screenshot every 30 seconds
  - [ ] Convert to base64
  - [ ] Send to POST /api/screenshot
  - [ ] Handle retry logic
  - [ ] Error handling

Implementation notes:
  - Use System.Drawing.Bitmap
  - Use Graphics class for capture
  - Compress using PNG format
```

**Status:** ⏳ NOT STARTED

---

### **5.2 Application Monitoring Service**
```
File: agent-csharp/Services/RunningAppsService.cs (NEW)

Tasks:
  - [ ] Get list of running processes every 60 sec
  - [ ] Get CPU usage per process
  - [ ] Get memory usage per process
  - [ ] Get window titles
  - [ ] Get process paths
  - [ ] Send to POST /api/activity (action=update_processes)
  - [ ] Handle process filtering

Implementation notes:
  - Use System.Diagnostics.Process
  - Use PerformanceCounter for CPU/Memory
  - Use Windows API for window titles
```

**Status:** ⏳ NOT STARTED

---

### **5.3 Media Social Detection Service**
```
File: agent-csharp/Services/MediaSocialDetectionService.cs (NEW)

Tasks:
  - [ ] Scan active windows every 120 seconds
  - [ ] Get list of open browser tabs
  - [ ] Get list of running processes
  - [ ] Match against platform keywords
  - [ ] Calculate duration
  - [ ] Send to POST /api/activity (action=detect_media_social)
  - [ ] Track previous detections

Detection targets:
  - Facebook, Instagram, TikTok, Twitter, YouTube
  - WhatsApp, Telegram, Discord, LinkedIn, Snapchat, Viber, LINE, Gmail

Implementation notes:
  - Use Windows API for window enumeration
  - Use browser automation APIs (Selenium/etc) for tab detection
  - Regex matching for keywords
  - Store local session database
```

**Status:** ⏳ NOT STARTED

---

### **5.4 Bandwidth Limiting Service**
```
File: agent-csharp/Services/BandwidthLimiterService.cs (NEW)

Tasks:
  - [ ] Poll /api/command for throttle_bandwidth commands
  - [ ] Execute bandwidth limiting
  - [ ] Track bandwidth usage
  - [ ] Restore full bandwidth on command

Implementation notes:
  - Use NetLimiter API or similar
  - Or use Windows QoS Group Policy
  - Or use WMI for bandwidth management
  - Monitor current bandwidth usage
```

**Status:** ⏳ NOT STARTED

---

### **5.5 Shutdown Command Handler**
```
File: agent-csharp/Services/ShutdownCommandService.cs (NEW)

Tasks:
  - [ ] Poll /api/command for shutdown commands
  - [ ] Execute shutdown with delay
  - [ ] Log shutdown execution
  - [ ] Handle force shutdown flag

Implementation notes:
  - Use Process.Start("shutdown.exe", "/s /t {delay}")
  - Use RegexMatch to parse parameters
  - Log to local database
```

**Status:** ⏳ NOT STARTED

---

## 🧪 PHASE 6: INTEGRATION TESTING

### **6.1 Local Testing** ⏳
- [ ] Start PCMonitorAgent service locally
- [ ] Test /api/screenshot endpoint
  - POST screenshot
  - GET latest screenshot
  - GET history
  - DELETE screenshot
- [ ] Test /api/activity endpoint
  - POST update_processes
  - POST detect_media_social
  - GET all activities
- [ ] Test /api/command endpoint
  - POST shutdown
  - POST throttle_bandwidth
- [ ] Verify data in dashboard

---

### **6.2 Webhost Testing** ⏳
- [ ] Upload all files to tracker.lppmunud.id
- [ ] Configure PCMonitorAgent to point to webhost API
- [ ] Test API connectivity from agent
- [ ] Verify data flowing to webhost database
- [ ] Test dashboard displays all features
- [ ] Test screenshot viewing
- [ ] Test bandwidth control buttons
- [ ] Test app monitoring
- [ ] Test media social detection

---

### **6.3 Load Testing** ⏳
- [ ] Test with multiple agents
- [ ] Test screenshot storage performance
- [ ] Test database query performance
- [ ] Monitor server resources
- [ ] Test concurrent screenshot uploads

---

### **6.4 Security Testing** ⏳
- [ ] Verify API authentication
- [ ] Test SQL injection prevention
- [ ] Test file upload security
- [ ] Test CSV download security
- [ ] Test permission boundaries

---

## 🎯 PHASE 7: OPTIMIZATION & PRODUCTION

### **7.1 Performance Optimization**
- [ ] Add database indexes
  ```sql
  CREATE INDEX idx_agent_id ON screenshots(agent_id);
  CREATE INDEX idx_detected_at ON media_social_activity(detected_at);
  CREATE INDEX idx_timestamp ON running_applications(snapshot_at);
  ```
- [ ] Compress screenshot files
- [ ] Implement caching layer
- [ ] Add rate limiting on API endpoints
- [ ] Optimize dashboard queries

---

### **7.2 Data Cleanup & Maintenance**
- [ ] Create auto-cleanup cronjob (7-day retention for screenshots)
  ```php
  // cron/cleanup.php
  DELETE FROM screenshots WHERE captured_at < DATE_SUB(NOW(), INTERVAL 7 DAY);
  DELETE FROM media_social_activity WHERE detected_at < DATE_SUB(NOW(), INTERVAL 30 DAY);
  DELETE FROM running_applications WHERE snapshot_at < DATE_SUB(NOW(), INTERVAL 7 DAY);
  ```
- [ ] Archive old data
- [ ] Backup strategy

---

### **7.3 Security Hardening**
- [ ] Encrypt screenshots at-rest
- [ ] Add HTTPS SSL certificate
- [ ] Implement API key verification
- [ ] Add audit logging
- [ ] Rate limiting on API
- [ ] DDoS protection

---

### **7.4 Monitoring & Alerting**
- [ ] Setup uptime monitoring
- [ ] Setup error alerting
- [ ] Monitor API response times
- [ ] Monitor database performance
- [ ] Setup log aggregation

---

### **7.5 Documentation**
- [ ] API documentation
- [ ] User manual
- [ ] Admin guide
- [ ] Troubleshooting guide
- [ ] Installation guide

---

## 📊 SUMMARY CHECKLIST

| Phase | Status | Progress |
|-------|--------|----------|
| Phase 1: Core Setup | ✅ DONE | 100% |
| Phase 2: Bug Fixes | ✅ DONE | 100% |
| Phase 3: Features | ✅ DONE | 100% |
| Phase 4: Deployment | ⏳ READY | 0% (ready to start!) |
| Phase 5: Agent C# | ⏳ NOT STARTED | 0% |
| Phase 6: Testing | ⏳ NOT STARTED | 0% |
| Phase 7: Production | ⏳ NOT STARTED | 0% |

---

## 🎬 IMMEDIATE NEXT STEPS

### **Priority 1: DEPLOYMENT (Next 2-3 hours)**
1. [ ] Upload all controller files to webhost
2. [ ] Upload all view files to webhost
3. [ ] Update api/index.php routing
4. [ ] Create required directories
5. [ ] Set proper file permissions
6. [ ] Test API endpoints from webhost

### **Priority 2: AGENT IMPLEMENTATION (Next 8-16 hours)**
1. [ ] Create ScreenshotService.cs
2. [ ] Create RunningAppsService.cs
3. [ ] Create MediaSocialDetectionService.cs
4. [ ] Create BandwidthLimiterService.cs
5. [ ] Create ShutdownCommandService.cs

### **Priority 3: INTEGRATION TESTING (Next 4-6 hours)**
1. [ ] Test all features on webhost
2. [ ] Verify data flow end-to-end
3. [ ] Fix any issues

---

## ⚡ QUICK DEPLOYMENT COMMANDS

```bash
# 1. Upload controllers
scp -r api/controllers/* user@tracker.lppmunud.id:/home/lppmunu1/public_html/tracker.lppmunud.id/api/controllers/

# 2. Upload views
scp -r dashboard/views/* user@tracker.lppmunud.id:/home/lppmunu1/public_html/tracker.lppmunud.id/dashboard/views/

# 3. Create directories
ssh user@tracker.lppmunud.id mkdir -p /home/lppmunu1/public_html/tracker.lppmunud.id/screenshots/{agent_ids}
ssh user@tracker.lppmunud.id mkdir -p /home/lppmunu1/public_html/tracker.lppmunud.id/media-files

# 4. Set permissions
ssh user@tracker.lppmunud.id chmod -R 755 /home/lppmunu1/public_html/tracker.lppmunud.id/screenshots
ssh user@tracker.lppmunud.id chmod -R 755 /home/lppmunu1/public_html/tracker.lppmunud.id/media-files

# 5. Verify
curl -X GET http://tracker.lppmunud.id/api/agents
curl -X POST http://tracker.lppmunud.id/api/test
```

---

## 📞 SUPPORT & TROUBLESHOOTING

### **Common Issues:**

**API not responding**
- Check if controllers uploaded correctly
- Verify api/index.php updated with requires
- Check file permissions
- Review error logs

**Webhost database connection fails**
- Verify .env.webhost configured
- Check database credentials
- Verify EnvironmentHelper auto-detection
- Test: php test-env.php

**Screenshots not displaying**
- Verify /screenshots/ directory exists
- Check file permissions on screenshots directory
- Verify base64 encoding/decoding
- Check database screenshot records

**Agent not sending data**
- Verify PCMonitorAgent is running
- Check network connectivity
- Verify agent is pointing to webhost API
- Test: curl to /api/test endpoint

---

**Last Updated:** 2026-03-28  
**Prepared By:** Tracker Development Team  
**Status:** Ready for Phase 4 Deployment ✅

