# Deployment — v0.2.0

## Server requirements

- PHP 8.4+
- PHP extensions:
  - PDO / pdo_mysql
  - mbstring
  - OpenSSL
  - fileinfo
  - ZIP
- MySQL 8-compatible database for production
- web root pointed to `/public`
- writable:
  - `storage/`
  - `bootstrap/cache/`
- HTTPS before commercial use

## Fresh installation

1. Upload the full project package.
2. Run `composer install --no-dev --optimize-autoloader`.
3. Copy `.env.example` to `.env`.
4. Configure `APP_URL` and database credentials.
5. Production values must include:
   - `APP_ENV=production`
   - `APP_DEBUG=false`
   - `SESSION_SECURE_COOKIE=true`
   - `OTP_DRIVER=sms`
6. Run `php artisan key:generate` once for a new installation.
7. Run `php artisan migrate --seed --force`.
8. Create/promote the first Super Admin:
   `php artisan system:make-super-admin 0912XXXXXXX --name="مدیر سامانه"`
9. Configure Mida SMS:
   `php artisan system:configure-mida-sms`
   or Admin → پیامک.
10. Run `php artisan optimize`.
11. Publish only the `public/` directory through the web server.

Never regenerate `APP_KEY` on an existing installation: Phase 2 encrypts SMS
credentials with the application key.

## Upgrade from v0.1.0

Use Admin → Update Center and upload the official
`estelam-update-v0.1.0-to-v0.2.0.zip` package. The installer validates hashes,
backs up affected project files/database state, enters Maintenance Mode, runs
pending migrations, records the version, clears caches and rolls back when a
sensitive step fails.

The updater deliberately does not replace `.env`. A legacy installation may
still contain `OTP_DRIVER=log`; outside `local`/`testing`, v0.2.0 refuses to use
the log sender and selects the SMS sender instead. Configure Mida before ending
the currently authenticated administrator session.

## Authentication and SMS

Phase 2 has a production OTP path with:

- random six-digit OTP;
- HMAC-only database storage;
- expiry and single-use consumption;
- resend cooldown;
- independent per-mobile / per-IP request limits;
- verification attempt limiting;
- Persian/Arabic digit normalization;
- persistent database sessions;
- real SMS delivery through the central SMS service.

Mida credentials are encrypted at rest and never placed in frontend JavaScript.
The adapter restricts its configurable endpoint to HTTPS on `sms.mida-co.ir`.
Message sends are not automatically retried after connection timeout because the
provider may already have accepted the SMS; ambiguous connection results are
tracked separately instead of risking duplicate OTP delivery.

## Queue

Database queue tables exist. Phase 2 notification delivery is intentionally
synchronous so its delivery state is deterministic without requiring a worker.
Queue-backed asynchronous delivery can be introduced behind the same
Notification Service contract when channel volume justifies it.

## IRANSans

The central CSS references `public/fonts/IRANSans.woff2`. The licensed font
binary is intentionally not bundled. Put the licensed webfont at that path
during deployment.
