# 📦 Installation Package for Website Deployment

This guide explains how to prepare the installation folder for uploading to your Namecheap hosting.

---

## 🎯 What You Need to Upload

You'll create a **deployment package** that includes:
- ✅ All source code files
- ✅ Built application (`.next/` folder)
- ✅ Dependencies (`node_modules/`)
- ✅ Configuration (`.env` file)
- ❌ Exclude: Git files, development files

---

## 📋 Step-by-Step: Create Installation Folder

### **Step 1: Complete Local Build**

First, build everything on your local machine:

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

# Install dependencies
npm install

# Build the application
npm run build
```

**Wait for:** "Compiled successfully" message

---

### **Step 2: Create Deployment Folder**

Create a clean folder for deployment:

```bash
# Create deployment folder
mkdir C:\Users\hp\Documents\rebrandly-deploy

# Copy all necessary files
xcopy C:\Users\hp\Documents\rev1111111 C:\Users\hp\Documents\rebrandly-deploy /E /I /H
```

---

### **Step 3: Clean Up Unnecessary Files**

Remove files that shouldn't be deployed:

```bash
cd C:\Users\hp\Documents\rebrandly-deploy

# Remove Git files
rmdir /S /Q .git
del .gitignore

# Remove development files
del .env.example
rmdir /S /Q .next\cache

# Remove documentation (optional - keep if you want)
del DEPLOYMENT_STEPS.md
del CLEANUP_AND_DEPLOY.md
del FRONTEND_MIGRATION_COMPLETE.md
del MIGRATION_NOTES.md
```

---

### **Step 4: Verify Required Files**

Make sure these are in your deployment folder:

**✅ Required Files:**
```
rebrandly-deploy/
├── .env                          ← Your configured environment
├── .next/                        ← Built application
├── node_modules/                 ← All dependencies
├── app/                          ← Application code
├── components/                   ← UI components
├── lib/                          ← Utilities
├── public/                       ← Static files
├── database/
│   └── schema.sql               ← Database schema
├── package.json                  ← Dependencies list
├── next.config.mjs              ← Next.js config
└── server.js                    ← Server entry point (create if missing)
```

---

### **Step 5: Create server.js** (if it doesn't exist)

Create `C:\Users\hp\Documents\rebrandly-deploy\server.js`:

```javascript
const { createServer } = require('http')
const { parse } = require('url')
const next = require('next')

const dev = process.env.NODE_ENV !== 'production'
const hostname = 'localhost'
const port = process.env.PORT || 3000

const app = next({ dev, hostname, port })
const handle = app.getRequestHandler()

app.prepare().then(() => {
  createServer(async (req, res) => {
    try {
      const parsedUrl = parse(req.url, true)
      await handle(req, res, parsedUrl)
    } catch (err) {
      console.error('Error occurred handling', req.url, err)
      res.statusCode = 500
      res.end('internal server error')
    }
  }).listen(port, (err) => {
    if (err) throw err
    console.log(`> Ready on http://${hostname}:${port}`)
  })
})
```

---

## 📤 Upload to Namecheap

### **Option A: FTP Upload**

1. Connect to your Namecheap hosting via FTP
2. Navigate to `public_html/` or your app directory
3. Upload the entire `rebrandly-deploy/` folder contents
4. **This will take time** (node_modules is large)

### **Option B: cPanel File Manager**

1. Compress the folder first:
   ```bash
   # Create ZIP file
   Compress-Archive -Path C:\Users\hp\Documents\rebrandly-deploy\* -DestinationPath C:\Users\hp\Documents\rebrandly-deploy.zip
   ```

2. Upload `rebrandly-deploy.zip` via cPanel File Manager
3. Extract on the server
4. Delete the ZIP file after extraction

### **Option C: Git Deploy** (Recommended)

1. Initialize Git in deployment folder:
   ```bash
   cd C:\Users\hp\Documents\rebrandly-deploy
   git init
   git add .
   git commit -m "Production build"
   ```

2. Push to GitHub (private repo)
3. SSH into your server and clone
4. Much faster than FTP!

---

## ⚙️ Configure on Server

After uploading, you need to:

### **1. Set Up Node.js App in cPanel**

- Go to **Setup Node.js App**
- Application root: `/home/username/public_html`
- Application URL: `https://rebrandlyai.com`
- Application startup file: `server.js`
- Node.js version: 18.x or higher
- Click **Create**

### **2. Install Dependencies on Server** (if needed)

If you didn't upload `node_modules/`:

```bash
cd /home/username/public_html
npm install --production
```

### **3. Set Environment Variables**

In cPanel Node.js app settings, add:
- `NODE_ENV=production`
- Or ensure `.env` file is uploaded

### **4. Start the Application**

Click **Start App** in cPanel or:

```bash
npm start
```

---

## 📊 Deployment Package Size

**Approximate sizes:**
- Source code: ~50 MB
- `node_modules/`: ~300-500 MB
- `.next/` build: ~50-100 MB
- **Total: ~400-650 MB**

**Upload time estimates:**
- Fast internet (100 Mbps): 5-10 minutes
- Medium internet (50 Mbps): 10-20 minutes
- Slow internet (10 Mbps): 30-60 minutes

---

## ✅ Verification Checklist

Before uploading, verify:

- [ ] `.env` has all real credentials (not placeholders)
- [ ] `npm install` completed successfully
- [ ] `npm run build` completed successfully
- [ ] `.next/` folder exists and has content
- [ ] `node_modules/` folder exists
- [ ] `server.js` file exists
- [ ] Database is set up and accessible
- [ ] All passwords are correct

---

## 🚨 Important Notes

**DO NOT upload:**
- `.git/` folder
- `.env.example` (only upload `.env`)
- `*.md` documentation files (optional)
- Development cache files

**DO upload:**
- `.env` (with real credentials)
- `.next/` (built application)
- `node_modules/` (or install on server)
- All source code folders

**Security:**
- Make sure `.env` is NOT publicly accessible
- Use `.htaccess` to protect sensitive files
- Never commit `.env` to Git

---

## 🎯 Quick Deploy Checklist

1. ✅ Build locally: `npm install && npm run build`
2. ✅ Create deployment folder
3. ✅ Copy all files
4. ✅ Remove unnecessary files
5. ✅ Create `server.js`
6. ✅ Verify `.env` has real credentials
7. ✅ Compress or upload via FTP
8. ✅ Configure Node.js app in cPanel
9. ✅ Start the application
10. ✅ Test at your domain

---

**Your installation package is ready when you complete the local build!**
