Skip to content

Data Backend Proposal - Update Summary

Date: November 9, 2025
Updates: RBAC, Apps/Trigger Separation, Better Stack Integration


You requested three critical updates to the data backend proposal:

  1. Add RBAC (role-based permissions, not just org-level)
  2. Use Trigger.dev Python Extension (eliminate Spark cluster)
  3. Separate Trigger.dev into its own app (apps/trigger instead of apps/webapp/src/trigger)
  4. Better Stack Integration (export Trigger.dev traces)

5 Role Levels Defined:

owner β†’ Full access + billing
admin β†’ Manage connections, users, all data
data_analyst β†’ Read ERP data, run reports (NEW!)
editor β†’ Create/edit orders, upload PDFs
viewer β†’ Read-only access

Implementation:

  • Clerk Organizations integration
  • Cube RLS with role-based row filtering
  • Field-level masking (hide pricing from viewers)
  • Middleware authorization for API routes

Files Updated:

  • docs/architecture/data-backend-implementation-guide.md (lines 22-278)

New Structure:

erp-unlocked/
β”œβ”€β”€ apps/
β”‚ β”œβ”€β”€ webapp/ β†’ Coolify (frontend only)
β”‚ └── trigger/ β†’ Trigger.dev Cloud (background tasks)
└── packages/
└── data-backend/ β†’ Configs (Cube, Trino, Hudi)

Benefits:

  • Clear deployment boundaries
  • Independent dependency management
  • Better CI/CD (only changed app rebuilds)
  • 6-week phased migration plan provided

Files Created:

  • Migration checklist in implementation guide (lines 573-750)

Eliminated:

  • ❌ Separate Spark cluster
  • ❌ Separate dlt containers
  • ❌ Complex orchestration

New Approach:

// Python ETL runs inside Trigger.dev tasks
export const syncERPProducts = schemaTask({
id: 'sync-erp-products-v2',
run: async payload => {
const result = await python.runScript('./src/python/etl/prophet21_products.py', []);
},
});

Cost Savings: $200/month (no Spark cluster)

Files Updated:

Current Issue: Trigger.dev v4 traces NOT sent to Better Stack (telemetry commented out)

Solution Provided:

apps/trigger/trigger.config.ts
telemetry: {
exporters: [
new OTLPTraceExporter({
url: "https://in-otel.betterstack.com/v1/traces",
headers: {
Authorization: `Bearer ${process.env.BETTER_STACK_SOURCE_TOKEN}`,
},
}),
],
logExporters: [
new OTLPLogExporter({
url: "https://in-otel.betterstack.com/v1/logs",
headers: {
Authorization: `Bearer ${process.env.BETTER_STACK_SOURCE_TOKEN}`,
},
}),
],
serviceName: "erp-unlocked-trigger-tasks",
}

Files Created:

  • docs/architecture/trigger-betterstack-integration.md (complete setup guide)
  • Implementation guide updated (lines 903-1018)

DocumentPurposeKey Updates
data-backend-implementation-guide.mdImplementation detailsβ€’ RBAC section added
β€’ Apps/trigger separation
β€’ Better Stack integration
β€’ All diagrams now Mermaid
trigger-betterstack-integration.mdBetter Stack setupβ€’ 5-minute setup guide
β€’ Troubleshooting
β€’ Environment variables
QUICK_START.mdDecision guideβ€’ Updated for apps/trigger
β€’ Better Stack mentioned
README.mdNavigationβ€’ Added new docs to index

Previous Estimate: $875/month
- With Spark cluster: $50/month
New Estimate: $725/month (52% savings from current!)
- Eliminated Spark: $0
- Downsized Trino: $150 (was $250)
- Total savings: $775/month vs current $1,500
Annual Savings: $9,300
3-Year Savings: $27,900

Additional savings from apps/trigger separation:

  • Faster deployments (no full webapp rebuild)
  • Reduced Trigger.dev compute (smaller bundle size)

No migration needed. Current version: "@trigger.dev/sdk": "4.0.4"

The telemetry config was just commented out for β€œv3 compatibility” but you’re already on v4.

  1. Add BETTER_STACK_SOURCE_TOKEN to .env
  2. Uncomment telemetry config in trigger.config.ts
  3. Deploy trigger tasks
  4. Done! Traces appear in Better Stack

Benefits outweigh migration cost:

  • 6-week phased migration (low risk)
  • Clear deployment boundaries
  • Better CI/CD
  • Clean foundation for data backend

  1. Review apps/trigger structure - Decide if separation makes sense for your team
  2. Enable Better Stack integration - 5-minute fix to get traces flowing
  3. Test Python extension - Validate approach with one ETL pipeline
  1. Week 1: Create apps/trigger/ structure
  2. Week 2: Move existing tasks
  3. Week 3: Enable Better Stack telemetry
  4. Week 4-5: Parallel testing
  5. Week 6: Cutover decision
  1. Weeks 7-12: Implement data backend (if pilot succeeds)
  2. Weeks 13-18: Full migration to Hudi lakehouse

A: No! You’re already on v4 (4.0.4). Just enable the telemetry config.

A: Yes, recommended. Clear deployment boundaries, independent versioning, better CI/CD. 6-week migration plan provided.

A: Enable OpenTelemetry exporters in trigger.config.ts. Complete guide provided in trigger-betterstack-integration.md.

A:

  • ETL tasks: apps/trigger/src/tasks/data-backend/
  • Python scripts: apps/trigger/src/python/etl/
  • Configs: packages/data-backend/ (Cube, Trino, Hudi)

apps/webapp/
β”œβ”€β”€ src/
β”‚ β”œβ”€β”€ pages/ # Frontend
β”‚ └── trigger/ # ← Confusing! Deploys to different service
└── trigger.config.ts # ← Telemetry commented out
apps/webapp/ β†’ Coolify
└── src/pages/ # Frontend only
apps/trigger/ β†’ Trigger.dev Cloud
β”œβ”€β”€ src/
β”‚ β”œβ”€β”€ tasks/ # TypeScript tasks
β”‚ └── python/ # Python ETL
└── trigger.config.ts # ← Telemetry enabled!
packages/data-backend/ # Shared configs
β”œβ”€β”€ cube/
β”œβ”€β”€ trino/
└── hudi/

All requirements addressed:

βœ… RBAC with 5 role levels
βœ… Apps/trigger separation plan
βœ… Trigger.dev Python extension (no Spark)
βœ… Better Stack integration guide
βœ… Monorepo organization defined
βœ… Code reuse strategy
βœ… OpenTelemetry end-to-end
βœ… All diagrams converted to Mermaid

Total savings: 52% ($9,300/year)
Implementation time: 6 weeks (phased)
Risk level: Low (parallel testing, easy rollback)

Ready to proceed? Start with Better Stack integration (5 minutes), then decide on apps/trigger separation.


Documentation: