# COLORJET Unified Sync Suite — VPS Deployment

## 1. Minimum server

- Ubuntu 22.04/24.04 VPS
- 4 vCPU, 8 GB RAM, 80 GB SSD recommended
- Public IPv4, domain and SSL
- Docker Engine + Docker Compose plugin

## 2. Production environment

Root folder-এ `.env.example` কপি করে `.env` করুন।

```bash
cp .env.example .env
```

Mandatory values:

```env
POSTGRES_PASSWORD=REPLACE_WITH_LONG_UNIQUE_PASSWORD
JWT_ACCESS_SECRET=REPLACE_WITH_64_PLUS_CHAR_RANDOM_SECRET
JWT_REFRESH_SECRET=REPLACE_WITH_ANOTHER_64_PLUS_CHAR_RANDOM_SECRET
BOOTSTRAP_TOKEN=REPLACE_WITH_ONE_TIME_RANDOM_TOKEN
WEB_ORIGIN=https://erp.yourdomain.com
PUBLIC_BASE_URL=https://erp.yourdomain.com
EXPO_PUBLIC_API_BASE_URL=https://erp.yourdomain.com/api
```

Never put these values in GitHub, Android source, screenshots or WhatsApp chat.

## 3. Start services

```bash
docker compose up -d --build
docker compose ps
curl http://127.0.0.1:8080/api/health
```

The health endpoint must return `ok: true` before user creation or data migration.

## 4. Create first Owner account

There is no default Owner/Admin password in the source. Run this only once:

```bash
docker compose exec server npm run create:owner:docker -- \
  --name "Owner Name" \
  --email "owner@yourdomain.com" \
  --phone "01XXXXXXXXX"
```

The command asks for a new password from secure shell input. Do not keep it in terminal history.

## 5. Set domain and SSL

Point `erp.yourdomain.com` to the VPS. Update `deploy/nginx/default.conf` server name, then install a certificate using your own reverse proxy/Certbot approach. Only HTTPS should be exposed publicly.

## 6. Operations

```bash
docker compose logs -f server
docker compose restart server
docker compose up -d --build
docker compose exec postgres pg_dump -U colorjet colorjet_erp > colorjet-backup.sql
```

Database backup must be encrypted and stored outside the public web root.

## cPanel note

This implementation is designed for VPS/Docker because Socket.IO, long-running Node.js API and PostgreSQL are central to real-time synchronization. A normal shared cPanel PHP/MySQL account is not equivalent. Use cPanel only when it supports a persistent Node.js application, reverse proxy/WebSocket and managed PostgreSQL; otherwise use VPS.
