Share this prompt:
aiwithkyle.com/6607I need to add a credit system to track AI usage in my app with Supabase: Database schema needed: 1. Add to user profiles table: - account_type (free/paid/cancelled) - credits_remaining (integer, default based on tier) - credits_used_this_month (integer, default 0) - last_credit_reset (timestamp) - subscription_start_date (timestamp) 2. Create usage_log table: - user_id (foreign key to profiles) - credits_used (integer) - action_type (text: "ai_generation", "api_call", etc) - timestamp (when the usage occurred) Credit rules: - Free users: 5 credits total, no reset - Paid users: [INSERT YOUR CALCULATED LIMIT] credits, reset monthly on subscription anniversary - Each AI request costs 1 credit - Block requests when credits_remaining = 0 - Show usage dashboard with remaining/used counts Please create this database structure and the logic to handle credit deduction and monthly resets.
See this prompt in context with full examples, use cases, and strategies in Getting ready for revenue (Part 4).
See How to Use This