# cPanel Deployment Guide for CompareKit

## The Issue You're Seeing

You uploaded the files but you're seeing a directory listing. This is because:
1. The Node.js application isn't running
2. You need to configure it as a Node.js app in cPanel

## Step-by-Step Deployment

### Option 1: Using cPanel's Node.js App Manager (Recommended)

#### Step 1: Access Node.js Setup

1. Log into your cPanel
2. Search for "Setup Node.js App" or "Node.js Selector"
3. Click on it

#### Step 2: Create Application

Click "Create Application" and configure:

```
Application root: CompareKit
Application URL: CompareKit
Application startup file: src/server.js
Node.js version: 18.x or higher (or latest available)
```

#### Step 3: Set Environment Variables (Optional)

Add these environment variables in the interface:
- `PORT` = `3000` (or whatever cPanel assigns)
- `NODE_ENV` = `production`

#### Step 4: Run NPM Install

In the Node.js app interface:
1. Find the "Run NPM Install" button
2. Click it and wait for dependencies to install

#### Step 5: Start the Application

Click "Start" or "Restart" button in the Node.js app interface.

#### Step 6: Access Your App

Visit: `https://kodepilot.com/CompareKit`

---

### Option 2: If cPanel Doesn't Have Node.js Support

If your cPanel doesn't support Node.js apps, you'll need to create a **static version** or use a different approach.

#### Quick Fix: Create an .htaccess file

Create this file in your CompareKit directory:

```apache
# /CompareKit/.htaccess
Options -Indexes
DirectoryIndex index.html

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /CompareKit/

    # Redirect /CompareKit to /CompareKit/public/
    RewriteCond %{REQUEST_URI} ^/CompareKit/?$
    RewriteRule ^(.*)$ /CompareKit/public/ [L]

    # Serve files from public directory
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
```

This will at least show the frontend interface, but the API won't work without Node.js running.

---

## Alternative: Deploy on a Subdomain with Full Node.js Access

### If you have SSH access:

1. SSH into your server
2. Navigate to your domain directory:
   ```bash
   cd ~/public_html/CompareKit
   ```

3. Install dependencies:
   ```bash
   npm install
   ```

4. Install PM2 (process manager):
   ```bash
   npm install -g pm2
   ```

5. Start the application:
   ```bash
   pm2 start src/server.js --name comparekit
   pm2 save
   pm2 startup
   ```

6. Configure Apache as a reverse proxy (in .htaccess):
   ```apache
   RewriteEngine On
   RewriteCond %{REQUEST_URI} !^/CompareKit/public
   RewriteRule ^(.*)$ http://localhost:3000/$1 [P,L]
   ```

---

## Troubleshooting

### "Directory Listing Showing"
- The Node.js app isn't running
- Check cPanel's Node.js App Manager to see if app is started
- Check error logs in cPanel

### "Node.js Not Available in cPanel"
- Contact your hosting provider
- Ask about Node.js support
- Consider these alternatives:
  - Deploy on Vercel/Netlify (free)
  - Use a VPS instead
  - Upgrade hosting plan

### "Dependencies Won't Install"
- Check Node.js version (needs 18+)
- Try manually: SSH in and run `npm install`
- Check disk space in cPanel

---

## Quick Test After Setup

Once the app is running, test these URLs:

1. **Frontend**: `https://kodepilot.com/CompareKit/`
2. **Health Check**: `https://kodepilot.com/CompareKit/health`
3. **API Test**:
   ```bash
   curl -X POST https://kodepilot.com/CompareKit/api/generate/comparison \
     -H "Content-Type: application/json" \
     -d '{"productA": "Semrush", "productB": "Ahrefs"}' \
     --output test.png
   ```

---

## Need Help?

**Common cPanel Node.js locations:**
- "Setup Node.js App" (CloudLinux)
- "Application Manager"
- "Node.js Selector"

**If you can't find it:**
1. Search for "node" in cPanel search bar
2. Check under "Software" section
3. Contact your hosting provider's support

**Your hosting provider should be able to:**
- Enable Node.js support
- Install PM2
- Configure the application
- Set up the reverse proxy
