# DeliverUs Dev server — tester access

Publish Admin, Store, Landing, and API on one server so QA can open URLs without local installs.

## Tester URLs

Replace `YOUR_SERVER_IP` with the server IP or domain.

| App | URL |
|-----|-----|
| **Landing** (public / register) | `http://YOUR_SERVER_IP:3000` |
| **Store** (merchant panel) | `http://YOUR_SERVER_IP:3001` |
| **Admin** (platform panel) | `http://YOUR_SERVER_IP:3002` |
| **API** (Swagger / health) | `http://YOUR_SERVER_IP:3030/api/v1` |
| **WebSocket** (chat / location) | `ws://YOUR_SERVER_IP:1234` |

Seeded admin (after DB seed): `admin@admin.com` / `Default@123`  
Seeded store vendor (after DB seed): `store@store.com` / `Default@123`  
OTP in Dev: `1234` (via `DEFAULT_OTP`)

---

## One-time setup on the server

### 1. Prerequisites

- Docker + Docker Compose plugin
- Ports open: **3000, 3001, 3002, 3030, 1234** (and **3307** only if you need external DB access)
- Project files copied to the server (this repo root)

### 2. Create root Dev env

```bash
cp .env.dev.example .env.dev
# Edit DEV_HOST=... to the IP/domain testers will use (not localhost)
```

Example:

```dotenv
DEV_HOST=203.0.113.10
```

Frontends bake this host into the JS bundle at **build** time. If you change `DEV_HOST`, rebuild:

```bash
docker compose -f docker-compose.dev.yml --env-file .env.dev up -d --build
```

### 3. Create API `.env`

```bash
cp deliver-us-api-manage/deliver-us-api-manage/.env.example \
   deliver-us-api-manage/deliver-us-api-manage/.env
```

If `.env.example` is missing, use the template in `deliver-us-api-manage/deliver-us-api-manage/STAGING.md` (section 2).

Important Dev values:

- `DATABASE_URL` is overridden by Compose to point at the `mysql` service — still keep a valid URL in `.env` for local Prisma tools.
- Set secrets (`ACCESS_TOKEN_SECRET`, etc.) to non-production values.
- Keep `DEFAULT_OTP=1234` only on Dev.
- Set `FRONTEND_URL=http://YOUR_SERVER_IP:3000`
- Provide a valid `FIREBASE_PRIVATE_KEY` (stub PEM is enough to boot; see STAGING.md)

### 4. Start the stack

From the **repo root**:

```bash
docker compose -f docker-compose.dev.yml --env-file .env.dev up -d --build
```

### 5. Seed the database (first time)

```bash
docker exec -it deliverus-dev-api sh -c "npm run db:seed"
```

### 6. Smoke checks

```bash
curl -s -o /dev/null -w "%{http_code}\n" http://YOUR_SERVER_IP:3030/api/v1
curl -s -o /dev/null -w "%{http_code}\n" http://YOUR_SERVER_IP:3000
curl -s -o /dev/null -w "%{http_code}\n" http://YOUR_SERVER_IP:3001
curl -s -o /dev/null -w "%{http_code}\n" http://YOUR_SERVER_IP:3002
```

Expect `200` (or `307`/`308` redirects for Next.js is also fine).

---

## What was changed in the codebase

- Admin / Store / Landing `utils/config.ts` now read `NEXT_PUBLIC_API_*` and websocket URLs from env (fallback remains the old production host if unset).
- Frontend Dockerfiles accept those values as **build args**.
- Root `docker-compose.dev.yml` + `.env.dev.example` publish all four apps with fixed tester ports.

---

## Notes for QA

- This is a **Dev** stack: fixed OTP, staging secrets, separate MySQL — do not use production keys.
- If HTTPS/domains are required later, put Nginx (or similar) in front and rebuild frontends with `https://` / `wss://` URLs.
- Mobile apps are not included in this compose.

---

## Stop / reset

```bash
docker compose -f docker-compose.dev.yml --env-file .env.dev down
# wipe DB volume (destructive):
docker compose -f docker-compose.dev.yml --env-file .env.dev down -v
```
