Open source alternatives to paid SaaS apps: Notion, Slack, Auth0, Vercel and more. Curated list with licenses and GitHub stars.
JavaScript alternativesauth0-alternativeawesomeawesome-listfigma-alternativefirebase-alternativefree-softwarenotion-alternativeopen-sourceopen-source-alternativesopen-source-softwarepostman-alternativeprivacysaassaas-alternativesself-hostedselfhostedslack-alternativevercel-alternativezapier-alternative
upgrade: integrate standard SaaS components (NextAuth, Stripe billing, layouts, and theme support)
Jaya Prasad Kavuruf90a0d17686b
diff --git a/package-lock.json b/package-lock.jsonindex 3401ecf..5cfc725 100644--- a/package-lock.json+++ b/package-lock.json@@ -20,6 +20,7 @@"pg": "^8.21.0","react": "19.2.4","react-dom": "19.2.4",+ "react-hot-toast": "^2.5.2","react-icons": "^5.6.0","stripe": "^22.1.1","tailwind-merge": "^3.6.0"@@ -3450,9 +3451,7 @@"version": "3.2.3","resolved": "https://registry.npmjs.org/csstype/-/csstype-3.2.3.tgz","integrity": "sha512-z1HGKcYy2xA8AGQfwrn0PAy+PB7X/GSj3UVJW9qKyn43xWa+gl5nXmU4qqLMRzWVLFC8KusUX8T/0kCiOYpAIQ==",- "devOptional": true,- "license": "MIT",- "peer": true+ "license": "MIT"},"node_modules/damerau-levenshtein": {"version": "1.0.8",@@ -4798,6 +4797,15 @@"url": "https://github.com/sponsors/ljharb"}},+ "node_modules/goober": {+ "version": "2.1.19",+ "resolved": "https://registry.npmjs.org/goober/-/goober-2.1.19.tgz",+ "integrity": "sha512-U7veizMqxyKlM58+Z5j2ngJBH/r9siDmxpvNxSw0PylF6WQvrASJEZrxh1hidRBJc2jqoBVSyOban5u8m+6Rxg==",+ "license": "MIT",+ "peerDependencies": {+ "csstype": "^3.0.10"+ }+ },"node_modules/gopd": {"version": "1.2.0","resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz",@@ -7037,6 +7045,23 @@"react": "^19.2.4"}},+ "node_modules/react-hot-toast": {+ "version": "2.6.0",+ "resolved": "https://registry.npmjs.org/react-hot-toast/-/react-hot-toast-2.6.0.tgz",+ "integrity": "sha512-bH+2EBMZ4sdyou/DPrfgIouFpcRLCJ+HoCA32UoAYHn6T3Ur5yfcDCeSr5mwldl6pFOsiocmrXMuoCJ1vV8bWg==",+ "license": "MIT",+ "dependencies": {+ "csstype": "^3.1.3",+ "goober": "^2.1.16"+ },+ "engines": {+ "node": ">=10"+ },+ "peerDependencies": {+ "react": ">=16",+ "react-dom": ">=16"+ }+ },"node_modules/react-icons": {"version": "5.6.0","resolved": "https://registry.npmjs.org/react-icons/-/react-icons-5.6.0.tgz",diff --git a/package.json b/package.jsonindex 719127d..0d485d1 100644--- a/package.json+++ b/package.json@@ -23,7 +23,8 @@"react-dom": "19.2.4","react-icons": "^5.6.0","stripe": "^22.1.1",- "tailwind-merge": "^3.6.0"+ "tailwind-merge": "^3.6.0",+ "react-hot-toast": "^2.5.2"},"devDependencies": {"@tailwindcss/postcss": "^4",@@ -32,4 +33,4 @@"prisma": "^7.8.0","tailwindcss": "^4"}-}+}\ No newline at end of filediff --git a/src/app/api/checkout/route.js b/src/app/api/checkout/route.jsnew file mode 100644index 0000000..66aafb8--- /dev/null+++ b/src/app/api/checkout/route.js@@ -0,0 +1,24 @@+import { NextResponse } from "next/server";+import { getServerSession } from "next-auth/next";+import { authOptions } from "@/lib/auth";+import { BillingService } from "@/lib/services/billing";++export async function POST(req) {+ try {+ const session = await getServerSession(authOptions);+ if (!session || !session.user) {+ return NextResponse.json({ error: "Unauthorized. Please sign in." }, { status: 401 });+ }++ const { planId } = await req.json();+ if (!planId) {+ return NextResponse.json({ error: "Missing planId parameter" }, { status: 400 });+ }++ const checkoutUrl = await BillingService.createCheckoutSession(session.user.id, planId);+ return NextResponse.json({ url: checkoutUrl });+ } catch (error) {+ console.error("Checkout route error:", error);+ return NextResponse.json({ error: error.message }, { status: 500 });+ }+}diff --git a/src/app/api/webhook/stripe/route.js b/src/app/api/webhook/stripe/route.jsnew file mode 100644index 0000000..3354845--- /dev/null+++ b/src/app/api/webhook/stripe/route.js@@ -0,0 +1,21 @@+import { NextResponse } from "next/server";+import { headers } from "next/headers";+import { BillingService } from "@/lib/services/billing";++export async function POST(req) {+ try {+ const body = await req.text();+ const headersList = await headers();+ const signature = headersList.get("stripe-signature");++ if (!signature) {+ return NextResponse.json({ error: "Missing stripe-signature header" }, { status: 400 });+ }++ const result = await BillingService.handleWebhook(body, signature);+ return NextResponse.json(result);+ } catch (error) {+ console.error("Stripe webhook processing error:", error);+ return NextResponse.json({ error: error.message }, { status: 500 });+ }+}diff --git a/src/app/globals.css b/src/app/globals.cssindex c67b39f..1162605 100644--- a/src/app/globals.css+++ b/src/app/globals.css@@ -3,89 +3,146 @@@theme {--font-sans: var(--font-inter), sans-serif;--font-outfit: var(--font-inter), sans-serif;++ --color-bg-page: var(--bg-page, #09090b);+ --color-bg-card: var(--bg-card, #18181b);+ --color-bg-card-hover: var(--bg-card-hover, #27272a);+ --color-bg-elevated: var(--bg-elevated, #202024);+ --color-divider: var(--divider, #3f3f46);+ --color-primary: var(--primary, #8b5cf6);+ --color-primary-hover: var(--primary-hover, #7c3aed);+ --color-primary-text: var(--primary-text, #f4f4f5);+ --color-secondary-text: var(--secondary-text, #a1a1aa);+ --color-primary-btn-text: var(--primary-btn-text, #ffffff);}-:root {- --background: #09090b;- --foreground: #f4f4f5;- --primary: #8b5cf6; /* Violet */- --primary-hover: #7c3aed;- --card: #18181b;- --border: #27272a;+/* Premium Visual Themes Override Definitions */+[data-theme="cyberpunk"] {+ --bg-page: #05010a;+ --bg-card: #0e051c;+ --bg-card-hover: #1b0c32;+ --bg-elevated: #150827;+ --divider: #ec4899;+ --primary: #f43f5e;+ --primary-hover: #e11d48;+ --primary-text: #fff1f2;+ --secondary-text: #06b6d4;+ --primary-btn-text: #ffffff;}-body {- background-color: var(--background);- color: var(--foreground);- font-family: var(--font-sans);+[data-theme="emerald"] {+ --bg-page: #022c22;+ --bg-card: #064e3b;+ --bg-card-hover: #0f766e;+ --bg-elevated: #042f2e;+ --divider: #115e59;+ --primary: #10b981;+ --primary-hover: #059669;+ --primary-text: #ecfdf5;+ --secondary-text: #34d399;+ --primary-btn-text: #ffffff;}-/* Premium Glassmorphism Card styling */-.card-premium {+[data-theme="sunset"] {+ --bg-page: #1c0a00;+ --bg-card: #2d1500;+ --bg-card-hover: #452400;+ --bg-elevated: #371b00;+ --divider: #ea580c;+ --primary: #f97316;+ --primary-hover: #ea580c;+ --primary-text: #fff7ed;+ --secondary-text: #fb923c;+ --primary-btn-text: #ffffff;+}++[data-theme="midnight"] {+ --bg-page: #000000;+ --bg-card: #0c0c0e;+ --bg-card-hover: #1e1e24;+ --bg-elevated: #151518;+ --divider: #2d2d34;+ --primary: #ffffff;+ --primary-hover: #e4e4e7;+ --primary-text: #f4f4f5;+ --secondary-text: #a1a1aa;+ --primary-btn-text: #000000;+}++.bg-primary {+ color: var(--primary-btn-text, #ffffff) !important;+}++@layer base {+ html, body {+ background-color: var(--color-bg-page);+ color: var(--color-primary-text);+ font-family: var(--font-sans);+ height: 100%;+ margin: 0;+ padding: 0;+ }+}++/* Glassmorphism Utilities */+.glass-panel {background: rgba(24, 24, 27, 0.7);backdrop-filter: blur(12px);- border: 1px solid rgba(39, 39, 42, 0.8);- border-radius: 1rem;- box-shadow: 0 4px 30px rgba(0, 0, 0, 0.5);- transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);+ -webkit-backdrop-filter: blur(12px);+ border: 1px solid rgba(63, 63, 70, 0.5);}-.card-premium:hover {- border-color: rgba(139, 92, 246, 0.4);- box-shadow: 0 8px 30px rgba(139, 92, 246, 0.1);+.glass-dropdown {+ background: rgba(15, 15, 18, 0.95);+ backdrop-filter: blur(16px);+ -webkit-backdrop-filter: blur(16px);+ border: 1px solid rgba(63, 63, 70, 0.6);}-/* Global scrollbars */-::-webkit-scrollbar {- width: 8px;- height: 8px;+/* Premium Scrollbars */+.scrollbar-subtle::-webkit-scrollbar {+ width: 6px;+ height: 6px;}-::-webkit-scrollbar-track {- background: #09090b;+.scrollbar-subtle::-webkit-scrollbar-track {+ background: transparent;}-::-webkit-scrollbar-thumb {- background: #27272a;- border-radius: 9999px;- border: 2px solid #09090b;+.scrollbar-subtle::-webkit-scrollbar-thumb {+ background: var(--color-divider);+ border-radius: 10px;}-::-webkit-scrollbar-thumb:hover {- background: #3f3f46;+.scrollbar-subtle::-webkit-scrollbar-thumb:hover {+ background: var(--color-primary);}-/* Micro-animations */-@keyframes fadeIn {- from {- opacity: 0;- transform: translateY(6px);+/* Animations */+@keyframes pulseGlow {+ 0%, 100% {+ opacity: 0.6;+ transform: scale(1);}- to {+ 50% {opacity: 1;- transform: translateY(0);+ transform: scale(1.02);}}-.animate-fade-in {- animation: fadeIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;+.animate-pulse-glow {+ animation: pulseGlow 2s infinite ease-in-out;}-@keyframes pulse-ring {- 0% {- transform: scale(0.95);- box-shadow: 0 0 0 0 rgba(139, 92, 246, 0.5);- }- 70% {- transform: scale(1);- box-shadow: 0 0 0 8px rgba(139, 92, 246, 0);+@keyframes gradientX {+ 0%, 100% {+ background-position: 0% 50%;}- 100% {- transform: scale(0.95);- box-shadow: 0 0 0 0 rgba(139, 92, 246, 0);+ 50% {+ background-position: 100% 50%;}}-.animate-pulse-ring {- animation: pulse-ring 2s infinite;+.animate-gradient-x {+ animation: gradientX 6s ease infinite;}diff --git a/src/app/layout.js b/src/app/layout.jsindex fccbf26..754bc59 100644--- a/src/app/layout.js+++ b/src/app/layout.js@@ -1,7 +1,8 @@import { Inter } from "next/font/google";import "./globals.css";-import { Providers } from "@/components/Providers";-import { Navbar } from "@/components/layout/Navbar";+import { Providers } from "./providers";+import Navbar from "../components/Navbar";+import config from "@/lib/config";const inter = Inter({variable: "--font-inter",@@ -15,12 +16,14 @@ export const metadata = {};export default function RootLayout({ children }) {+ const theme = config?.theme || "slate-indigo";+return (- <html lang="en" className="h-full w-full dark">- <body className={`${inter.variable} ${inter.className} h-full w-full flex flex-col antialiased bg-zinc-950 text-zinc-100`}>+ <html lang="en" className="h-full w-full" data-theme={theme}>+ <body className={`${inter.variable} ${inter.className} h-full w-full flex flex-col antialiased bg-bg-page text-primary-text overflow-hidden`}><Providers><Navbar />- <div className="flex-1 flex flex-col overflow-hidden">+ <div className="flex-1 flex flex-col overflow-hidden min-h-0">{children}</div></Providers>@@ -28,3 +31,4 @@ export default function RootLayout({ children }) {</html>);}+diff --git a/src/app/login/page.js b/src/app/login/page.jsnew file mode 100644index 0000000..fc8732e--- /dev/null+++ b/src/app/login/page.js@@ -0,0 +1,64 @@+"use client";++import { signIn, useSession } from "next-auth/react";+import { useEffect, Suspense } from "react";+import { useRouter, useSearchParams } from "next/navigation";+import { FaGoogle, FaInfoCircle } from "react-icons/fa";++function LoginContent() {+ const { data: session, status } = useSession();+ const router = useRouter();+ const searchParams = useSearchParams();+ const next = searchParams.get("callbackUrl") || searchParams.get("next") || "/";++ useEffect(() => {+ if (status === "authenticated") {+ router.push(next);+ }+ }, [status, router, next]);++ return (+ <div className="min-h-dvh flex items-center justify-center bg-bg-page px-6 text-primary-text select-none">+ <div className="relative bg-bg-card border border-divider w-full max-w-md rounded-lg p-8 space-y-8 shadow-2xl animate-scale-up">+ <div className="flex flex-col items-center text-center space-y-4">+ <div className="w-14 h-14 rounded-full bg-primary/10 flex items-center justify-center text-2xl text-primary font-black shadow-md shadow-primary/15">+ A+ </div>+ <h2 className="text-2xl font-black uppercase tracking-tight">Sign In to Studio</h2>+ <p className="text-xs font-semibold text-secondary-text leading-relaxed px-4">+ Sign in with Google to enable predictions, save generation history, and top up credits packages.+ </p>+ </div>++ <div className="space-y-4">+ <button+ onClick={() => signIn("google", { callbackUrl: next })}+ className="w-full py-3.5 bg-white text-neutral-900 rounded-full text-xs font-bold flex items-center justify-center gap-3 hover:opacity-90 transition-all shadow-md active:scale-[0.98] cursor-pointer"+ >+ <FaGoogle className="text-sm text-red-500" />+ <span>Continue with Google</span>+ </button>+ </div>++ <div className="flex items-start gap-2.5 bg-primary/5 border border-primary/10 p-3.5 rounded text-[11px] leading-relaxed text-secondary-text">+ <FaInfoCircle className="text-primary text-xs shrink-0 mt-0.5" />+ <span>+ By signing in, you agree to our Terms of Service. Purchases are stripe-secured and credit balance addition is automated.+ </span>+ </div>+ </div>+ </div>+ );+}++export default function Login() {+ return (+ <Suspense fallback={+ <div className="min-h-dvh flex items-center justify-center bg-bg-page text-primary-text">+ <div className="w-8 h-8 border-2 border-primary border-t-transparent rounded-full animate-spin" />+ </div>+ }>+ <LoginContent />+ </Suspense>+ );+}diff --git a/src/app/pricing/page.js b/src/app/pricing/page.jsindex cccb336..5847e99 100644--- a/src/app/pricing/page.js+++ b/src/app/pricing/page.js@@ -1,221 +1,121 @@"use client";-import { useSession, signIn } from "next-auth/react";+import { useSession } from "next-auth/react";import { useState } from "react";-import { FaCheck, FaCrown, FaRocket, FaBolt, FaExclamationTriangle } from "react-icons/fa";+import Navbar from "@/components/Navbar";+import Footer from "@/components/Footer";+import { FaCheck, FaInfoCircle } from "react-icons/fa";+import axios from "axios";+import toast, { Toaster } from "react-hot-toast";const PLANS = [- {- id: "starter",- name: "Starter Pack",- price: "$5",- credits: 100,- description: "Perfect for casual content creators starting to automate their scheduling.",- features: [- "100 publishing credits",- "YouTube Video Publishing",- "TikTok Video Publishing",- "Detailed error diagnostics",- "Immediate or scheduled posts",- ],- popular: false,- Icon: FaBolt,- iconColor: "text-amber-400 bg-amber-500/10",- buttonId: "pricing-buy-starter",- },- {- id: "pro",- name: "Pro Pack",- price: "$15",- credits: 500,- description: "Best for active creators looking to maintain a consistent upload calendar.",- features: [- "500 publishing credits",- "YouTube Video Publishing",- "TikTok Video Publishing",- "Detailed error diagnostics",- "Immediate or scheduled posts",- "Priority API queue processing",- "Auto-retry for failed attempts",- ],- popular: true,- Icon: FaRocket,- iconColor: "text-violet-400 bg-violet-500/10",- buttonId: "pricing-buy-pro",- },- {- id: "business",- name: "Business Pack",- price: "$45",- credits: 2000,- description: "Designed for social media agencies managing multiple client channels.",- features: [- "2000 publishing credits",- "YouTube Video Publishing",- "TikTok Video Publishing",- "Detailed error diagnostics",- "Immediate or scheduled posts",- "Highest priority execution queue",- "Auto-retry for failed attempts",- "Dedicated developer email support",- ],- popular: false,- Icon: FaCrown,- iconColor: "text-fuchsia-400 bg-fuchsia-500/10",- buttonId: "pricing-buy-business",- },+ { id: "basic", name: "Basic Pack", price: "$5", credits: 100, description: "Perfect for testing custom prompts and exploring styles." },+ { id: "standard", name: "Standard Pack", price: "$10", credits: 250, description: "Ideal for regular creators wanting high resolution outputs." },+ { id: "pro", name: "Professional Pack", price: "$20", credits: 600, description: "Designed for power users demanding batch exports and high speed.", popular: true },+ { id: "business", name: "Business Pack", price: "$50", credits: 2000, description: "Maximum value pack for agency workflows and large volume generations." }];-export default function PricingPage() {- const { data: session } = useSession();+export default function Pricing() {+ const { data: session, status } = useSession();const [loadingPlan, setLoadingPlan] = useState(null);- const handlePurchase = async (planId) => {- if (!session?.user) {- signIn("google");+ const handleCheckout = async (planId) => {+ if (status !== "authenticated") {+ toast.error("You must sign in with Google to purchase credit packages.");return;}setLoadingPlan(planId);try {- const res = await fetch("/api/stripe/checkout", {- method: "POST",- headers: {- "Content-Type": "application/json",- },- body: JSON.stringify({ planId }),- });-- if (!res.ok) {- const errorText = await res.text();- throw new Error(errorText || "Failed to create checkout session");- }-- const data = await res.json();+ const { data } = await axios.post("/api/checkout", { planId });if (data.url) {window.location.href = data.url;} else {- alert("Could not load payment checkout link. Please try again.");+ throw new Error("No redirection URL returned");}} catch (err) {console.error(err);- alert(err.message || "An error occurred initiating checkout");+ toast.error(err.response?.data?.error || "Failed to trigger Stripe checkout session.");} finally {setLoadingPlan(null);}};return (- <main className="flex-1 min-h-screen bg-zinc-950 px-6 py-16 flex flex-col items-center">- <div className="max-w-5xl w-full flex flex-col gap-12">- {/* Header Section */}- <div className="flex flex-col items-center text-center gap-4">- <h1 className="text-4xl font-extrabold tracking-tight text-white sm:text-5xl">- Flexible <span className="bg-gradient-to-r from-violet-400 to-fuchsia-400 bg-clip-text text-transparent">Credit Packs</span>- </h1>- <p className="max-w-xl text-sm text-zinc-400 leading-relaxed">- No monthly subscriptions, no lock-ins. Purchase credits when you need them.- One credit is consumed per successfully published video or scheduled post.+ <div className="flex min-h-dvh flex-col bg-bg-page select-none text-primary-text overflow-hidden">+ <Toaster position="top-right" />+ <Navbar />++ <main className="flex-1 max-w-7xl w-full mx-auto px-4 py-12 sm:px-6 lg:px-8 flex flex-col gap-10 overflow-y-auto scrollbar-subtle items-center">+ <div className="text-center space-y-4">+ <div className="inline-flex items-center gap-2 px-3 py-1 bg-primary/10 border border-primary/20 rounded-full mb-1">+ <FaInfoCircle className="text-primary text-xs" />+ <span className="text-[10px] font-black text-primary uppercase tracking-widest">Pricing Plans</span>+ </div>+ <h1 className="text-3xl sm:text-4xl font-black tracking-tight uppercase">Buy Credits Packs</h1>+ <p className="text-xs sm:text-sm text-secondary-text max-w-lg leading-relaxed">+ Purchase flexible credit packages to perform high-resolution predictions. Keep all profits — we handle AI infrastructure.</p></div>- {/* Guest mode warning if needed */}- {!session?.user && (- <div className="mx-auto max-w-2xl w-full bg-amber-500/5 border border-amber-500/20 rounded-xl p-4 flex items-center justify-between gap-4">- <div className="flex items-center gap-3">- <FaExclamationTriangle className="text-amber-500 text-lg shrink-0" />- <div className="flex flex-col text-left">- <span className="text-xs font-bold text-amber-500">Sign in required</span>- <span className="text-[11px] text-zinc-400">Please sign in to buy credit packs for your account.</span>- </div>- </div>- <button- onClick={() => signIn("google")}- className="px-4 py-1.5 bg-amber-500 hover:bg-amber-600 text-zinc-950 font-bold text-[11px] rounded-lg transition-colors cursor-pointer"- >- Sign In- </button>- </div>- )}-{/* Pricing Cards Grid */}- <div className="grid grid-cols-1 md:grid-cols-3 gap-8 items-stretch">- {PLANS.map((plan) => {- const PlanIcon = plan.Icon;- return (- <div- key={plan.id}- className={`card-premium relative p-8 flex flex-col justify-between overflow-hidden animate-fade-in ${- plan.popular- ? "border-violet-500/40 shadow-lg shadow-violet-500/5 ring-1 ring-violet-500/30"- : ""- }`}- >- {plan.popular && (- <div className="absolute top-4 right-4 bg-violet-500 text-white text-[9px] font-bold tracking-wider uppercase px-2.5 py-1 rounded-full shadow-inner">- Most Popular- </div>- )}-- <div className="flex flex-col gap-6">- {/* Title & Icon Header */}- <div className="flex items-center gap-3">- <div className={`h-10 w-10 rounded-xl flex items-center justify-center shrink-0 ${plan.iconColor}`}>- <PlanIcon className="text-lg" />- </div>- <div className="flex flex-col">- <h3 className="text-base font-bold text-white leading-none">{plan.name}</h3>- <span className="text-[10px] text-zinc-500 font-medium mt-1">One-time payment</span>- </div>- </div>-- {/* Price & Credits display */}- <div className="flex items-baseline gap-2 border-b border-zinc-900 pb-5">- <span className="text-3xl font-extrabold text-white">{plan.price}</span>- <span className="text-zinc-400 text-xs">/ {plan.credits} Credits</span>- </div>-- <p className="text-xs text-zinc-400 leading-relaxed min-h-[40px]">{plan.description}</p>-- {/* Feature Checklist */}- <ul className="flex flex-col gap-3">- {plan.features.map((feature, index) => (- <li key={index} className="flex items-start gap-2.5 text-xs text-zinc-300">- <FaCheck className="text-[10px] text-violet-400 shrink-0 mt-1" />- <span>{feature}</span>- </li>- ))}- </ul>+ <div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6 w-full max-w-5xl">+ {PLANS.map((plan) => (+ <div+ key={plan.id}+ className={`relative bg-bg-card border rounded-lg p-6 flex flex-col justify-between gap-6 transition-all duration-300 hover:shadow-2xl hover:-translate-y-1 ${+ plan.popular ? "border-primary shadow-xl shadow-primary/5 scale-105" : "border-divider/50 shadow-md"+ }`}+ >+ {plan.popular && (+ <span className="absolute -top-3 left-1/2 -translate-x-1/2 bg-primary text-white text-[9px] font-black uppercase px-3 py-1 rounded-full tracking-wider shadow">+ Most Popular+ </span>+ )}++ <div className="space-y-4">+ <div className="space-y-1">+ <h3 className="text-sm font-extrabold uppercase tracking-wide text-primary-text">{plan.name}</h3>+ <p className="text-2xl font-black tracking-tight text-white">{plan.price}</p>+ </div>++ <div className="text-xs bg-bg-page/50 border border-divider/30 p-3 rounded text-center font-extrabold text-primary">+ {plan.credits} Art Credits</div>- {/* Purchase Button */}- <button- id={plan.buttonId}- disabled={loadingPlan !== null}- onClick={() => handlePurchase(plan.id)}- className={`w-full mt-8 py-3 rounded-xl font-bold text-xs transition-all cursor-pointer flex items-center justify-center ${- plan.popular- ? "bg-gradient-to-r from-violet-500 to-fuchsia-500 hover:from-violet-600 hover:to-fuchsia-600 text-white shadow-lg shadow-violet-500/10 active:scale-[0.98]"- : "bg-zinc-900 hover:bg-zinc-800 border border-zinc-800 text-zinc-200 hover:text-white"- } disabled:opacity-50 disabled:cursor-not-allowed`}- >- {loadingPlan === plan.id ? "Processing..." : `Buy ${plan.credits} Credits`}- </button>+ <p className="text-xs text-secondary-text leading-relaxed font-medium min-h-[3rem]">{plan.description}</p>++ <ul className="space-y-2 border-t border-divider/30 pt-4 text-xs font-semibold text-secondary-text">+ <li className="flex items-center gap-2">+ <FaCheck className="text-primary text-[10px]" />+ <span>Dynamic aspect ratios</span>+ </li>+ <li className="flex items-center gap-2">+ <FaCheck className="text-primary text-[10px]" />+ <span>HD image downloads</span>+ </li>+ <li className="flex items-center gap-2">+ <FaCheck className="text-primary text-[10px]" />+ <span>No subscription required</span>+ </li>+ </ul></div>- );- })}- </div>- {/* FAQ Section or Info Footer */}- <div className="mt-6 border-t border-zinc-900 pt-10 text-center flex flex-col items-center gap-2">- <p className="text-xs text-zinc-500">- Secure checkout powered by Stripe. Have questions or need support? Contact [email protected].- </p>- <p className="text-[10px] text-zinc-600">- If a scheduled post fails due to an external service error, your consumed credit is automatically refunded to your account balance.- </p>+ <button+ onClick={() => handleCheckout(plan.id)}+ disabled={loadingPlan !== null}+ className={`w-full py-3 rounded-full text-xs font-bold transition-all shadow-md cursor-pointer select-none active:scale-[0.98] ${+ plan.popular ? "bg-primary text-white hover:bg-primary-hover shadow-primary/15" : "bg-bg-page hover:bg-bg-card text-primary-text border border-divider"+ }`}+ >+ {loadingPlan === plan.id ? "Loading checkout..." : "Purchase Credits"}+ </button>+ </div>+ ))}</div>- </div>- </main>+ </main>++ <Footer />+ </div>);}diff --git a/src/app/providers.js b/src/app/providers.jsnew file mode 100644index 0000000..659111e--- /dev/null+++ b/src/app/providers.js@@ -0,0 +1,20 @@+"use client";++import { SessionProvider } from "next-auth/react";+import { useEffect } from "react";+import config from "@/lib/config";++export function Providers({ children }) {+ useEffect(() => {+ if (typeof window !== "undefined") {+ const theme = config?.theme || "slate-indigo";+ document.documentElement.setAttribute("data-theme", theme);+ }+ }, []);++ return (+ <SessionProvider>+ {children}+ </SessionProvider>+ );+}diff --git a/src/components/Footer.js b/src/components/Footer.jsnew file mode 100644index 0000000..42fa648--- /dev/null+++ b/src/components/Footer.js@@ -0,0 +1,26 @@+"use client";++import Link from "next/link";++export default function Footer() {+ const currentYear = new Date().getFullYear();++ return (+ <footer className="w-full border-t border-divider/40 bg-bg-page py-6 text-center text-xs text-secondary-text mt-auto">+ <div className="mx-auto max-w-7xl px-4 sm:px-6 lg:px-8 flex flex-col sm:flex-row items-center justify-between gap-4">+ <div>+ © {currentYear} AI SaaS Studio. All rights reserved.+ </div>+ <div className="flex gap-4">+ <Link href="/terms" className="hover:text-primary-text transition-colors">+ Terms of Service+ </Link>+ <span className="opacity-30">•</span>+ <Link href="/privacy" className="hover:text-primary-text transition-colors">+ Privacy Policy+ </Link>+ </div>+ </div>+ </footer>+ );+}diff --git a/src/components/Navbar.js b/src/components/Navbar.jsnew file mode 100644index 0000000..e5aa792--- /dev/null+++ b/src/components/Navbar.js@@ -0,0 +1,226 @@+"use client";++import Link from "next/link";+import { useSession, signOut } from "next-auth/react";+import { useState, useEffect } from "react";+import { usePathname } from "next/navigation";+import { IoClose, IoMenu } from "react-icons/io5";+import { FiMoon, FiSun, FiLogOut, FiDollarSign, FiPlus, FiUser } from "react-icons/fi";+import { SiVercel } from "react-icons/si";+import config from "@/lib/config";++export default function Navbar() {+ const { data: session, status } = useSession();+ const pathname = usePathname();+ const [isOpen, setIsOpen] = useState(false);+ const [isProfileOpen, setIsProfileOpen] = useState(false);++ const appName = config?.appName || "AI SaaS";+ const logoLetter = appName.trim().charAt(0).toUpperCase();++ // Eagerly prefetch workspace/gallery routes for fast tabs+ useEffect(() => {+ // Prefetch common routes+ }, []);++ const appMatch = pathname ? pathname.match(/^\/app\/([^\/]+)/) : null;+ const currentAppId = appMatch ? appMatch[1] : null;++ const navLinks = currentAppId+ ? [+ { name: "Workspace", path: `/app/${currentAppId}` },+ { name: "Gallery", path: `/app/${currentAppId}/gallery` },+ { name: "Pricing", path: `/app/${currentAppId}/pricing` },+ ]+ : [+ { name: "Workspace", path: "/" },+ { name: "Gallery", path: "/gallery" },+ { name: "Pricing", path: "/pricing" },+ ];++ return (+ <header className="sticky top-0 z-50 w-full glass-panel border-b border-divider/50 shadow-md">+ <div className="mx-auto flex max-w-7xl items-center justify-between px-4 py-4 sm:px-6 lg:px-8">++ {/* Logo and Brand Title (Visible at all times) */}+ <Link href="/" className="flex items-center gap-2 transition-transform hover:scale-[1.02] active:scale-95">+ <div className="flex h-9 w-9 items-center justify-center rounded-lg bg-primary text-white font-extrabold text-lg shadow-md shadow-primary/30">+ {logoLetter}+ </div>+ <span className="text-lg font-black tracking-tight text-primary-text text-nowrap">+ {appName}+ </span>+ </Link>++ {/* Desktop Navigation Links */}+ <nav className="hidden md:flex items-center gap-6">+ {navLinks.map((link) => {+ const isActive = pathname === link.path;+ return (+ <Link+ key={link.name}+ href={link.path}+ className={`text-[13px] font-semibold transition-all relative py-1 ${+ isActive ? "text-primary" : "text-secondary-text hover:text-primary-text"+ }`}+ >+ {link.name}+ {isActive && (+ <div className="absolute -bottom-[20px] left-0 right-0 h-0.5 bg-primary rounded-full" />+ )}+ </Link>+ );+ })}+ </nav>++ {/* Desktop Actions Section */}+ <div className="hidden md:flex items-center gap-4">++ {/* Vercel Deploy Button */}+ <a+ href="https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2FSamurAIGPT%2Fcommon-saas-template"+ target="_blank"+ rel="noopener noreferrer"+ className="flex items-center gap-2 rounded-full border border-divider px-4 py-1.5 text-xs font-bold text-secondary-text hover:text-primary-text hover:bg-bg-card transition-colors shadow-sm"+ >+ <SiVercel className="text-xs text-white" />+ <span>Deploy</span>+ </a>++ {status === "authenticated" ? (+ <div className="flex items-center">+ {/* Credit Balance indicator */}+ <div className="flex items-center h-9 border border-divider rounded-l bg-bg-page/30 overflow-hidden pr-2">+ <span className="font-bold text-[13px] px-3 flex items-center text-primary-text gap-1">+ <FiDollarSign className="text-emerald-500 text-xs" />+ {session.user.credits !== undefined ? session.user.credits : 0}+ </span>+ <Link+ href="/pricing"+ className="flex items-center justify-center w-5 h-5 rounded hover:bg-bg-card text-secondary-text transition-colors"+ >+ <FiPlus size={14} />+ </Link>+ </div>++ {/* Profile Menu Toggle */}+ <div className="relative">+ <button+ onClick={() => setIsProfileOpen(!isProfileOpen)}+ onBlur={() => setTimeout(() => setIsProfileOpen(false), 200)}+ className="h-9 w-9 flex items-center justify-center border-y border-r border-divider rounded-r bg-bg-page/30 hover:bg-bg-page transition-colors cursor-pointer"+ >+ {session.user.image ? (+ <img+ src={session.user.image}+ alt="Profile"+ className="h-6 w-6 rounded-full object-cover"+ />+ ) : (+ <FiUser className="text-secondary-text" size={16} />+ )}+ </button>++ {/* Profile Dropdown */}+ {isProfileOpen && (+ <div className="absolute right-0 top-11 w-48 rounded border border-divider bg-bg-card p-1 shadow-lg z-[100] animate-scale-up">+ <div className="px-3 py-2 text-xs text-secondary-text border-b border-divider/50 mb-1 truncate">+ {session.user.email}+ </div>+ <button+ onClick={() => signOut({ callbackUrl: "/login" })}+ className="flex w-full items-center gap-2 rounded px-3 py-2 text-left text-sm font-semibold text-red-500 hover:bg-red-500/10 transition-colors"+ >+ <FiLogOut size={14} />+ <span>Sign Out</span>+ </button>+ </div>+ )}+ </div>+ </div>+ ) : (+ <Link+ href="/login"+ className="bg-primary text-white px-5 py-1.5 rounded-full text-sm font-bold hover:bg-primary-hover transition-all shadow-md shadow-primary/20"+ >+ Sign In+ </Link>+ )}+ </div>++ {/* Mobile Navbar Hamburger Menu Controls */}+ <div className="flex md:hidden items-center gap-2">+ {status === "authenticated" && (+ <div className="flex items-center h-8 border border-divider rounded bg-bg-page/30 px-2.5 text-xs font-bold text-primary-text gap-0.5">+ <FiDollarSign className="text-emerald-500 text-[10px]" />+ {session.user.credits !== undefined ? session.user.credits : 0}+ </div>+ )}++ <button+ onClick={() => setIsOpen(!isOpen)}+ className="hover:bg-bg-card p-2 rounded cursor-pointer transition-colors text-primary-text border border-divider/50"+ aria-label="Toggle Menu"+ >+ {isOpen ? <IoClose size={20} /> : <IoMenu size={20} />}+ </button>+ </div>+ </div>++ {/* Absolutely Positioned Mobile Menu Dropdown (Backdrop blur + matches layout) */}+ {isOpen && (+ <div className="absolute top-full left-0 right-0 z-[200] glass-dropdown border-b border-divider shadow-2xl py-4 px-6 md:hidden animate-fade-in">+ <nav className="flex flex-col gap-3">+ <span className="text-[10px] uppercase font-bold text-secondary-text tracking-widest mb-1">Navigation</span>+ {navLinks.map((link) => (+ <Link+ key={link.name}+ href={link.path}+ onClick={() => setIsOpen(false)}+ className={`flex items-center py-2.5 rounded text-sm font-semibold transition-all ${+ pathname === link.path ? "bg-primary/10 text-primary px-3 border border-primary/20" : "text-primary-text hover:bg-bg-card"+ }`}+ >+ {link.name}+ </Link>+ ))}++ <div className="h-px bg-divider/50 my-2" />++ {/* Vercel Deploy in Mobile menu */}+ <a+ href="https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2FSamurAIGPT%2Fcommon-saas-template"+ target="_blank"+ rel="noopener noreferrer"+ className="flex w-full items-center justify-center gap-2 rounded-full border border-divider py-3 text-xs font-bold text-secondary-text hover:text-primary-text hover:bg-bg-card transition-all"+ >+ <SiVercel className="text-xs text-white" />+ <span>Clone & Deploy Template</span>+ </a>++ {status === "authenticated" ? (+ <button+ onClick={() => {+ setIsOpen(false);+ signOut({ callbackUrl: "/login" });+ }}+ className="flex w-full items-center justify-center gap-2 rounded bg-red-500/10 text-red-500 py-3 text-sm font-bold hover:bg-red-500/20 transition-all border border-red-500/20 mt-2"+ >+ <FiLogOut size={16} />+ <span>Sign Out</span>+ </button>+ ) : (+ <Link+ href="/login"+ onClick={() => setIsOpen(false)}+ className="flex w-full items-center justify-center rounded bg-primary text-white py-3 text-sm font-bold hover:bg-primary-hover transition-all shadow-md shadow-primary/20 mt-2"+ >+ Sign In+ </Link>+ )}+ </nav>+ </div>+ )}+ </header>+ );+}diff --git a/src/components/Providers.jsx b/src/components/Providers.jsxdeleted file mode 100644index 05e1c78..0000000--- a/src/components/Providers.jsx+++ /dev/null@@ -1,7 +0,0 @@-"use client";--import { SessionProvider } from "next-auth/react";--export function Providers({ children }) {- return <SessionProvider>{children}</SessionProvider>;-}diff --git a/src/components/layout/Navbar.jsx b/src/components/layout/Navbar.jsxdeleted file mode 100644index 2a92b28..0000000--- a/src/components/layout/Navbar.jsx+++ /dev/null@@ -1,176 +0,0 @@-"use client";--import Link from "next/link";-import { usePathname } from "next/navigation";-import { signIn, signOut, useSession } from "next-auth/react";-import { SiVercel } from "react-icons/si";-import { FiMenu, FiX } from "react-icons/fi";-import { useState } from "react";-import clsx from "clsx";--const navLinks = [- { name: "Workspace", href: "/" },- { name: "Integrations", href: "/integrations" },- { name: "Gallery", href: "/gallery" },- { name: "Pricing", href: "/pricing" },-];--export function Navbar() {- const pathname = usePathname();- const { data: session } = useSession();- const [mobileMenuOpen, setMobileMenuOpen] = useState(false);-- const toggleMobileMenu = () => setMobileMenuOpen(prev => !prev);-- const deployUrl = "https://vercel.com/new/clone?repository-url=https://github.com/SamurAIGPT/free-ai-social-media-scheduler";-- return (- <nav className="sticky top-0 z-50 bg-zinc-950/80 backdrop-blur-md border-b border-zinc-800/80 px-6 py-4">- <div className="max-w-7xl mx-auto w-full flex items-center justify-between">- <div className="flex items-center gap-8">- <Link href="/" className="text-lg font-bold tracking-tight text-white flex items-center gap-2">- <span className="h-2 w-2 rounded-full bg-violet-500 animate-pulse-ring" />- AI SCHEDULER- </Link>- <div className="hidden md:flex items-center gap-6">- {navLinks.map((link) => {- const isActive = pathname === link.href;- return (- <Link- key={link.name}- href={link.href}- className={clsx(- "text-sm font-medium transition-colors hover:text-white",- isActive ? "text-white" : "text-zinc-400"- )}- >- {link.name}- </Link>- );- })}- </div>- </div>-- {/* Right controls */}- <div className="flex items-center gap-4">- {/* Desktop profile & credentials */}- <div className="hidden md:flex items-center gap-4">- {session?.user ? (- <div className="flex items-center gap-4">- <span className="text-xs font-semibold text-violet-400 bg-violet-500/10 px-3 py-1.5 rounded-full border border-violet-500/20">- Credits: {session.user.credits ?? 0}- </span>- <div className="h-8 w-8 rounded-full overflow-hidden border border-zinc-700">- <img src={session.user.image || "/default-avatar.png"} alt="Profile" className="h-full w-full object-cover" />- </div>- <button- onClick={() => signOut()}- className="text-xs font-medium text-zinc-400 hover:text-white transition-colors"- >- Sign out- </button>- </div>- ) : (- <button- onClick={() => signIn("google")}- className="px-4 py-1.5 text-xs font-semibold text-zinc-950 bg-white rounded-lg hover:bg-zinc-200 transition-colors"- >- Sign in- </button>- )}-- <a- href={deployUrl}- target="_blank"- rel="noopener noreferrer"- className="flex items-center gap-1.5 px-3 py-1.5 rounded-lg bg-zinc-900 border border-zinc-800 text-white hover:bg-zinc-800 transition-all font-bold text-[9px] tracking-wider uppercase shadow-lg"- >- <SiVercel className="text-[10px]" />- Deploy- </a>- </div>-- {/* Mobile Hamburger Button */}- <button- onClick={toggleMobileMenu}- className="md:hidden p-2 text-zinc-400 hover:text-white rounded-lg focus:outline-none"- >- {mobileMenuOpen ? <FiX className="text-xl" /> : <FiMenu className="text-xl" />}- </button>- </div>-- {/* Mobile Absolute Dropdown Menu Overlay */}- {mobileMenuOpen && (- <div className="absolute top-full left-0 right-0 z-[200] bg-zinc-950/95 backdrop-blur-lg border-b border-zinc-800 flex flex-col p-6 gap-4 animate-fade-in md:hidden">- {navLinks.map((link) => {- const isActive = pathname === link.href;- return (- <Link- key={link.name}- href={link.href}- onClick={() => setMobileMenuOpen(false)}- className={clsx(- "text-sm font-medium py-2 transition-colors hover:text-white border-b border-zinc-900",- isActive ? "text-white" : "text-zinc-400"- )}- >- {link.name}- </Link>- );- })}-- <div className="flex flex-col gap-4 mt-2 pt-2">- {session?.user ? (- <div className="flex flex-col gap-3">- <div className="flex items-center gap-3">- <div className="h-8 w-8 rounded-full overflow-hidden border border-zinc-700">- <img src={session.user.image || "/default-avatar.png"} alt="Profile" className="h-full w-full object-cover" />- </div>- <div className="flex flex-col">- <span className="text-xs font-semibold text-white">{session.user.name}</span>- <span className="text-[10px] text-zinc-500">{session.user.email}</span>- </div>- </div>- <div className="flex justify-between items-center bg-violet-500/10 border border-violet-500/20 px-3 py-2 rounded-lg">- <span className="text-xs text-zinc-400">Available Balance</span>- <span className="text-xs font-bold text-violet-400">{session.user.credits ?? 0} Credits</span>- </div>- <button- onClick={() => {- signOut();- setMobileMenuOpen(false);- }}- className="w-full py-2 bg-zinc-900 hover:bg-zinc-800 border border-zinc-800 rounded-lg text-xs font-medium text-zinc-300 hover:text-white transition-colors"- >- Sign out- </button>- </div>- ) : (- <button- onClick={() => {- signIn("google");- setMobileMenuOpen(false);- }}- className="w-full py-2 text-xs font-semibold text-zinc-950 bg-white rounded-lg hover:bg-zinc-200 transition-colors"- >- Sign in with Google- </button>- )}-- <a- href={deployUrl}- target="_blank"- rel="noopener noreferrer"- onClick={() => setMobileMenuOpen(false)}- className="flex items-center justify-center gap-1.5 w-full py-2 rounded-lg bg-zinc-900 border border-zinc-800 text-white hover:bg-zinc-800 transition-all font-bold text-[10px] tracking-wider uppercase"- >- <SiVercel className="text-xs" />- Deploy to Vercel- </a>- </div>- </div>- )}- </div>- </nav>- );-}diff --git a/src/lib/auth.js b/src/lib/auth.jsindex 0e8f606..205f642 100644--- a/src/lib/auth.js+++ b/src/lib/auth.js@@ -1,14 +1,13 @@import { PrismaAdapter } from "@next-auth/prisma-adapter";import GoogleProvider from "next-auth/providers/google";import { prisma } from "./prisma";-import config from "./config";export const authOptions = {adapter: PrismaAdapter(prisma),providers: [GoogleProvider({- clientId: config.auth.google.clientId,- clientSecret: config.auth.google.clientSecret,+ clientId: process.env.GOOGLE_CLIENT_ID,+ clientSecret: process.env.GOOGLE_CLIENT_SECRET,}),],callbacks: {@@ -20,5 +19,8 @@ export const authOptions = {return session;},},- secret: config.auth.secret,+ secret: process.env.NEXTAUTH_SECRET,+ pages: {+ signIn: "/login",+ },};diff --git a/src/lib/config.js b/src/lib/config.jsindex e2c7789..be1fc77 100644--- a/src/lib/config.js+++ b/src/lib/config.js@@ -1,4 +1,5 @@const config = {+ appName: "Free Ai Social Media Scheduler",auth: {google: {clientId: process.env.GOOGLE_CLIENT_ID,diff --git a/src/lib/prisma.js b/src/lib/prisma.jsindex b8335ea..f993c5e 100644--- a/src/lib/prisma.js+++ b/src/lib/prisma.js@@ -11,8 +11,7 @@ export const prisma =globalForPrisma.prisma ||new PrismaClient({adapter,- log:- process.env.NODE_ENV === "development" ? ["query", "error", "warn"] : ["error"],+ log: process.env.NODE_ENV === "development" ? ["query", "error", "warn"] : ["error"],});if (process.env.NODE_ENV !== "production") globalForPrisma.prisma = prisma;diff --git a/src/lib/services/billing.js b/src/lib/services/billing.jsindex 0649447..4ca83a9 100644--- a/src/lib/services/billing.js+++ b/src/lib/services/billing.js@@ -14,8 +14,8 @@ export const BillingService = {price_data: {currency: "usd",product_data: {- name: `AI Social Scheduler - ${plan.name}`,- description: `Purchase ${plan.credits} credits to publish/schedule social media posts.`,+ name: `${config.stripe.plans[planId].name}`,+ description: `Purchase ${plan.credits} credits to perform AI generations.`,},unit_amount: plan.price,},diff --git a/src/lib/services/user.js b/src/lib/services/user.jsindex 7ab54e5..1ecfd4d 100644--- a/src/lib/services/user.js+++ b/src/lib/services/user.js@@ -1,34 +1,40 @@import { prisma } from "../prisma";export const UserService = {- async addCredits(userId, credits) {+ async getCredits(userId) {+ const user = await prisma.user.findUnique({+ where: { id: userId },+ select: { credits: true },+ });+ return user ? user.credits : 0;+ },++ async addCredits(userId, amount) {+ if (amount <= 0) return;return await prisma.user.update({where: { id: userId },data: {credits: {- increment: credits,+ increment: amount,},},});},- async deductCredits(userId, credits) {- // 1. Get user credits- const user = await prisma.user.findUnique({- where: { id: userId },- select: { credits: true },- });-- if (!user || user.credits < credits) {- throw new Error("Insufficient credits");+ async deductCredits(userId, amount) {+ if (amount <= 0) return;++ // Check if the user has enough credits+ const currentCredits = await this.getCredits(userId);+ if (currentCredits < amount) {+ throw new Error("Insufficient credits available");}- // 2. Deduct creditsreturn await prisma.user.update({where: { id: userId },data: {credits: {- decrement: credits,+ decrement: amount,},},});diff --git a/src/lib/stripe.js b/src/lib/stripe.jsindex 70a484d..f8a3542 100644--- a/src/lib/stripe.js+++ b/src/lib/stripe.js@@ -1,6 +1,10 @@import Stripe from "stripe";import config from "./config";-export const stripe = new Stripe(config.stripe.secretKey, {- apiVersion: "2022-11-15",+const apiKey = config.stripe.secretKey && config.stripe.secretKey.trim() !== ""+ ? config.stripe.secretKey+ : "sk_test_placeholder_key_for_build_purposes";++export const stripe = new Stripe(apiKey, {+ apiVersion: "2023-10-16",});