Repository navigation
feat(content): monthly quota for content brief generation - #224
Merged
Merged
Conversation
Cloud plans now cap AI content-brief generations per calendar month: Starter 10, Growth 50, Enterprise unlimited by default with per-customer overrides via organizations.plan_overrides.maxBriefGenerations. Self-hosted stays unlimited. - New brief_usage table (mirrors volume_usage) tracks generations per org - Quota enforced in the shared generateBriefForOpportunity core so the dashboard route and internal MCP route draw from the same pool; cached brief reads never charge quota - Server plan resolution now applies enterprise plan_overrides (parity with web getOrgPlan) - Dashboard brief route gains an org-ownership check and returns the updated quota; new GET /api/content/briefs/quota endpoint - Content detail page shows remaining briefs and swaps the generate button for an Upgrade Plan CTA when the quota is exhausted Co-authored-by: Cursor <[email protected]>
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a plan-based monthly quota for AI content-brief generation (the "Generate Content Brief" action on
/dashboard/content/[id]):organizations.plan_overrides.maxBriefGenerationsQuota resets on the 1st of each month (same convention as
maxVolumeAnalyses).Backend
brief_usagetable (migration00015), mirroring thevolume_usagepattern: one row per generated brief, counted per org per month. RLS enabled, service-role only.maxBriefGenerationsadded to plan definitions (web + server, kept in sync).generateBriefForOpportunitycore, so the dashboard route and the internal MCP route draw from the same monthly pool. Cached brief reads never charge quota.plan_overrides— parity with the webgetOrgPlan()behavior.POST /api/content/:id/briefnow does an org-ownership check (quota is charged to the opportunity's org) and returns the updated quota; quota exhaustion returns403 quota_exceededwith a clear message.GET /api/content/briefs/quotareturns{ used, limit, remaining }.Frontend
X/Y briefs remaining this monthunder the generate button (hidden when unlimited).Settings → Billing.Setting an Enterprise customer limit
Test plan
node --checkon all edited server fileseslint+prettier --checkpasstsc --noEmit,eslint(0 errors),vitest(10/10) pass00015_brief_usage.sqlto the cloud DB before deployIS_CLOUD != true) shows no counter and no limitMade with Cursor