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
Description
apps/backend/src/services/billing/cost-estimation.service.tsexists 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
GET /api/deployments/[id]/estimate-costSuggested Execution
Branch:
feat/deployment-cost-estimation-complexityImplement Changes
cost-estimation.service.tswith a template complexity scoring function/api/deployments/[id]/estimate-costrouteTest and Commit
Run
pnpm test -- cost-estimationand confirm estimate accuracy is within 10% for test fixtures.Example Commit Message
Guidelines
main, keep PRs focused on one issuepnpm lintandpnpm typecheckpass before review