# cPanel Deployment Guide for MTE7 DApp & Admin

This guide outlines how to deploy the packaged **mte7-dapp** and **decx-admin** (Frontend + Express Backend) projects to cPanel using the created `mte7-deployment.zip`.

---

## 📦 What's Included in the Zip File?
The `mte7-deployment.zip` contains clean source directories for:
1. **mte7-dapp**: Next.js DApp Frontend.
2. **decx-admin**: Next.js Admin Panel Frontend + Express Backend (`decx-admin/backend`).
*Note: `node_modules`, `.next` builds, and local development database files have been excluded to keep the package small (approx. 0.44 MB) and clean for the production environment.*

---

## 🛠️ Step 1: Upload and Extract in cPanel
1. Log in to your cPanel.
2. Open **File Manager** and navigate to your home directory or a folder outside of public HTML (e.g. `/home/username/mte7-app`).
3. Upload `mte7-deployment.zip` and extract it. You will see two folders:
   - `mte7-dapp`
   - `decx-admin`

---

## ⚙️ Step 2: Configure Environment Variables (.env)
Update/Verify `.env` configuration files inside the extracted directories (these have been pre-configured for you in the zip):

### 1. DApp Frontend (`mte7-dapp/.env`)
Ensure `MONGO_URI` and `DB_NAME` reflect your production MongoDB database credentials.
```env
MONGO_URI=mongodb+srv://mte7star2026_db_user:q5OXQNK9WlD902jJ@cluster0.tjjpo68.mongodb.net/decxdb?retryWrites=true&w=majority
DB_NAME=decxdb
MINT_PRIVATE_KEY=0x63c80bb07924927afffaa7a627f6ca7ecee10b16f27b1f16153f9643b462133d
MTC_TOKEN_ADDRESS=0xA7E60EAFc976C46ee168939a0b4f85d659f8C5d7
COMPANY_WALLET_ADDRESS=0xD29fC11437Eeae0e2cC2795484eBa3d0Ed9Ca2bA
VAULT_ADDRESS=0xf62a0d7778E817DF41570c4a830b1495E6eA5F5b
```

### 2. Admin Express Backend (`decx-admin/backend/.env`)
```env
MONGO_URI=mongodb+srv://mte7star2026_db_user:q5OXQNK9WlD902jJ@cluster0.tjjpo68.mongodb.net/decxdb?retryWrites=true&w=majority
JWT_SECRET=decxsecret
PORT=5000
```

### 3. Admin Frontend (`decx-admin/.env`)
Ensure the URL points to your deployed Express backend URL:
```env
NEXT_PUBLIC_API_URL=https://test.mte7star.com/api
```

---

## 🚀 Step 3: Setup Node.js Applications in cPanel
cPanel provides a **Setup Node.js App** tool. You will need to create **three separate Node.js applications**:

### App 1: DApp Frontend (Next.js)
* **Node.js Version**: Select recommended version (e.g., 20.x or 18.x).
* **Application Mode**: `production`
* **Application Root**: `mte7-dapp`
* **Application URL**: `yourdomain.com` (or subdomain like `dapp.yourdomain.com`)
* **Application Startup File**: `server.js`
* Click **Create**, then click **Run JS Build** or use the terminal to run `npm run build` after npm packages are installed.

### App 2: Admin Frontend (Next.js)
* **Node.js Version**: Same version.
* **Application Mode**: `production`
* **Application Root**: `decx-admin`
* **Application URL**: `admin.yourdomain.com`
* **Application Startup File**: `server.js`
* Click **Create**, then click **Run JS Build** (or run `npm run build` via terminal).

### App 3: Express Backend API
* **Node.js Version**: Same version.
* **Application Mode**: `production`
* **Application Root**: `decx-admin/backend`
* **Application URL**: `yourdomain.com/api` (or `api.yourdomain.com`)
* **Application Startup File**: `server.js`
* Click **Create**.

---

## 📦 Step 4: Install Dependencies & Build
For each application:
1. Enter the virtual environment command provided at the top of the Setup Node.js App page in your terminal (SSH), or click **npm install** in the UI.
2. In the terminal:
   ```bash
   # Go to your app directory
   cd ~/mte7-dapp
   # Install dependencies
   npm install
   # Build production code
   npm run build

   # Go to admin directory
   cd ~/decx-admin
   npm install
   npm run build

   # Go to backend directory
   cd ~/decx-admin/backend
   npm install
   ```
3. Restart each Node.js app from the cPanel interface.
