# AegisTrade AI — cPanel Setup Guide (NO Terminal / SSH Access)

This guide is designed for standard cPanel shared hosting accounts where **Terminal and SSH access are disabled** by your hosting provider.

You can complete the entire setup using only the **cPanel Web Browser Interface**:
1. **File Manager**
2. **Setup Python App (GUI)**
3. **Cron Jobs**

---

## Step 1: Upload Project via File Manager

1. Log into your **cPanel Dashboard**.
2. Open **File Manager** (under *Files*).
3. Navigate to your user home directory (one level above `public_html`, usually `/home/yourusername/`).
4. Click **+ Folder** at the top left and name it: `aegistrade-ai`.
5. Open the `aegistrade-ai` folder and click **Upload** at the top.
6. Drag and drop **`aegistrade-ai.zip`**.
7. Once upload completes (100% green bar), return to File Manager.
8. Right-click `aegistrade-ai.zip` and select **Extract** -> **Extract Files**.
9. In the extracted files, find `.env.example`:
   - Right-click `.env.example` -> **Copy** -> name the new file `.env`.
   - Right-click `.env` -> **Edit** -> click **Edit**.
   - Make sure `TRADING_MODE=PAPER` and save changes.

---

## Step 2: Create the Python Application in cPanel

1. Go back to the main cPanel dashboard.
2. Find and click **Setup Python App** (under *Software*).
3. Click the blue **Create Application** button at the top right:
   - **Python version**: Select `3.10` or `3.11` (or `3.9`).
   - **Application root**: `aegistrade-ai`
   - **Application URL**: Select your domain or subdomain (e.g., `trading.yourdomain.com`).
   - **Application startup file**: `passenger_wsgi.py`
   - **Application Entry point**: `application`
4. Click **Create** at the top right.

---

## Step 3: Install Dependencies Without Terminal (GUI Pip Install)

cPanel includes a built-in graphical Pip installer:

1. On the same **Setup Python App** page, scroll down to the **Configuration files** section.
2. In the input box that says *"Enter configuration file name"*, type:
   ```
   requirements.txt
   ```
3. Click the **Add** button.
4. Once added, a button labeled **Run Pip Install** will appear next to `requirements.txt`.
5. Click **Run Pip Install**.
6. Wait 1–2 minutes while cPanel automatically downloads and installs FastAPI, Pydantic, a2wsgi, Scikit-learn, and the other dependencies.
7. A green notification will confirm: *"Pip install completed successfully"*.

---

## Step 4: Restart the Application & Automatic Database Creation

1. Scroll back up to the top of the **Setup Python App** page.
2. Click the **Restart** button.
3. Open your browser and visit your application URL (e.g., `https://trading.yourdomain.com`).
4. **Database Auto-Creation**: The system will automatically initialize the local SQLite database (`data/aegistrade.db`), create all tables, seed the administrator user, and serve the dark financial terminal!

---

## Step 5: Keep the App Awake (Cron Job Heartbeat)

Shared cPanel hosts put Python apps to sleep after inactivity. To keep your terminal and feeds responsive:

1. Return to the main cPanel dashboard and click **Cron Jobs** (under *Advanced*).
2. Under **Common Settings**, select **Once Per Minute (* * * * *)**.
3. In the **Command** field, enter:
   ```bash
   curl -s https://trading.yourdomain.com/api/v1/health > /dev/null 2>&1
   ```
   *(Replace with your actual URL)*.
4. Click **Add New Cron Job**.

---

## Troubleshooting

- **500 Internal Server Error**:
  - In File Manager, check `/home/yourusername/aegistrade-ai/passenger_wsgi.py`.
  - In Setup Python App, ensure you clicked **Run Pip Install** on `requirements.txt`.
  - Click **Restart** on the Python App.
- **cPanel does not have "Setup Python App"**:
  - If your hosting provider does not offer Python in cPanel, your plan is PHP-only. In this case, you can upload `frontend/dist` to `public_html` as a static dashboard and run the backend on a free cloud service like Render or a $4/mo VPS.
