# 🚀 LOOPUMAN LAUNCH - COMPLETE STEP-BY-STEP GUIDE

**Ray - Follow these steps exactly. Everything will work.**

---

## 📋 PRE-LAUNCH CHECKLIST

**You need:**
- [ ] Downloaded the ZIP package
- [ ] Oracle Cloud server access (145.241.213.91)
- [ ] SSH key file (loopuman-micro-ssh.key)
- [ ] Your Telegram ID (find by messaging @userinfobot)
- [ ] Platform wallet funded (at least $100 cUSD)

---

## 🎯 STEP 1: CONFIGURE LOCALLY (10 MINUTES)

### **1.1 Extract Package**
```bash
# On your Windows machine
unzip LOOPUMAN-LAUNCH-READY-20260114.zip
cd LAUNCH
```

### **1.2 Create .env File**
```bash
# Copy example
cp .env.example .env

# Edit with your keys
# Use Notepad or VS Code
notepad .env
```

### **1.3 Fill in ALL These Values:**

```env
# ═══════════════════════════════════════════
# CRITICAL - MUST FILL THESE
# ═══════════════════════════════════════════

# Your Telegram ID (message @userinfobot to get it)
YOUR_TELEGRAM_ID=123456789  # ← CHANGE THIS

# Supabase
SUPABASE_URL=https://your-project.supabase.co
SUPABASE_SERVICE_KEY=eyJhbGc...your-key-here

# Telegram Bots
TELEGRAM_BOT_TOKEN=7123456789:AAH...your-bot-token
TELEGRAM_ADMIN_TOKEN=7987654321:AAH...your-admin-bot-token

# WhatsApp
WA_ACCESS_TOKEN=EAAxxxx...your-whatsapp-token
WA_PHONE_NUMBER_ID=123456789012345
WA_VERIFY_TOKEN=loopuman_verify_token

# Celo Blockchain (CRITICAL!)
TREASURY_PRIVATE_KEY=REDACTED_ROTATE_THIS_KEY
TREASURY_ADDRESS=0x9F52C166c90567B7F9906c6319ef90aF4F516856

# Stripe
STRIPE_SECRET_KEY=sk_test_REDACTED  # Use test key first
STRIPE_WEBHOOK_SECRET=whsec_REDACTED

# Google AI (for AI agents)
GOOGLE_API_KEY=AIzaSy...your-google-key

# ═══════════════════════════════════════════
# OPTIONAL - Can skip for now
# ═══════════════════════════════════════════

# DeepSeek (backup AI)
DEEPSEEK_API_KEY=sk-...

# AWS (for Nova Micro moderation)
AWS_ACCESS_KEY_ID=AKIA...
AWS_SECRET_ACCESS_KEY=...
AWS_REGION=us-east-1

# Website
WEBSITE_URL=https://loopuman.com

# AI Agents
AI_AGENTS_ENABLED=true
```

**Save and close .env file** ✅

---

## 🎯 STEP 2: PUSH TO GITHUB (2 MINUTES)

### **2.1 Initialize Git (if not already done)**
```bash
# In Windows terminal (in LAUNCH folder)
cd LAUNCH
git init
git add .
git commit -m "Loopuman production ready - complete package"
```

### **2.2 Connect to Your Private GitHub Repo**

**Your repo:** `seesayearn-boop/loopuman-backend`

```bash
# Add remote (if not already added)
git remote add origin https://github.com/seesayearn-boop/loopuman-backend.git

# Or if remote exists, just push
git push origin master
```

**If you get authentication error:**
- Use GitHub Personal Access Token as password
- Or update: `git remote set-url origin https://YOUR_TOKEN@github.com/seesayearn-boop/loopuman-backend.git`

### **2.3 Verify on GitHub**

Go to: https://github.com/seesayearn-boop/loopuman-backend

**Should see:**
- ✅ telegram-bot.js
- ✅ whatsapp-bot.js
- ✅ enterprise-api.js
- ✅ ai-agents.js
- ✅ All other files
- ❌ .env (should NOT be there - in .gitignore)

---

## 🎯 STEP 3: DEPLOY TO ORACLE CLOUD (5 MINUTES)

### **3.1 Connect to Server**
```bash
# Windows terminal
ssh -i %USERPROFILE%\Downloads\loopuman-micro-ssh.key ubuntu@145.241.213.91
```

**Server details:**
- IP: 145.241.213.91
- User: ubuntu
- Key: loopuman-micro-ssh.key

### **3.2 Pull Latest Code**

```bash
# On Oracle server
cd ~/loopuman-backend

# Backup current version
cp -r ~/loopuman-backend ~/loopuman-backup-$(date +%Y%m%d)

# Pull latest from GitHub
git pull origin master
```

**If first time cloning:**
```bash
cd ~
git clone https://github.com/seesayearn-boop/loopuman-backend.git
cd loopuman-backend
```

### **3.3 Install Dependencies**
```bash
npm install
```

### **3.4 Setup .env File**

**Copy your .env from Windows to server:**

**Option A: Manual (secure)**
```bash
# On server
nano .env
# Paste contents from your Windows .env file
# Save: Ctrl+O, Enter, Ctrl+X
```

**Option B: SCP upload (from Windows)**
```bash
# From Windows terminal
scp -i %USERPROFILE%\Downloads\loopuman-micro-ssh.key LAUNCH/.env ubuntu@145.241.213.91:~/loopuman-backend/
```

---

## 🎯 STEP 3: DATABASE SETUP (5 MINUTES)

### **3.1 Run Migrations in Supabase**

**Go to:** https://supabase.com/dashboard

**Navigate to:** SQL Editor

**Run these files in order:**

**File 1: database/schema.sql**
```sql
-- Copy entire contents of database/schema.sql
-- Paste into SQL Editor
-- Click "Run"
-- Wait for success ✅
```

**File 2: reviews-system.sql**
```sql
-- Copy entire contents of reviews-system.sql
-- Paste into SQL Editor
-- Click "Run"
-- Wait for success ✅
```

**Verify tables exist:**
```sql
SELECT table_name 
FROM information_schema.tables 
WHERE table_schema = 'public' 
ORDER BY table_name;
```

**Should see:**
- app_users
- tasks
- task_acceptances
- task_submissions
- reviews (NEW)
- vae_balances
- withdrawals
- worker_badges
- etc.

---

## 🎯 STEP 4: DEPLOY SERVICES (5 MINUTES)

### **4.1 Install Dependencies**
```bash
cd ~/loopuman-backend
npm install
```

### **4.2 Make Scripts Executable**
```bash
chmod +x *.sh
```

### **4.3 Deploy All Services**
```bash
./deploy.sh
```

**Should see:**
```
✅ Dependencies installed
✅ Services stopped
✅ Services started
✅ PM2 saved

┌─────┬────────────────┬─────────┬─────────┐
│ id  │ name           │ status  │ restart │
├─────┼────────────────┼─────────┼─────────┤
│ 0   │ telegram-bot   │ online  │ 0       │
│ 1   │ whatsapp-bot   │ online  │ 0       │
│ 2   │ admin-bot      │ online  │ 0       │
│ 3   │ scheduler      │ online  │ 0       │
│ 4   │ ai-agents      │ online  │ 0       │
└─────┴────────────────┴─────────┴─────────┘
```

**Check logs:**
```bash
pm2 logs --lines 20
```

**Should see:** All services connecting successfully

---

## 🎯 STEP 5: SETUP TEST ENVIRONMENT (2 MINUTES)

### **5.1 Start Telegram Bot**

**On your phone:**
1. Open Telegram
2. Search: @Loopuman_bot (or your bot username)
3. Send: `/start`
4. Bot should respond with menu

### **5.2 Add Test Credits & Tasks**
```bash
cd ~/loopuman-backend
./setup-test-environment.sh
```

**This will:**
- ✅ Add Ⓥ100,000 ($1,000) to your requester balance
- ✅ Add Ⓥ5,000 ($50) to your worker balance
- ✅ Create 20 test tasks (mix of AI-eligible and human-only)

**Output should show:**
```
✅ Found user: 12345678...
✅ Added credits
✅ Created 20 test tasks
```

---

## 🎯 STEP 6: TEST ALL FEATURES (30 MINUTES)

### **✅ TEST 1: Browse & Accept Task (Telegram)**

1. Open Telegram → @Loopuman_bot
2. Click "Browse Tasks"
3. Should see 20 test tasks
4. Click on one (e.g., "Write 3 product descriptions")
5. Click "✅ Accept Task"
6. Complete it with any text
7. Click "Submit"
8. ✅ **PASS:** Task submitted

---

### **✅ TEST 2: WhatsApp Immediate Menu**

1. Open WhatsApp
2. Message: +254702632772 (your WhatsApp number)
3. Send ANY message (e.g., "test")
4. ✅ **PASS:** Menu appears IMMEDIATELY (no "hi" required)

---

### **✅ TEST 3: Review & Approve (WhatsApp)**

1. In WhatsApp bot
2. Click "Review Submissions"
3. Should see your submission from Test 1
4. Click "Approve" or "Reject"
5. Rate worker 1-5 stars
6. ✅ **PASS:** Two-way reviews working

---

### **✅ TEST 4: Withdraw $1 (Telegram)**

1. Telegram → @Loopuman_bot
2. Click "Wallet"
3. Click "Withdraw"
4. Enter: `100` (Ⓥ100 = $1)
5. Choose: USDC or USDT or cUSD
6. Enter your Celo wallet address
7. Click "Confirm"
8. Wait 8 seconds
9. Check wallet
10. ✅ **PASS:** USDC arrived in wallet

---

### **✅ TEST 5: Stripe Payment (Test Mode)**

1. WhatsApp → "Buy VAE"
2. Choose amount (e.g., $6 minimum)
3. Click payment link
4. Use test card: `4242 4242 4242 4242`
5. Expiry: Any future date (e.g., 12/28)
6. CVC: Any 3 digits (e.g., 123)
7. Complete payment
8. Check balance in WhatsApp
9. ✅ **PASS:** VAE credited

---

### **✅ TEST 6: AI Agents Accept Tasks**

1. Wait 2-3 hours (AI waits 1-3 hours for multi-worker tasks)
2. Check Telegram bot → Browse Tasks
3. Some tasks should show "Accepted by: Maria Santos" (AI agent)
4. Check logs: `pm2 logs ai-agents`
5. Should see: "AI Agent 'Maria Santos' accepted task..."
6. ✅ **PASS:** AI agents working

**To speed up testing:**
```bash
# Edit ai-agents.js temporarily
# Change wait time from 60-180 min to 1-3 min
# Then restart: pm2 restart ai-agents
```

---

### **✅ TEST 7: Ask Question Feature**

1. Telegram → Browse Tasks → Select task
2. Click "❓ Ask Question"
3. Type question (e.g., "Is this still available?")
4. Send
5. Requester should receive notification (check admin bot)
6. ✅ **PASS:** Questions working

---

### **✅ TEST 8: Support Tickets**

1. Telegram → Menu → "Support"
2. Describe issue
3. Submit ticket
4. Check admin bot for notification
5. ✅ **PASS:** Support system working

---

### **✅ TEST 9: On-Chain Reputation**

1. Complete 10 tasks as worker
2. Check Supabase → worker_badges table
3. Should see badge milestone
4. Check CeloScan: https://celoscan.io/address/YOUR_WALLET
5. Look for contract interactions
6. ✅ **PASS:** Badges recorded

**Note:** Full on-chain writes need the reputation service deployed (optional for launch)

---

### **✅ TEST 10: GPS Verification (Local Tasks)**

1. Create local task (WhatsApp)
2. Worker accepts (Telegram)
3. Worker submits with location
4. System verifies within radius
5. ✅ **PASS:** GPS working

---

## 🎯 STEP 7: INVITE FRIEND TO TEST (10 MINUTES)

### **7.1 Send Invitation**

**Message your friend:**
```
Hey! I'm launching my platform Loopuman.

Want to test? You can:
- Complete tasks and earn money instantly
- Get paid in USDC (real crypto) in 8 seconds
- Withdraw from $1 minimum

Try it:
1. Telegram: @Loopuman_bot
2. Click /start
3. Browse tasks and complete one
4. Withdraw instantly

Let me know what you think!
```

### **7.2 Monitor Friend's Experience**

```bash
# Watch logs
pm2 logs telegram-bot --lines 100

# Check database
# Supabase → Table Editor → app_users
# Should see friend's account created
```

### **7.3 Fix Issues in Real-Time**

**Common issues:**
- Bot not responding → `pm2 restart telegram-bot`
- Withdrawal failed → Check platform wallet balance
- Task not showing → Check task status in database

---

## 🎯 STEP 8: MONITOR & OPTIMIZE (ONGOING)

### **8.1 Daily Checks**

```bash
# Check services status
pm2 status

# Check logs for errors
pm2 logs | grep -i error

# Check platform wallet balance
# https://celoscan.io/address/0x9F52C166...

# Check Stripe dashboard
# https://dashboard.stripe.com/test/payments
```

### **8.2 Weekly Tasks**

- Review user feedback
- Check task completion rates
- Monitor AI agent quality
- Refill platform wallet if < $100
- Review dispute resolutions

---

## 🎯 STEP 9: SWITCH TO LIVE MODE (WHEN READY)

### **9.1 Stripe Live Mode**

1. Go to Stripe dashboard
2. Switch from Test → Live mode
3. Get live API keys
4. Update .env:
   ```env
   STRIPE_SECRET_KEY=sk_live_REDACTED
   STRIPE_WEBHOOK_SECRET=whsec_live_REDACTED
   ```
5. Restart: `pm2 restart all`

### **9.2 Verify Live Payments**

1. Make real $6 deposit
2. Verify credits appear
3. Test real withdrawal
4. ✅ All working → Live!

---

## 🎯 STEP 10: PUBLIC LAUNCH (1 DAY)

### **10.1 Morning: Soft Launch**

**Post on Twitter:**
```
Introducing Loopuman 🚀

The fastest way to get work done:
• Post task in WhatsApp
• Workers complete in minutes
• Pay instantly in crypto

Starting at $0.50 per task.
No minimum withdrawal ($1+).
Payment in 8 seconds.

Try it: t.me/Loopuman_bot
```

**Post on Reddit:**
- r/beermoney
- r/WorkOnline
- r/SideHustle

### **10.2 Afternoon: Monitor**

- Watch for signups
- Respond to questions
- Fix bugs immediately
- Monitor logs constantly

### **10.3 Evening: Iterate**

- Collect feedback
- Make quick fixes
- Prepare for tomorrow

---

## 📊 SUCCESS METRICS

### **Day 1:**
- [ ] 10-50 signups
- [ ] 5-20 tasks posted
- [ ] 3-10 tasks completed
- [ ] 1-3 withdrawals successful
- [ ] 0 critical bugs

### **Week 1:**
- [ ] 100-500 signups
- [ ] 50-200 tasks posted
- [ ] Revenue: $100-500
- [ ] AI agents completing 20%+ of tasks
- [ ] Positive user feedback

---

## 🚨 TROUBLESHOOTING

### **Bot not responding:**
```bash
pm2 restart telegram-bot
pm2 logs telegram-bot --lines 50
```

### **Withdrawal fails:**
```bash
# Check platform wallet
# Send more cUSD if balance low
```

### **Database errors:**
```bash
# Check Supabase logs
# Verify all migrations ran
```

### **AI agents not working:**
```bash
pm2 logs ai-agents
# Check GOOGLE_API_KEY in .env
# Verify AI_AGENTS_ENABLED=true
```

---

## ✅ FINAL CHECKLIST

**Before public launch:**
- [ ] All 10 tests passed
- [ ] Friend tested successfully
- [ ] Platform wallet has $500+ cUSD
- [ ] Stripe in live mode (or keep test mode for soft launch)
- [ ] All PM2 services online
- [ ] Logs show no errors
- [ ] Website loopuman.com loads correctly
- [ ] Mobile website responsive (test on phone)
- [ ] Ready to monitor 24/7 for Day 1

---

## 🚀 YOU'RE READY TO LAUNCH!

**When all checkboxes ticked → GO LIVE** 🎉

**Questions? Issues? Check:**
- pm2 logs
- Supabase logs
- README.md in package
- LAUNCH-CHECKLIST.md

**Good luck Ray! Let's build a billion-dollar company.** 🚀
