feat: implement subscription system with conversation limits

Implement complete backend subscription system that limits free users to 10
AI conversations per month and offers Premium tier ($10/month or $100/year)
with unlimited conversations.

Changes:
- Add User subscription fields (tier, status, limits, counters)
- Create Subscription model to track Stripe subscriptions
- Implement conversation limit enforcement in chat API
- Add subscription checkout and customer portal APIs
- Update Stripe webhook to handle subscription events
- Add subscription utility functions (limit checks, tier management)
- Add comprehensive subscription translations (en, ro, es, it)
- Update environment variables for Stripe price IDs
- Update footer "Sponsor Us" link to point to /donate
- Add "Sponsor Us" button to home page hero section

Database:
- User model: subscriptionTier, subscriptionStatus, conversationLimit,
  conversationCount, limitResetDate, stripeCustomerId, stripeSubscriptionId
- Subscription model: tracks Stripe subscription details, periods, status
- SubscriptionStatus enum: ACTIVE, CANCELLED, PAST_DUE, TRIALING, etc.

API Routes:
- POST /api/subscriptions/checkout - Create Stripe checkout session
- POST /api/subscriptions/portal - Get customer portal link
- Webhook handlers for: customer.subscription.created/updated/deleted,
  invoice.payment_succeeded/failed

Features:
- Free tier: 10 conversations/month with automatic monthly reset
- Premium tier: Unlimited conversations
- Automatic limit enforcement before conversation creation
- Returns LIMIT_REACHED error with upgrade URL when limit hit
- Stripe Customer Portal integration for subscription management
- Automatic tier upgrade/downgrade via webhooks

Documentation:
- SUBSCRIPTION_IMPLEMENTATION_PLAN.md - Complete implementation plan
- SUBSCRIPTION_IMPLEMENTATION_STATUS.md - Current status and next steps

Frontend UI still needed: subscription page, upgrade modal, usage display

🤖 Generated with Claude Code (https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-10-12 22:14:22 +00:00
parent be22b5b4fd
commit c3cd353f2f
16 changed files with 3771 additions and 699 deletions

View File

@@ -38,7 +38,8 @@
"description": "Biblical Guide is an online Bible study app. Read Scripture, ask questions with AI-powered chat, search verses instantly, and join a global prayer community that supports your spiritual growth.",
"cta": {
"readBible": "Start reading",
"askAI": "Try it free now AI Bible chat"
"askAI": "Try it free now AI Bible chat",
"supportMission": "Support the Mission"
},
"liveCounter": "Join thousands of believers who use Biblical Guide to study, understand, and apply God's Word in their everyday lives"
},
@@ -577,5 +578,211 @@
"updateReady": "Update ready",
"offline": "You're offline",
"onlineAgain": "You're back online!"
},
"donate": {
"hero": {
"title": "Biblical Guide",
"subtitle": "Every Scripture. Every Language. Forever Free.",
"cta": {
"readBible": "Read the Bible",
"supportMission": "Support the Mission"
}
},
"mission": {
"title": "The Word Should Never Have a Price Tag",
"description1": "Most Bible apps today hide the Word of God behind ads, upgrades, or premium study tools.",
"different": "Biblical Guide is different.",
"description2": "No subscriptions. No tracking. No paywalls.",
"description3": "Just Scripture — in every language, for every believer — free forever."
},
"pitch": {
"title": "Your Gift Keeps the Gospel Free",
"description1": "Every donation directly supports the servers, translations, and technology that make Biblical Guide possible.",
"description2": "When you give, you are not paying for access — you are keeping access open for millions who cannot afford to pay.",
"verse": {
"text": "Freely you have received; freely give.",
"reference": "— Matthew 10:8"
}
},
"features": {
"title": "What Your Support Sustains",
"subtitle": "Your donation keeps every verse, every prayer, every word — free to all.",
"globalLibrary": {
"title": "A Global Bible Library",
"description": "1,200+ versions, from ancient Hebrew to modern translations"
},
"multilingual": {
"title": "Multilingual Access",
"description": "7 languages today, 40+ tomorrow"
},
"prayerWall": {
"title": "A Prayer Wall Without Borders",
"description": "Believers praying for one another in real time"
},
"aiChat": {
"title": "AI Bible Chat",
"description": "Answers grounded in Scripture, not opinion"
},
"privacy": {
"title": "Complete Privacy",
"description": "No ads, no tracking, no data sale — ever"
},
"offline": {
"title": "Offline Access",
"description": "Because the Word should reach even where the internet cannot"
}
},
"form": {
"title": "How You Can Support",
"makedonation": "Make a Donation",
"success": "Thank you for your donation!",
"errors": {
"invalidAmount": "Please enter a valid amount (minimum $1)",
"invalidEmail": "Please enter a valid email address",
"checkoutFailed": "Failed to create checkout session",
"generic": "An error occurred. Please try again."
},
"recurring": {
"label": "Make this a recurring donation",
"monthly": "Monthly",
"yearly": "Yearly"
},
"amount": {
"label": "Select Amount (USD)",
"custom": "Custom Amount"
},
"info": {
"title": "Your Information",
"email": "Email Address",
"name": "Name (optional)",
"anonymous": "Make this donation anonymous",
"message": "Message (optional)",
"messagePlaceholder": "Share why you're supporting Biblical Guide..."
},
"submit": "Donate",
"secure": "Secure payment powered by Stripe"
},
"alternatives": {
"title": "Or donate with",
"paypal": "Donate via PayPal",
"kickstarter": "Support us on Kickstarter (coming soon)"
},
"impact": {
"title": "Your Impact",
"description": "Every donation directly supports the servers, translations, and technology that make Biblical Guide possible."
},
"why": {
"title": "Why Donate?",
"description1": "Biblical Guide is committed to keeping God's Word free and accessible to all. We don't have ads, paywalls, or sell your data.",
"description2": "When you give, you're not paying for access — you're keeping access open for millions who cannot afford to pay."
},
"matters": {
"title": "Why It Matters",
"point1": "Each day, someone opens a Bible app and hits a paywall.",
"point2": "Each day, a believer loses connection and can't read the Word offline.",
"point3": "Each day, the Gospel becomes harder to reach for someone who needs it most.",
"together": "Together, we can change that.",
"conclusion": "Your donation ensures that God's Word remains freely accessible — without cost, without barriers, without end."
},
"join": {
"title": "Join the Mission",
"description1": "Biblical Guide is built by one believer, sustained by many.",
"description2": "No corporations. No investors. Just faith, code, and community.",
"callToAction": "If this mission speaks to you — help keep the Bible free forever.",
"closing": "Every verse you read today stays free tomorrow."
},
"footer": {
"tagline": "Every Scripture. Every Language. Forever Free.",
"links": {
"readBible": "Read Bible",
"prayerWall": "Prayer Wall",
"aiChat": "AI Chat",
"contact": "Contact"
}
}
},
"subscription": {
"title": "Subscription Plans",
"subtitle": "Choose the plan that works best for you",
"currentPlan": "Current Plan",
"upgradePlan": "Upgrade Plan",
"managePlan": "Manage Subscription",
"billingPortal": "Billing Portal",
"free": {
"name": "Free",
"price": "$0",
"period": "forever",
"description": "Perfect for occasional Bible study",
"features": {
"conversations": "10 AI conversations per month",
"bible": "Full Bible access",
"prayer": "Prayer wall access",
"bookmarks": "Bookmarks & highlights"
},
"cta": "Current Plan"
},
"premium": {
"name": "Premium",
"priceMonthly": "$10",
"priceYearly": "$100",
"periodMonthly": "per month",
"periodYearly": "per year",
"savings": "Save 17% with annual",
"description": "Unlimited spiritual growth",
"features": {
"conversations": "Unlimited AI conversations",
"bible": "Full Bible access",
"prayer": "Prayer wall access",
"bookmarks": "Bookmarks & highlights",
"support": "Priority support",
"early": "Early access to new features"
},
"cta": "Upgrade to Premium",
"ctaProcessing": "Processing..."
},
"billing": {
"monthly": "Monthly",
"yearly": "Yearly"
},
"usage": {
"title": "Your Usage",
"conversations": "Conversations",
"used": "used",
"of": "of",
"unlimited": "Unlimited",
"remaining": "remaining",
"resetsOn": "Resets on",
"resetDate": "{{date}}"
},
"limitReached": {
"title": "Conversation Limit Reached",
"message": "You've used all {{limit}} conversations for this month.",
"upgradeMessage": "Upgrade to Premium for unlimited conversations and support your spiritual journey.",
"cta": "Upgrade to Premium",
"resetInfo": "Your free conversations will reset on {{date}}"
},
"success": {
"title": "Welcome to Premium!",
"message": "Thank you for subscribing to Biblical Guide Premium. You now have unlimited AI conversations.",
"benefit1": "Unlimited AI Bible conversations",
"benefit2": "Priority support",
"benefit3": "Early access to new features",
"cta": "Start Chatting",
"goHome": "Go to Home"
},
"errors": {
"loadFailed": "Failed to load subscription information",
"checkoutFailed": "Failed to create checkout session",
"portalFailed": "Failed to open billing portal",
"alreadySubscribed": "You already have an active Premium subscription",
"generic": "Something went wrong. Please try again."
},
"status": {
"active": "Active",
"cancelled": "Cancelled",
"pastDue": "Past Due",
"trialing": "Trial",
"expired": "Expired"
}
}
}
}