-
ERP Public API: Used by frontend, n8n, and AI tools.
- Port: 3000 (local), 443 (production)
- Authentication: JWT
-
n8n Webhook URL: Receives event pushes from Worker.
- Port: 5678 (local), 443 (production)
- Authentication: Basic Auth (username/password)
-
Worker: Sends events to n8n Webhook URL via HTTPS.
- No direct DB access.
- n8n and AI do not connect directly to PostgreSQL.
- AI tools are in-process modules inside the ERP API.
- Tenant isolation is enforced via
organization_idon all tenant-scoped entities.
-
JWT for API authentication:
- Token includes
user_id,organization_id,roles,permissions. - Token expires after 24 hours.
- Refresh token issued on login.
- Token includes
-
Basic Auth for n8n Webhook URL:
- username/password configured via environment variables.
- Shared secret between Worker and n8n.
- Never commit secrets (e.g.,
.env). - Use environment variables for configuration.
- Secrets managed by Fly.io in production.
- RBAC: Role-Based Access Control.
- Permissions: Fine-grained permissions on entities.
- Tenant Context: All queries filtered by
organization_id.
- Every mutation records an
AuditLogentry. - Includes: user_id, action, entity_type, entity_id, metadata.
- AI tools have explicit authorization context.
- Critical mutations require explicit human approval.
- AI cannot perform destructive actions autonomously.