# TimetableGen SaaS v2 — cPanel Deployment Guide

## Install Packages

In **cPanel → Setup Python App**, click your app.
Copy the `source ...` activate command shown at the top. Then in cPanel Terminal:

```bash
source /home/USERNAME/virtualenv/APPFOLDER/3.x/bin/activate
pip install fastapi uvicorn jinja2 python-multipart reportlab aiofiles bcrypt a2wsgi
```

> No `--user` flag. You are inside the virtualenv already.

---

## cPanel Python App Settings

| Field | Value |
|---|---|
| Application startup file | `passenger_wsgi.py` |
| Application Entry point | `application` |

---

## File Layout (inside your app root)

```
passenger_wsgi.py   ← must be at root, not in a subfolder
main.py
database.py
auth.py
requirements.txt
static/
templates/
services/
```

If the ZIP extracted into a subfolder called `timetable_saas/`,
move everything **up one level** in File Manager.

---

## After Upload → Restart

cPanel → Setup Python App → **Restart** button.

---

## Reading the Error Log

Every error is written to `error.log` in your app folder.
Open it in **cPanel → File Manager** to see exactly what failed.

Successful startup looks like:
```
[2025-06-01 10:00:00] passenger_wsgi.py loading...
[2025-06-01 10:00:00] Database initialised OK
[2025-06-01 10:00:01] FastAPI app imported OK
[2025-06-01 10:00:01] a2wsgi wrapper ready — startup complete
```

If you see an error there, share it and it will be fixed immediately.

---

## Change Admin Secret

Edit `passenger_wsgi.py` line:
```python
os.environ.setdefault("ADMIN_SECRET", "your_real_secret_here")
```
Then restart the app.

## Platform Admin
Visit `/admin?secret=YOUR_ADMIN_SECRET`

## First Use
Visit your domain → Landing page → Register → Dashboard.
