# Backend Integration Details (Local)

This file documents how the Press.Zone backend is deployed and how the WordPress plugin talks to it.

SECURITY
- This file contains credentials and infrastructure details.
- It is intentionally gitignored by `plugins/multilingual-press-zone/.gitignore`.
- Keep file permissions restrictive (recommended: `chmod 600`).

Last Updated: 2026-02-14

## Host Topology

Backend API host (Podman)
- SSH: `root@100.116.176.87`
- Hostname: `cloudpanel01`
- App user: `press-api` (use `su - press-api`)
- Backend repo path:
  - `/home/press-api/Press.Zone-Works/press-zone-backend`
- Container runtime:
  - `podman` / `podman-compose`
- Compose file:
  - `/home/press-api/Press.Zone-Works/press-zone-backend/podman-compose.yml`

API process is exposed on the host network at `http://127.0.0.1:3000` on `100.116.176.87`.

## Reverse Proxy Mapping (api.press.zone)

On `root@100.109.41.8`, in `/etc/httpd/conf.d/api.press.zone.conf`, these mappings exist:

- `/translate/` -> `http://185.151.196.109/translate/` (legacy)
- `/health` -> `http://100.116.176.87:3000/health`
- `/v1/` -> `http://100.116.176.87:3000/v1/`
- `/pricing` -> `http://100.116.176.87:3000/pricing`
- `/account/licenses` -> `http://100.116.176.87:3000/account/licenses`
- `/admin/` (static SPA) -> `/home/dev1/public_html/admin/`

Quick smoke checks:
- `curl -i https://api.press.zone/health`
- `curl -i https://api.press.zone/v1/multilingual/license/status`
- `curl -i https://api.press.zone/pricing`
- `curl -i https://api.press.zone/account/licenses`
- `curl -i https://api.press.zone/admin/`

## Backend Deployment (Podman Compose)

On `root@100.116.176.87`:

```bash
su - press-api
cd /home/press-api/Press.Zone-Works/press-zone-backend

# rebuild and restart
podman-compose -f podman-compose.yml up -d --build

# check
podman ps --filter name=presszone --format "table {{.Names}}\t{{.Status}}"
curl -i http://127.0.0.1:3000/health
```

Important env var note:
- The API container requires `JWT_ADMIN_SECRET`.
- Ensure `podman-compose.yml` passes `JWT_ADMIN_SECRET` into the `api` service.

## Admin Panel Deployment

The admin panel is deployed as a static SPA under:
- URL: `https://api.press.zone/admin/`
- Files on Apache host:
  - `/home/dev1/public_html/admin/`

Build command (local dev machine):

```bash
cd wp-content/press-zone-backend/admin-panel
VITE_API_URL='https://api.press.zone' VITE_BASE='/admin/' npm run build
```

Deploy command (from local dev machine):

```bash
rsync -az --delete wp-content/press-zone-backend/admin-panel/dist/ \
  root@100.109.41.8:/home/dev1/public_html/admin/
```

SPA routing:
- The build uses `/admin/` base.
- React Router runs with `basename={import.meta.env.BASE_URL}`.

## Admin Credentials (Production)

Admin user:
- Email: `admin@press.zone`
- Password: `VJTat6C2OcntfIiTms40qb3_tQ6nRIgQ`

Login endpoints:
- UI: `https://api.press.zone/admin/login`
- API: `POST https://api.press.zone/v1/admin/auth/login`

Example login request:

```bash
curl -s -X POST https://api.press.zone/v1/admin/auth/login \
  -H 'Content-Type: application/json' \
  -d '{"email":"admin@press.zone","password":"VJTat6C2OcntfIiTms40qb3_tQ6nRIgQ"}'
```

