# IDURAR Production Readiness

## What was hardened in code

- Backend startup now validates critical environment variables before boot.
- Production CORS is restricted through `CORS_ALLOWED_ORIGINS`.
- Auth and API rate limiting are enabled.
- Security headers are applied at the API layer.
- Health check endpoint is available at `GET /healthz`.
- Frontend demo mode is disabled automatically for production builds.
- Temporary passwords for newly created users are generated randomly instead of using a shared default.

## Required backend environment variables

Use [`backend/.env.example`](/C:/Users/DELL/OneDrive/Dokumente/idurar-erp-crm-master/backend/.env.example) as the baseline.

Minimum required:

- `NODE_ENV=production`
- `DATABASE`
- `JWT_SECRET`
- `INTEGRATION_ENCRYPTION_KEY`
- `SETUP_ADMIN_EMAIL`
- `SETUP_ADMIN_PASSWORD`
- `CORS_ALLOWED_ORIGINS`

Recommended:

- `TRUST_PROXY=true`
- `AUTOMATION_WORKER_ENABLED=true`
- `AGENT_WORKER_ENABLED=true`
- provider credentials such as `OPENAI_API_KEY`, `KIMI_API_KEY`, `HERMES_API_KEY`, `RESEND_API`, `META_ACCESS_TOKEN`, `FAL_KEY`

## Required frontend environment variables

Use [`frontend/.env.example`](/C:/Users/DELL/OneDrive/Dokumente/idurar-erp-crm-master/frontend/.env.example).

- `VITE_BACKEND_SERVER=https://api.yourdomain.com/`
- `VITE_DEMO_MODE=false`

## Release checklist

1. Set production env vars for backend and frontend.
2. Confirm MongoDB production connectivity and backups.
3. Confirm HTTPS is terminated at the load balancer or reverse proxy.
4. Set `CORS_ALLOWED_ORIGINS` to only trusted frontend domains.
5. Rotate any old integration secrets and store fresh ones through the admin UI or deployment secrets.
6. Run:
   - `node --test tests\platform.test.js tests\agents.test.js`
   - `npm.cmd run build`
7. Smoke-test:
   - login/logout
   - tenant-scoped CRUD
   - user creation
   - AI provider settings
   - automation run due jobs
   - POS session open and checkout
8. Verify `GET /healthz` returns `200`.
9. Turn off any demo deployment flag and confirm demo login no longer works in production.

## Remaining non-code production work

- Deployment secrets must be populated in your hosting environment.
- Database backup, restore, and monitoring must be configured outside the repo.
- Reverse proxy, TLS certificates, and domain routing must be configured outside the repo.
- Object storage credentials for uploads must be configured if file uploads are needed in production.
