# 🚀 Step-by-Step Deployment Guide

You've completed: ✅ **MySQL Database Setup**

Follow these steps **in order**, one at a time:

---

## ✅ STEP 1: MySQL Database Setup (COMPLETED)

Great! Your database is ready with all tables created.

---

## 📝 STEP 2: Configure Environment Variables

**Action:** Edit the `.env` file with your actual credentials

### 2.1 - Fill in MySQL Credentials

Open `.env` and update these lines with your **actual** database info from cPanel:

```env
MYSQL_HOST=localhost
MYSQL_USER=your_actual_database_username
MYSQL_PASSWORD=your_actual_database_password
MYSQL_DATABASE=rebrandlyai_db
```

**Where to find these:**
- Go to Namecheap cPanel → MySQL Databases
- Copy the database username and password you created
- Database name should be what you created (e.g., `rebrandlyai_db`)

---

### 2.2 - Fill in SMTP Email Password

Update this line with your **actual** email password:

```env
SMTP_PASS=your_actual_email_password
```

**This is the password for:** `noreply@rebrandlyai.com`

---

### 2.3 - Generate Session Secret

**Run this command in your terminal:**

```bash
node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"
```

**Copy the output** and paste it in `.env`:

```env
SESSION_SECRET=paste_the_generated_string_here
```

**Example output:** `a1b2c3d4e5f6...` (64 characters)

---

### 2.4 - Add Stripe Keys (if you have them)

If you have Stripe set up, add your keys:

```env
STRIPE_SECRET_KEY=sk_live_your_actual_stripe_secret_key
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=pk_live_your_actual_publishable_key
STRIPE_WEBHOOK_SECRET=whsec_your_actual_webhook_secret
```

**If you don't have Stripe yet:** Leave the test keys as-is for now. You can add them later.

---

### ✅ Step 2 Complete When:
- [ ] MySQL credentials filled in
- [ ] SMTP password filled in
- [ ] Session secret generated and added
- [ ] Stripe keys added (or left as test keys)

**Once done, tell me: "Step 2 done"**

---

## 📦 STEP 3: Install Dependencies

**Action:** Install all required Node.js packages

### 3.1 - Open Terminal/Command Prompt

Navigate to your project folder:

```bash
cd C:\Users\hp\Documents\rev1111111
```

---

### 3.2 - Install Packages

Run this command:

```bash
npm install
```

**What this does:**
- Downloads all dependencies from `package.json`
- Creates `node_modules/` folder
- Installs: Next.js, MySQL client, email library, etc.

**Expected time:** 2-5 minutes

**You'll see:** Progress bars and package names being installed

---

### ✅ Step 3 Complete When:
- [ ] Command finishes without errors
- [ ] `node_modules/` folder exists
- [ ] You see "added XXX packages" message

**Once done, tell me: "Step 3 done"**

---

## 🔨 STEP 4: Build the Application

**Action:** Compile TypeScript and create production build

### 4.1 - Run Build Command

```bash
npm run build
```

**What this does:**
- Compiles TypeScript to JavaScript
- Optimizes code for production
- Creates `.next/` folder with compiled app

**Expected time:** 1-3 minutes

**You'll see:** Build progress, route compilation, optimization steps

---

### ✅ Step 4 Complete When:
- [ ] Build finishes successfully
- [ ] You see "Compiled successfully" message
- [ ] `.next/` folder exists

**Once done, tell me: "Step 4 done"**

---

## 🚀 STEP 5: Test Locally (Optional but Recommended)

**Action:** Run the app on your local machine first

### 5.1 - Start Development Server

```bash
npm run dev
```

**What this does:**
- Starts Next.js on `http://localhost:3000`
- Connects to your MySQL database
- Allows you to test before deploying

---

### 5.2 - Test in Browser

1. Open browser: `http://localhost:3000`
2. Try to sign up with a test email
3. Check if verification email is sent
4. Try logging in
5. Check dashboard loads

---

### ✅ Step 5 Complete When:
- [ ] App loads at localhost:3000
- [ ] No database connection errors
- [ ] Signup/login works
- [ ] Dashboard displays

**Once done, tell me: "Step 5 done" or "Skip to deployment"**

---

## 🌐 STEP 6: Deploy to Namecheap

**Action:** Upload and configure on your hosting

### Choose Your Hosting Type:

**Option A: Namecheap Shared Hosting**
- Limited Node.js support
- May have issues with Next.js
- Not recommended for this app

**Option B: Namecheap VPS** (Recommended)
- Full control
- Better performance
- Requires SSH access

**Option C: Vercel** (Easiest)
- Free tier available
- Auto-deploys from GitHub
- Best for Next.js

---

### Tell me which option you want:
- "Deploy to VPS"
- "Deploy to Vercel"
- "Deploy to shared hosting" (not recommended)

---

## 📊 Progress Tracker

- [x] **Step 1:** MySQL Database Setup ✅
- [ ] **Step 2:** Configure .env file
- [ ] **Step 3:** Install dependencies
- [ ] **Step 4:** Build application
- [ ] **Step 5:** Test locally
- [ ] **Step 6:** Deploy to hosting

---

## 🆘 If You Get Stuck:

**Database connection error?**
- Check MySQL credentials in `.env`
- Verify database exists in cPanel
- Check user has ALL PRIVILEGES

**npm install fails?**
- Make sure Node.js v18+ is installed
- Try: `npm cache clean --force` then retry

**Build fails?**
- Check for TypeScript errors
- Make sure all `.env` variables are set
- Try: `rm -rf .next` then rebuild

**Email not sending?**
- Verify SMTP password is correct
- Check port 465 is not blocked
- Test email account login manually

---

## 🎯 Current Status

✅ **Database:** Ready  
✅ **Groq API:** Configured  
⏳ **Environment:** Waiting for credentials  
⏳ **Dependencies:** Not installed yet  
⏳ **Build:** Not built yet  
⏳ **Deployment:** Not deployed yet  

---

**Start with Step 2 and work through each step in order. Tell me when each step is complete!**
