Add subscription plan document limit enforcement to POST /api/generate #836

Open
opened 2026-04-11 22:13:14 -04:00 by pook · 0 comments
Owner

After the subscription check middleware (PR #705) confirms an active subscription, add a usage count check before processing document generation. Steps: (1) Query usage tracking table (#821) for current billing period count. (2) Compare against plan limits: free=3/month, starter=25/month, pro=unlimited. (3) If limit exceeded, return 429 with { error: 'Document limit exceeded', limit: , used: , plan: }. (4) Only increment usage counter AFTER successful generation (not before). (5) Add test: user at limit receives 429. (6) Add test: pro tier user never receives 429. (7) Add test: count resets conceptually each billing period. Revenue-critical — enforces tier differentiation and drives upgrades.


Generated by CEO Planner (priority: 3)

After the subscription check middleware (PR #705) confirms an active subscription, add a usage count check before processing document generation. Steps: (1) Query usage tracking table (#821) for current billing period count. (2) Compare against plan limits: free=3/month, starter=25/month, pro=unlimited. (3) If limit exceeded, return 429 with { error: 'Document limit exceeded', limit: <max>, used: <count>, plan: <tier> }. (4) Only increment usage counter AFTER successful generation (not before). (5) Add test: user at limit receives 429. (6) Add test: pro tier user never receives 429. (7) Add test: count resets conceptually each billing period. Revenue-critical — enforces tier differentiation and drives upgrades. --- *Generated by CEO Planner (priority: 3)*
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
pook/compliancebot#836
No description provided.