# Edil Bingo Admin — deploy to edilapk.makalla.org

## cPanel (recommended for makalla.org)

**→ See [DEPLOY-CPANEL.md](./DEPLOY-CPANEL.md)** for step-by-step cPanel instructions.

Quick summary:
1. Create subdomain `edilapk.makalla.org`
2. Upload `admin/` files to the subdomain folder
3. **Setup Node.js App** → startup file `server/index.js`
4. Set environment variables (`NODE_ENV`, `PUBLIC_BASE_URL`, `ADMIN_PASSWORD`, etc.)
5. Run NPM Install → Restart → enable SSL

---

## VPS / PM2 (alternative)

## 1. Server setup

```bash
# On your VPS (Ubuntu example)
sudo apt update && sudo apt install -y nginx certbot python3-certbot-nginx nodejs npm

cd /var/www/edil-bingo-admin   # upload the admin/ folder here
npm install --omit=dev
cp .env.production.example .env.production
nano .env.production           # set ADMIN_PASSWORD and ADMIN_SESSION_SECRET
```

## 2. Start with PM2

```bash
npm install -g pm2
pm2 start ecosystem.config.cjs --env production
pm2 save
pm2 startup
```

Or without PM2:

```bash
export $(grep -v '^#' .env.production | xargs)
node server/index.js
```

## 3. Nginx + SSL

Copy `deploy/nginx-edilapk.makalla.org.conf` to nginx sites-available, then:

```bash
sudo ln -s /etc/nginx/sites-available/edilapk.makalla.org /etc/nginx/sites-enabled/
sudo nginx -t
sudo certbot --nginx -d edilapk.makalla.org
sudo systemctl reload nginx
```

Point DNS **A record** for `edilapk.makalla.org` → your server IP.

## 4. Verify after deploy

```bash
npm run verify:integration
# or
node scripts/verify-integration.js https://edilapk.makalla.org
```

Expected: all checks pass (health, update.json, activation status).

## 5. Mobile APK

The Flutter app is configured with:

```json
{ "enabled": true, "baseUrl": "https://edilapk.makalla.org" }
```

Rebuild and upload APK via admin → **App Release**, or place in `uploads/apk/`.

## 6. First-time admin

1. Open https://edilapk.makalla.org
2. Login with credentials from `.env.production`
3. **Devices & Activation** → generate codes
4. **App Release** → upload latest APK

## Data backup

Back up these folders regularly:

- `admin/data/` — devices, codes, users, release metadata
- `admin/uploads/apk/` — APK files
