# Deploying this package

This is a production build of the Mini Max admin/API backend: PHP dependencies are
already installed (`composer install --no-dev --optimize-autoloader`) and the admin
panel's CSS/JS are already compiled (`public/build/`). You do not need Node or Composer
on the server to run it — only PHP 8.3+ and your web server.

## 1. Upload and configure

1. Upload this folder's contents to your server (e.g. `/var/www/minimax`).
2. Copy `.env.production.example` to `.env` and fill in every blank value:
   `APP_URL`, `DB_*` (MySQL), mail, and the payment/push credentials you use.
3. Generate the app key: `php artisan key:generate --force`
4. Point your web server's document root at this project's `public/` folder
   (not the project root).

## 2. Database and storage

Before seeding, set `SEED_ADMIN_PASSWORD` in `.env` to a real, freshly generated
password — the seeder's fallback (`change-me-now`) must never reach production.

```bash
php artisan migrate --force
php artisan db:seed --force
php artisan storage:link
```

`db:seed` creates the permission catalog, one super-admin account
(username `admin`, the password you set above), and a couple of harmless starter
rows (a demo game/tournament, the Alpha UPI gateway row) you can edit or delete
from the admin panel. Log in at `/admin/login` and change the admin password from
there on first login regardless.

## 3. File permissions

Make `storage/` and `bootstrap/cache/` writable by the web server user:

```bash
chown -R www-data:www-data storage bootstrap/cache
chmod -R 775 storage bootstrap/cache
```

## 4. Cache for performance (recommended)

Run these **after** `.env` is final — they bake the current config into fast cache
files, so re-run them after any `.env` or route change:

```bash
php artisan config:cache
php artisan route:cache
php artisan view:cache
```

## 5. Background jobs — required for the app to function correctly

Two things must run continuously/on schedule, or notifications, salary accrual,
auto-generated tournaments and auto-cancellation will silently stop working:

- **Queue worker** (process notifications, settlements, etc.):
  `php artisan queue:work --tries=3` under a process supervisor (systemd/Supervisor).
- **Scheduler** (daily tournament auto-generation at 1:00 AM Asia/Kolkata, staff
  salary accrual, auto-cancellation sweeps, etc.) — add one cron entry:
  ```
  * * * * * cd /var/www/minimax && php artisan schedule:run >> /dev/null 2>&1
  ```

## 6. Credentials you'll still need to enter from the Admin panel

These are deliberately **not** baked into this build — configure them after first
login, from Admin → Payment Settings / Settings, rather than in `.env`:

- Payment gateway (Alpha UPI) credentials — Admin → Payment Settings → Configure.
- Firebase Admin SDK service account JSON, for push notifications — place at
  `storage/app/firebase/service-account.json` (see `.env.production.example`).

## What's included

- `vendor/` — production PHP dependencies only (no test/dev tooling).
- `public/build/` — compiled admin panel assets.
- Full `database/migrations` — covering every feature up to and including the
  4-role Staff Management system (Manager/Worker/Result Maker/Customer Support).

## What's excluded

Tests, CI config, and anything from `.gitignore` (your real `.env`, logs, local
SQLite databases) — none of that belongs in a production deployment.
