# 🚀 cPanel One-Click Deployment & Installation Guide
### St. Michael Industrial School Examination Result Announcement Portal
**Department of Employment and Training · Government of Tamil Nadu**

---

## 🌟 Overview & Highlights

This portal comes with an automated **Softaculous-Style 1-Click Web Installer** designed specifically for cPanel shared hosting and VPS environments.

### ✨ What's included:
- **1-Click Web Installer (`/install` & `install.php`)**: An interactive wizard with real-time MySQL database connection testing, automatic table creation, and admin account setup.
- **Clean Production Ready**: All development test records and default passwords have been completely purged for a clean installation.
- **Zero-Config MySQL Schema**: Automatically provisions `results`, `system_settings`, `admin_users`, and `trades` tables with official Tamil & English trade curriculums.
- **Automated Security Locking**: Generates an `installed.lock` file upon completion to prevent unauthorized reconfiguration.
- **cPanel Native Entry Points**: Pre-configured `server.js`, `app.js`, and `.htaccess` for **cPanel "Setup Node.js App" (Phusion Passenger)**.

---

## 🛠️ Requirements
- **cPanel Hosting** with:
  - **Node.js** version 18.x, 20.x, or 22.x (via cPanel "Setup Node.js App" / CloudLinux Node Selector).
  - **MySQL / MariaDB** database access.
  - Optional: PHP 7.4+ or 8.x (if using the standalone `install.php` helper).

---

## 📦 Step-by-Step 1-Click Installation (cPanel)

```mermaid
flowchart TD
    A["1. Upload ZIP to cPanel File Manager"] --> B["2. Create MySQL Database in cPanel"]
    B --> C["3. Setup Node.js App in cPanel"]
    C --> D["4. Open https://yourdomain.com/install"]
    D --> E["5. Enter Database & Admin Password"]
    E --> F["🎉 1-Click Installation Complete!"]
```

---

### Step 1: Create a Database in cPanel (30 seconds)
1. Log into your **cPanel Dashboard**.
2. Click on **MySQL® Database Wizard** (under Databases).
3. **Step 1:** Enter database name (e.g. `isresults`) → click **Next Step**.
4. **Step 2:** Create a database user & password (e.g. `isadmin` + strong password) → click **Create User**.
5. **Step 3:** Check the box **ALL PRIVILEGES** → click **Make Changes**.
6. Note down your:
   - **Database Name** (e.g., `cpaneluser_isresults`)
   - **Database User** (e.g., `cpaneluser_isadmin`)
   - **Database Password**

---

### Step 2: Upload Application to cPanel
1. In cPanel, open **File Manager**.
2. Go to your domain's folder (e.g., `public_html` or a subdomain folder).
3. Upload `cpanel-deployment-ready.zip` (or your project archive).
4. Right-click the uploaded `.zip` and click **Extract**.

---

### Step 3: Setup Node.js in cPanel
1. In cPanel, click on **Setup Node.js App** (or **Node.js Selector**).
2. Click **Create Application**.
3. Fill in the parameters:
   - **Node.js Version:** `20.x` (or `18.x` / `22.x`)
   - **Application Mode:** `Production`
   - **Application Root:** `public_html` (or your app directory path)
   - **Application URL:** Select your domain or subdomain (e.g. `results.yourschool.edu` or `yourdomain.com`)
   - **Application Startup File:** `server.js` (or `app.js`)
4. Click **Create** (top right).
5. Click **Run NPM Install** (or in cPanel Terminal run: `npm install --omit=dev`).
6. Click **Restart Application**.

---

### Step 4: Run the 1-Click Softaculous-style Web Installer
1. Open your browser and navigate to:
   ```
   https://yourdomain.com/install
   ```
   *(Or if using the PHP helper: `https://yourdomain.com/install.php`)*

2. **Database Settings Section**:
   - **Database Host:** `localhost`
   - **Database Port:** `3306`
   - **Database Name:** *(Enter your cPanel DB name from Step 1)*
   - **Database User:** *(Enter your cPanel DB user from Step 1)*
   - **Database Password:** *(Enter your MySQL password)*
   - Click **⚡ Test Database Connection** to confirm instant connectivity!

3. **Administrator Security Setup**:
   - **Admin Username:** `admin` (or your chosen ID)
   - **Admin Password:** *(Create your secure password)*
   - **Confirm Admin Password:** *(Re-type password)*

4. **Institute Customization (Optional)**:
   - Default: *St.Michael Industrial School, Kalaiyar Karisal Kulam*
   - Exam Title: *Industrial School Common Examination July 2026*

5. Click **🚀 1-Click Install Now**!
   - The installer creates all tables, registers your administrator credentials, generates `.env` and `installed.lock`, and synchronizes the live database in under 3 seconds!

---

## 🌐 Quick Access URLs After Installation

| Feature | URL Endpoint |
| :--- | :--- |
| **Public Result Search Portal** | `https://yourdomain.com/` |
| **Administrator Login Console** | `https://yourdomain.com/admin/login` |
| **Admin Dashboard** | `https://yourdomain.com/admin` |
| **Add Single Result** | `https://yourdomain.com/admin/trainees/new` |
| **Bulk CSV Mark Import** | `https://yourdomain.com/admin/import` |
| **Trades & Curriculum** | `https://yourdomain.com/admin/trades` |
| **School Logo Upload** | `https://yourdomain.com/admin/settings` |

---

## 🔒 Security & Reinstallation Protection

- Once installed, the system automatically writes an `installed.lock` file in the project root directory.
- Visiting `/install` or `install.php` after installation will display a **"Portal is Already Installed & Protected"** status.
- **To Reinstall:** If you ever need to reset or move to a new database, delete the `installed.lock` file via cPanel File Manager and rerun `/install`.

---

## 📁 Environment Configuration File (`.env`)

The 1-Click Installer automatically creates and manages your `.env` file:
```env
NODE_ENV=production
MYSQL_HOST=localhost
MYSQL_PORT=3306
MYSQL_DATABASE=your_database_name
MYSQL_USER=your_database_user
MYSQL_PASSWORD=your_database_password
ADMIN_PASSWORD=your_admin_password
ADMIN_USERNAME=admin
INSTALLED=true
NEXT_PUBLIC_INSTITUTE_NAME=St.Micheal Industrial School, Kalaiyar Karisal Kulam
NEXT_PUBLIC_EXAM_TITLE=Industrial School Common Examination July 2026
```

---

## ❓ Frequently Asked Questions (FAQ)

### Q: Can I import 1,000+ student marks in bulk?
**A:** Yes! Log into `/admin/login`, go to **Bulk CSV Import** (`/admin/import`), select the trade (Cutting & Tailoring, Embroidery & Needle Work, or TTC), paste your CSV marks or upload file, and click **Import All Results**.

### Q: Does the certificate generator and PDF download work on cPanel?
**A:** Yes! The portal includes client-side HTML5 canvas and jsPDF vector generation that generates official Tamil Nadu State Department marksheet certificates with zero external server dependencies.

---
*St. Michael Industrial School, Kalaiyar Karisal Kulam · Official Examination Portal*
