ASI Database Node API

Configuration

New production defaults and engine contract: see MySQL v14. DATABASE_ENGINE=mysql (default), mariadb or postgresql is canonical. DB_ENGINE is a compatibility alias and must agree if both are configured. Remote connections require DB_SSL_CA and verified TLS. Existing v13 targets keep PostgreSQL.

Canonical production origin: https://asi-database-node-api.arybit.co.ke.

Copy deployment examples using bash init-deploy-database-api.sh. Keep target-specific configuration private. The production target must use domain=asi-database-node-api.arybit.co.ke; aliases need their own DNS records and certificate coverage. Staging retains its separate hostname.

Runtime settings read by backend/core/config.py:

Variable Meaning / default
ENV development, test, staging or production; default development
API_HOST / API_PORT 127.0.0.1 / 8080
DB_ENGINE postgresql or mysql; default postgresql
DB_HOST Loopback database host; default 127.0.0.1
DB_PORT 5432 for PostgreSQL; 3306 for MySQL
DB_NAME / DB_USER / DB_PASSWORD Explicit private database credentials
ALLOWED_HOSTS Comma-separated hostnames, without scheme or paths
CORS_ORIGINS Comma-separated origins, without paths

Production runtime host settings:

ENV=production
DB_ENGINE=postgresql
DB_HOST=127.0.0.1
DB_PORT=5432
ALLOWED_HOSTS=asi-database-node-api.arybit.co.ke,www.asi-database-node-api.arybit.co.ke,localhost,127.0.0.1
CORS_ORIGINS=https://asi-database-node-api.arybit.co.ke

Add privately provisioned DB_NAME, DB_USER and DB_PASSWORD. Deployed passwords must have at least 16 characters and cannot contain placeholder markers. Remote DB hosts are rejected in deployed settings because driver TLS is not implemented. Protect environment files with mode 0600. The deployment renderer derives runtime hosts and CORS from the selected target.

ui/config.json uses the current HTTPS origin when apiBase is empty. Keep contractVerified false until a session/login/logout contract actually exists; the current diagnostic backend does not provide it.

Authentication persistence contract

APPLICATION_API_ENABLED=1 enables /api/v1 operations only with DB_ENGINE=mysql and explicit database credentials. Default 0 preserves diagnostic deployments. DB_POOL_SIZE=8 bounds connections per worker (1–64); DB_TIMEOUT=5 bounds acquisition, connect and socket waits (1–30 seconds). Remote database hosts remain rejected; there is no implicit insecure TLS mode. Credential registry and schema provisioning are separate administrator actions; see database-qualification.md and security.md. No service key belongs in ui/config.json or the ordinary DB runtime environment.

Dual interface configuration

Backend remote MySQL transport now requires a readable DB_SSL_CA; verification cannot be disabled using DB_SSL_VERIFY_CERT/DB_SSL_VERIFY_IDENTITY. DIRECT_DATABASE_ENABLED=1 also requires MySQL plus DB_SSL_CA and permits the explicit direct-listener path through deployment validation. PostgreSQL compatibility defaults are retained; select MySQL explicitly for this target. API_SERVICE_RATE_PER_MINUTE=120 applies across workers/credentials for a registered tenant/service. DB_HOST must have no URL scheme or connection options. Client PHP settings live separately in .env.example. Server listener planning uses templates/direct-interface.env.example. Its DIRECT_PUBLIC_ACCESS=1 setting explicitly authorizes only the proposed database port exposure, not SSH/admin rules. The planner performs no changes.