# ABM SMS Gateway

Multi-tenant SMS Gateway SaaS for the Bangladesh market, built on CodeIgniter 4 / PHP 8.2 / MySQL. See [CLAUDE.md](CLAUDE.md) for the short version and [docs/SPEC.md](docs/SPEC.md) for the full spec, [docs/PLAN.md](docs/PLAN.md) for the phased build plan.

All 11 build phases (0-10) are complete. Three surfaces:

- **`/api/v1`** — the tenant-facing REST API (SPEC §5). Reference: [docs/api.md](docs/api.md) ([Bangla quick-start](docs/api.bn.md)), [Postman collection](docs/postman/abmsms.postman_collection.json), PHP SDK: [sdk/](sdk/) ([`AbmSms.php`](sdk/AbmSms.php) - single dependency-free file, PHP 7.2+, cURL only; CI3 integration example under [sdk/examples/ci3/](sdk/examples/ci3/)).
- **`/admin/login`** — ABM Soft's internal admin panel (SPEC §8): tenants, providers, pricing, sender ID approval, message/ledger explorers, audit log. `spark db:seed AdminUserSeeder` creates the first login.
- **`/portal/login`** — tenant self-service portal (SPEC §9): send SMS, message history, reports, sender ID requests, API credentials, webhooks, ledger. Full English/Bangla toggle. `spark db:seed TestTenantSeeder` creates a demo tenant + first login.

Deployment (supervisor/cron samples for every worker command): [docs/deployment.md](docs/deployment.md).

## Live VPS with LAMP (no Docker)

Follow the [LAMP VPS setup guide](docs/lamp-vps-setup.md) for Apache/PHP-FPM, an existing client database, HTTPS, workers, and scheduled jobs.

## Local development (Docker)

The host machine only has PHP 7.4; this app requires PHP 8.2+, so all development happens inside Docker.

```bash
# one-time setup
cp .env.example .env
docker compose build app
docker compose run --rm cli php spark key:generate -n

# database
docker compose run --rm cli php spark migrate --all -n
docker compose run --rm cli php spark db:seed DatabaseSeeder -n

# run the app
docker compose up -d
# -> http://localhost:8095/

# one-off commands (composer, spark, phpunit) without starting the whole stack
docker compose run --rm cli <command>
docker compose run --rm cli php spark routes
docker compose run --rm cli vendor/bin/phpunit
```

The `mysql` service also creates a second database, `abmsms_test`, used by the `tests` connection group (real MySQL, not SQLite — the credit ledger's concurrency tests need genuine `SELECT ... FOR UPDATE` row locking).

Table prefix is `sms_` (set once in `Config\Database`, applied automatically by CodeIgniter — migrations and models use bare table names like `tenants`, not `sms_tenants`).
