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": "Guida Biblica è un'app di studio biblico online. Leggi le Scritture, fai domande con la chat potenziata dall'IA, cerca versetti istantaneamente e unisciti a una comunità globale di preghiera che sostiene la tua crescita spirituale.",
"cta": {
"readBible": "Inizia a leggere",
"askAI": "Prova gratis ora Chat Biblica con IA"
"askAI": "Prova gratis ora Chat Biblica con IA",
"supportMission": "Sostieni la Missione"
},
"liveCounter": "Unisciti a migliaia di credenti che usano Guida Biblica per studiare, comprendere e applicare la Parola di Dio nella loro vita quotidiana"
},
@@ -577,5 +578,211 @@
"updateReady": "Aggiornamento pronto",
"offline": "Sei offline",
"onlineAgain": "Sei di nuovo 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": "Piani di Abbonamento",
"subtitle": "Scegli il piano più adatto a te",
"currentPlan": "Piano Attuale",
"upgradePlan": "Aggiorna Piano",
"managePlan": "Gestisci Abbonamento",
"billingPortal": "Portale Fatturazione",
"free": {
"name": "Gratuito",
"price": "$0",
"period": "per sempre",
"description": "Perfetto per lo studio biblico occasionale",
"features": {
"conversations": "10 conversazioni IA al mese",
"bible": "Accesso completo alla Bibbia",
"prayer": "Accesso al muro della preghiera",
"bookmarks": "Segnalibri ed evidenziazioni"
},
"cta": "Piano Attuale"
},
"premium": {
"name": "Premium",
"priceMonthly": "$10",
"priceYearly": "$100",
"periodMonthly": "al mese",
"periodYearly": "all'anno",
"savings": "Risparmia 17% con piano annuale",
"description": "Crescita spirituale illimitata",
"features": {
"conversations": "Conversazioni IA illimitate",
"bible": "Accesso completo alla Bibbia",
"prayer": "Accesso al muro della preghiera",
"bookmarks": "Segnalibri ed evidenziazioni",
"support": "Supporto prioritario",
"early": "Accesso anticipato a nuove funzionalità"
},
"cta": "Aggiorna a Premium",
"ctaProcessing": "Elaborazione..."
},
"billing": {
"monthly": "Mensile",
"yearly": "Annuale"
},
"usage": {
"title": "Il Tuo Utilizzo",
"conversations": "Conversazioni",
"used": "utilizzate",
"of": "su",
"unlimited": "Illimitate",
"remaining": "rimanenti",
"resetsOn": "Si azzera il",
"resetDate": "{{date}}"
},
"limitReached": {
"title": "Limite Conversazioni Raggiunto",
"message": "Hai utilizzato tutte le {{limit}} conversazioni di questo mese.",
"upgradeMessage": "Aggiorna a Premium per conversazioni illimitate e sostieni il tuo percorso spirituale.",
"cta": "Aggiorna a Premium",
"resetInfo": "Le tue conversazioni gratuite si azzereranno il {{date}}"
},
"success": {
"title": "Benvenuto in Premium!",
"message": "Grazie per esserti abbonato a Biblical Guide Premium. Ora hai conversazioni IA illimitate.",
"benefit1": "Conversazioni bibliche IA illimitate",
"benefit2": "Supporto prioritario",
"benefit3": "Accesso anticipato a nuove funzionalità",
"cta": "Inizia a Chattare",
"goHome": "Vai alla Home"
},
"errors": {
"loadFailed": "Errore nel caricamento informazioni abbonamento",
"checkoutFailed": "Errore nella creazione sessione checkout",
"portalFailed": "Errore nell'apertura portale fatturazione",
"alreadySubscribed": "Hai già un abbonamento Premium attivo",
"generic": "Qualcosa è andato storto. Riprova."
},
"status": {
"active": "Attivo",
"cancelled": "Annullato",
"pastDue": "Scaduto",
"trialing": "Prova",
"expired": "Scaduto"
}
}
}
}