# Pause POS: deploy steps

This zip is ready to upload. Nothing needs to be built or installed with Composer or npm.

| Folder | Goes to |
|---|---|
| `api/` | anywhere outside the public web folder, e.g. `~/pause/api`. Only `api/public` is served, as `api.yourdomain.com` |
| `app/` | the web folder of `app.yourdomain.com` (upload what is **inside** `app/`, including the hidden `.htaccess`) |

You need: Hostinger hosting with **SSH access**, **PHP 8.4**, a MySQL database, and SSL switched on for both subdomains.

## 1. API

1. Upload `api/` to the server and unzip it there (uploading the zip and extracting in File Manager is much faster than thousands of single files).
2. In hPanel, set PHP to 8.4 and create a MySQL database and user.
3. Point `api.yourdomain.com` at the `api/public` folder.
4. Over SSH:

   ```sh
   cd ~/pause/api
   cp .env.example .env
   nano .env                  # set the two domains, DB_*, ADMIN_PHONE, ADMIN_PASSWORD
   php artisan key:generate
   php artisan migrate --force
   php artisan db:seed --force
   php artisan storage:link
   php artisan config:cache && php artisan route:cache
   ```

5. Open `https://api.yourdomain.com/api/health`. It should show `"status":"ok"`.

Whenever you edit `.env` later, run `php artisan config:cache` again.

## 2. Frontend

1. Upload the contents of `app/` to the web folder of `app.yourdomain.com`.
2. If your sites are `app.yourdomain.com` and `api.yourdomain.com`, you are done: the API address is worked out automatically.
   For any other names, edit `config.js` on the server:

   ```js
   window.POS_API_URL = "https://api.yourdomain.com/api";
   ```

3. Open `https://app.yourdomain.com` and log in with `ADMIN_PHONE` and `ADMIN_PASSWORD`.

If login says it cannot reach the server, `FRONTEND_URL` in `api/.env` does not exactly match the frontend's address
(`https://`, no trailing slash). Fix it and run `php artisan config:cache`.

## 3. Cron (one job, every minute)

hPanel → Advanced → Cron Jobs:

```
* * * * * /usr/bin/php /home/uXXXXXXXX/pause/api/artisan schedule:run >> /dev/null 2>&1
```

Use the PHP 8.4 path shown on that page and your real folder.

## 4. First things to do as admin

1. **Platform settings:** support phone (shown on the login page), bKash/Nagad numbers.
2. **Plans:** check the prices. Two plans are seeded: Basic and Standard.
3. **Shops → Add shop:** create each shop with the owner's mobile number and a password, then give those to the owner.
4. Remove `ADMIN_PASSWORD` from `.env` and run `php artisan config:cache`.

## 5. On each shop's PC

Follow `docs/silent-printing.md` to print receipts without the print window, and print one test receipt
before the shop relies on it.

## Good to know

- **Backups** are saved on the same server by default (`BACKUP_DISK=local`, in `api/storage/app/private`).
  That does not protect you if the server is lost. Set up the S3 bucket described in `docs/deployment-hostinger.md`,
  or download a backup from hPanel every week.
- **SMS is off.** Shops cannot register themselves or reset passwords by SMS; you do both from the admin panel.
- The full guide, including updates and restoring a backup, is `docs/deployment-hostinger.md`.
