Skip to content

Build Cost Estimation Service with Predictive Billing Calculation for Template Complexity #756

Description

@temma02

Description

apps/backend/src/services/billing/cost-estimation.service.ts exists but only estimates costs based on tier. Add template complexity scoring that factors in: number of Soroban contract invocations, enabled features, and estimated Vercel compute usage to produce a per-deployment cost prediction.

Requirements and Context

  • Complexity score: base cost + N × soroban_invocation_cost + M × feature_cost
  • Expose the estimate via GET /api/deployments/[id]/estimate-cost
  • Estimate must update in real-time as the user changes customization options
  • Accuracy target: within 10% of actual Stripe charge on billing reconciliation

Suggested Execution

Branch: feat/deployment-cost-estimation-complexity

Implement Changes

  • Extend cost-estimation.service.ts with a template complexity scoring function
  • Add the /api/deployments/[id]/estimate-cost route
  • Implement real-time re-estimation on customization config change via the preview update endpoint
  • Add tests for complexity scoring accuracy against known billing outcomes

Test and Commit

Run pnpm test -- cost-estimation and confirm estimate accuracy is within 10% for test fixtures.

Example Commit Message

feat(billing): add template complexity scoring to cost estimation service

Co-authored-by: <your-name>

Guidelines

  • Branch off main, keep PRs focused on one issue
  • All new code must include unit or integration tests
  • Ensure pnpm lint and pnpm typecheck pass before review
  • Link this issue in your PR description
  • Request review from at least one maintainer before merging

Metadata

Metadata

Assignees

Labels

Stellar WaveIssues in the Stellar wave programbackendBackend related issues

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions