# MARTS on axiomasense.com (Apache, no Passenger)

Confirmed by your host:

- **No Passenger** and no `passenger_wsgi.py` support
- **No "Setup Python App"** wizard
- **Cron + virtualenv over SSH** is supported
- **CPU limits** are enforced — heavy or frequent jobs can suspend the account
- **No fixed max cron runtime** documented — keep jobs short and infrequent

Your panel shows:

| Setting | Value |
|---|---|
| Domain | `axiomasense.com` |
| Web root | `/www/axiomasense.com` |
| Web server | Apache |
| PHP | 8.5 (not used by MARTS) |
| Jail host | **On** — stay inside `/www/` for files and venv |

## What works on this host

| Approach | Supported? |
|---|---|
| Streamlit `app.py` | **No** — needs always-on process + WebSockets |
| Flask / Passenger | **No** — not available on your plan |
| **Cron → static `index.html`** | **Yes** — recommended |
| Cron-only (CSV files, no web page) | **Yes** |

MARTS publishes a **static HTML dashboard** to `/www/axiomasense.com/index.html`.
Apache serves it like any normal website — no Python runtime needed for visitors.

## Recommended folder layout

```
/www/axiomasense.com/
  index.html                 ← public dashboard (cron regenerates this)
  marts/                     ← project code (protected by .htaccess)
    venv/                    ← Python virtualenv (inside jail)
    deploy/cpanel/
    outputs/                 ← radar CSVs/JSON (not web-accessible)
    .env                     ← API keys (not web-accessible)
    marts_cli.py
    ...
```

Upload `MARTS_v2_web_ready.zip` and extract so `marts/` sits under the web root.

## Step 1 — Upload

Use the panel **Browse** button for `/www/axiomasense.com` or SFTP.

Extract the zip so you have `/www/axiomasense.com/marts/`.

## Step 2 — SSH setup

```bash
cd /www/axiomasense.com/marts
bash deploy/cpanel/setup.sh /www/axiomasense.com/marts
nano .env
```

This creates `/www/axiomasense.com/marts/venv/` and installs dependencies.

## Step 3 — First run (SSH)

```bash
/www/axiomasense.com/marts/venv/bin/python /www/axiomasense.com/marts/deploy/cpanel/cron_refresh.py
```

This will:

1. Run the opportunity radar (40 tickers by default — CPU-safe)
2. Write `/www/axiomasense.com/index.html`

Open **https://axiomasense.com/** in your browser.

To regenerate only the HTML (after manual CSV updates):

```bash
/www/axiomasense.com/marts/venv/bin/python /www/axiomasense.com/marts/deploy/cpanel/generate_static_site.py
```

## Step 4 — Cron job

In cPanel → **Cron Jobs**, use the **venv Python** (not `/usr/local/bin/python3`):

**Recommended — every 4 hours** (lower CPU risk):

```cron
0 */4 * * * /www/axiomasense.com/marts/venv/bin/python /www/axiomasense.com/marts/deploy/cpanel/cron_refresh.py >> /www/axiomasense.com/marts/outputs/cron.log 2>&1
```

**Conservative — twice daily** (safest for CPU limits):

```cron
0 6,18 * * * /www/axiomasense.com/marts/venv/bin/python /www/axiomasense.com/marts/deploy/cpanel/cron_refresh.py >> /www/axiomasense.com/marts/outputs/cron.log 2>&1
```

Do **not** run every 15–30 minutes — Yahoo API calls and scoring are CPU-heavy.

### Tuning workload (via `.env` or cron env)

| Variable | Default | Purpose |
|---|---|---|
| `MARTS_MAX_UNIVERSE` | `40` | Fewer tickers = faster cron |
| `MARTS_DEEP_SCAN` | `15` | Deep scan depth |
| `MARTS_WEB_ROOT` | `/www/axiomasense.com` | Where `index.html` is written |

Example lighter cron:

```cron
0 7,19 * * * MARTS_MAX_UNIVERSE=30 MARTS_DEEP_SCAN=10 /www/axiomasense.com/marts/venv/bin/python /www/axiomasense.com/marts/deploy/cpanel/cron_refresh.py >> /www/axiomasense.com/marts/outputs/cron.log 2>&1
```

## CPU limits — what to expect

Your host does not publish a max runtime, but they **do** monitor CPU usage.
If cron jobs are too heavy or too frequent:

- You receive email warnings
- The account may be **suspended for CPU overload**

Mitigations already built in:

- Smaller universe (`40` tickers, not uncapped)
- Static HTML (no background Python web server)
- 4-hour or 12-hour cron intervals recommended

Check progress after the first run:

```bash
tail -50 /www/axiomasense.com/marts/outputs/cron.log
ls -la /www/axiomasense.com/index.html
```

## Security notes

- `deploy/cpanel/setup.sh` installs `.htaccess` in `marts/` to block web access to `.env`, `.csv`, `.py`
- ModSecurity is **active** on your domain — normal for Apache hosts
- MARTS has **no login** — anyone visiting `axiomasense.com` sees the dashboard
- Consider cPanel **password-protect directory** on `/www/axiomasense.com` if you want privacy

## Files for this deployment

| File | Purpose |
|---|---|
| `deploy/cpanel/cron_refresh.py` | Cron entry: radar + publish HTML |
| `deploy/cpanel/generate_static_site.py` | Writes `index.html` to web root |
| `deploy/cpanel/site_renderer.py` | Builds dashboard HTML from CSVs |
| `deploy/cpanel/setup.sh` | SSH bootstrap for axiomasense.com |
| `deploy/cpanel/htaccess-protect.snippet` | Blocks web access to secrets |
| `requirements-cpanel.txt` | Python deps (no Streamlit/Flask) |

`passenger_wsgi.py` and `cpanel_app.py` are kept for other hosts only — **ignore them here**.

## Full interactive terminal

Run locally on your PC:

```bash
cd MARTS_v2
run_web.bat
```

Or deploy `app.py` to [Streamlit Cloud](https://share.streamlit.io) — see `DEPLOY.md`.
