Knowledge Portal · engineering documentation

Skip to content

Federated from workspace · PRD-001 · Dental Clinic Revenue Operating System/docs/deployment/PRODUCTION_RUNBOOK.md Do not edit canonical truth here — update the source repo, then re-run npm run docs:sync.


AI Clinic OS — Production Runbook

Operational guide for deploying and running the first managed production pilot. This is not marketing documentation.

1. Server requirements

ComponentMinimumRecommended
OSUbuntu 22.04 LTSUbuntu 24.04 LTS
CPU2 vCPU4 vCPU
RAM4 GB8 GB
Disk40 GB SSD80 GB SSD

PHP 8.2+ extensions

bcmath ctype curl dom fileinfo json mbstring openssl pdo pdo_pgsql tokenizer xml zip

Optional but recommended: redis, intl, gd or imagick.

2. Stack

  • Web: Nginx (or Caddy) terminating HTTPS
  • App: PHP-FPM 8.2+
  • Database: PostgreSQL 15+
  • Queue: Redis (recommended) or database driver
  • Cache: Redis (recommended) or database
  • Scheduler: system cron → php artisan schedule:run
  • Workers: Supervisor managing queue:work

3. Initial deploy

bash
git clone <repository-url> /var/www/ai-clinic-os
cd /var/www/ai-clinic-os

composer install --no-dev --optimize-autoloader
cp .env.example .env
php artisan key:generate

npm ci
npm run build

4. Environment variables (production)

VariableRequiredNotes
APP_ENVyesproduction
APP_DEBUGyesfalse
APP_URLyeshttps://your-domain.com
DB_CONNECTIONyespgsql
DB_HOST, DB_PORT, DB_DATABASE, DB_USERNAME, DB_PASSWORDyesPostgreSQL
QUEUE_CONNECTIONyesredis or database — never sync
CACHE_STOREyesredis or database
SESSION_DRIVERyesdatabase or redis
MAIL_MAILERyessmtp, ses, or postmark
MAIL_FROM_ADDRESSyesVerified sender
MAIL_FROM_NAMEyesClinic product name
TENANCY_ENABLEDyestrue for SaaS pilot
TENANCY_BASE_DOMAINyese.g. dentrevenue.com
SAAS_BILLING_PROVIDERyesstripe in production
SAAS_CUSTOMER_EXPERIENCE_REQUIRE_EMAIL_VERIFICATIONyestrue
REDIS_HOSTif using redis
AWS_* / STRIPE_*as neededBilling and object storage

Run php artisan config:cache and php artisan route:cache after env changes.

5. Database

bash
php artisan migrate --force
php artisan db:seed --class=PilotProductionSeeder   # first pilot clinic only

For upgrades:

bash
php artisan migrate --force
php artisan optimize:clear
php artisan config:cache
php artisan route:cache
php artisan view:cache

6. Storage and permissions

bash
chown -R www-data:www-data storage bootstrap/cache
chmod -R ug+rwx storage bootstrap/cache
php artisan storage:link

Ensure storage/app, storage/logs, and bootstrap/cache are writable by PHP-FPM.

7. Queue workers (Supervisor)

/etc/supervisor/conf.d/ai-clinic-os-worker.conf:

ini
[program:ai-clinic-os-worker]
process_name=%(program_name)s_%(process_num)02d
command=php /var/www/ai-clinic-os/artisan queue:work redis --sleep=3 --tries=3 --max-time=3600
autostart=true
autorestart=true
stopasgroup=true
killasgroup=true
user=www-data
numprocs=2
redirect_stderr=true
stdout_logfile=/var/www/ai-clinic-os/storage/logs/worker.log
stopwaitsecs=3600
bash
supervisorctl reread && supervisorctl update && supervisorctl start ai-clinic-os-worker:*

8. Scheduler (cron)

cron
* * * * * www-data cd /var/www/ai-clinic-os && php artisan schedule:run >> /dev/null 2>&1

Critical scheduled commands:

  • reminders:process — every 15 minutes
  • autopilot:run — hourly (when enabled)
  • clinic-ai:run — every 10 minutes (when enabled)
  • saas:billing — daily
  • workflow:process-schedules — every minute

9. HTTPS and health checks

  • Terminate TLS at Nginx/Caddy; forward X-Forwarded-Proto
  • Health endpoint: GET /up (Laravel 11 built-in)
  • After deploy: curl -f https://your-domain.com/up

10. Pilot validation

Before onboarding the first paying clinic:

bash
php artisan pilot:validate-deployment
php artisan pilot:validate-deployment --strict   # production: fail on warnings
php artisan test --filter=ProductionSmokeTest
php artisan test --filter=PilotDeploymentReadinessTest
php artisan test --filter=PilotWorkflowTest

All checks must show PASS (warnings reviewed in strict mode).

11. First clinic onboarding

  1. Owner visits /signup (Threshold experience)
  2. Completes workspace preparation → receives verification email (Settle phase)
  3. Clicks verification link → organization onboarding wizard
  4. Completes clinic profile, branding, plan selection
  5. Assign receptionist and doctor accounts via Team page
  6. Configure SMTP-sent reminders and working hours
  7. Run one test lead → booking → appointment through CRM

Optional: seed demo data with PilotProductionSeeder for training environments only.

12. Backups

bash
php artisan backup:run

Configure config/backup.php for off-site storage (S3). Verify restore quarterly.

13. Rollback

  1. Put app in maintenance: php artisan down
  2. Restore previous release tag / deployment artifact
  3. Roll back database if migration was destructive (restore from backup)
  4. composer install --no-dev, npm run build, php artisan migrate:status
  5. Restart workers and PHP-FPM
  6. php artisan up
  7. Re-run pilot:validate-deployment

14. Disaster recovery

ScenarioResponse
Database lossRestore latest PostgreSQL backup; replay queue dead letter if any
Redis lossRestart Redis; cache rebuilds automatically; queue may need replay
Worker stoppedSupervisor autostart; check storage/logs/worker.log
Mail failureVerify SMTP credentials; check failed jobs table
Scheduler stoppedRestore cron; run reminders:process manually once

15. Common production failures

SymptomLikely causeFix
Verification emails not sentQUEUE_CONNECTION=sync or worker downEnable queue + supervisor
Reminders never fireCron missingAdd schedule:run cron
403 after loginTenant not resolvedCheck TENANCY_BASE_DOMAIN, DNS
Mixed content / bad linksAPP_URL not HTTPSSet APP_URL=https://...
Upload failuresStorage not writableFix permissions on storage/
Stripe webhooks failWrong endpoint secretUpdate STRIPE_WEBHOOK_SECRET

16. Verification checklist

  • [ ] php artisan pilot:validate-deployment --strict passes
  • [ ] GET /up returns 200
  • [ ] Signup → verify email → onboarding completes
  • [ ] Admin login works for owner, receptionist, doctor
  • [ ] Queue worker processing (check jobs table emptying)
  • [ ] Cron running (schedule:list matches bootstrap schedule)
  • [ ] Test reminder email delivered
  • [ ] PostgreSQL backups scheduled
  • [ ] HTTPS certificate valid
  • [ ] Pilot workflow test passes on staging

Authority: Consumer deployment operations · complements docs/DEPLOYMENT-CHECKLIST.md and docs/PILOT-WORKFLOW.md.

ZAIXOS Knowledge Portal — public engineering docs at /docs · Staff operations at /admin