mirror of
https://github.com/nomadkaraoke/karaoke-gen.git
synced 2026-11-28 01:49:00 +09:00
Compare commits
15
Commits
No files matched your search
@@ -31,7 +31,6 @@ jobs:
|
||||
package: ${{ steps.filter.outputs.package }}
|
||||
infra: ${{ steps.filter.outputs.infra }}
|
||||
deps: ${{ steps.filter.outputs.deps }}
|
||||
buy_site: ${{ steps.filter.outputs.buy_site }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
@@ -51,8 +50,6 @@ jobs:
|
||||
- 'infrastructure/**'
|
||||
deps:
|
||||
- 'poetry.lock'
|
||||
buy_site:
|
||||
- 'buy-site/**'
|
||||
|
||||
- name: Summary
|
||||
run: |
|
||||
@@ -64,7 +61,6 @@ jobs:
|
||||
echo "| Package | ${{ steps.filter.outputs.package }} |" >> $GITHUB_STEP_SUMMARY
|
||||
echo "| Infrastructure | ${{ steps.filter.outputs.infra }} |" >> $GITHUB_STEP_SUMMARY
|
||||
echo "| Dependencies | ${{ steps.filter.outputs.deps }} |" >> $GITHUB_STEP_SUMMARY
|
||||
echo "| Buy Site | ${{ steps.filter.outputs.buy_site }} |" >> $GITHUB_STEP_SUMMARY
|
||||
|
||||
# ============================================
|
||||
# FRONTEND TESTS (PRs only - main skips tests)
|
||||
@@ -628,37 +624,9 @@ jobs:
|
||||
id: deployment
|
||||
uses: actions/deploy-pages@v4
|
||||
|
||||
deploy-buy-site:
|
||||
name: "Deploy - Buy Site (Cloudflare Pages)"
|
||||
runs-on: ubuntu-latest
|
||||
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Node.js with caching
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: '20'
|
||||
cache: 'npm'
|
||||
cache-dependency-path: buy-site/package-lock.json
|
||||
|
||||
- name: Install dependencies
|
||||
working-directory: buy-site
|
||||
run: npm ci
|
||||
|
||||
- name: Build buy-site (Next.js static export)
|
||||
working-directory: buy-site
|
||||
env:
|
||||
NEXT_PUBLIC_API_URL: https://api.nomadkaraoke.com
|
||||
run: npm run build
|
||||
|
||||
- name: Deploy to Cloudflare Pages
|
||||
uses: cloudflare/wrangler-action@v3
|
||||
with:
|
||||
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
|
||||
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
|
||||
command: pages deploy buy-site/out --project-name=nomadkaraoke-buy --branch=main
|
||||
# NOTE: buy-site was consolidated into the main frontend (PR #122, Dec 2024)
|
||||
# Landing page and payment flow are now at gen.nomadkaraoke.com (root)
|
||||
# buy.nomadkaraoke.com subdomain has been deleted
|
||||
|
||||
deploy-backend:
|
||||
name: "Deploy - Backend (Cloud Run)"
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
|
||||
| What | Where |
|
||||
|------|-------|
|
||||
| Product vision & goals | `docs/PRODUCT-VISION.md` |
|
||||
| Current status | `docs/README.md` |
|
||||
| Architecture | `docs/ARCHITECTURE.md` |
|
||||
| Dev setup & testing | `docs/DEVELOPMENT.md` |
|
||||
|
||||
@@ -121,12 +121,13 @@ class EmailService:
|
||||
self.settings = get_settings()
|
||||
self.provider = self._get_provider()
|
||||
self.frontend_url = os.getenv("FRONTEND_URL", "https://gen.nomadkaraoke.com")
|
||||
self.buy_url = os.getenv("BUY_URL", "https://buy.nomadkaraoke.com")
|
||||
# After consolidation, buy URL is the same as frontend URL
|
||||
self.buy_url = os.getenv("BUY_URL", self.frontend_url)
|
||||
|
||||
def _get_provider(self) -> EmailProvider:
|
||||
"""Get the configured email provider."""
|
||||
sendgrid_api_key = os.getenv("SENDGRID_API_KEY")
|
||||
from_email = os.getenv("EMAIL_FROM", "noreply@nomadkaraoke.com")
|
||||
from_email = os.getenv("EMAIL_FROM", "gen@nomadkaraoke.com")
|
||||
from_name = os.getenv("EMAIL_FROM_NAME", "Nomad Karaoke")
|
||||
|
||||
if sendgrid_api_key:
|
||||
|
||||
@@ -56,7 +56,8 @@ class StripeService:
|
||||
self.secret_key = os.getenv("STRIPE_SECRET_KEY")
|
||||
self.webhook_secret = os.getenv("STRIPE_WEBHOOK_SECRET")
|
||||
self.frontend_url = os.getenv("FRONTEND_URL", "https://gen.nomadkaraoke.com")
|
||||
self.buy_url = os.getenv("BUY_URL", "https://buy.nomadkaraoke.com")
|
||||
# After consolidation, buy URL is the same as frontend URL
|
||||
self.buy_url = os.getenv("BUY_URL", self.frontend_url)
|
||||
|
||||
if self.secret_key:
|
||||
stripe.api_key = self.secret_key
|
||||
|
||||
@@ -47,6 +47,9 @@ MAX_CREDIT_TRANSACTIONS = 100 # Keep last N transactions
|
||||
class UserService:
|
||||
"""Service for user management and authentication."""
|
||||
|
||||
# Number of free credits granted to new users
|
||||
NEW_USER_FREE_CREDITS = 1
|
||||
|
||||
def __init__(self):
|
||||
"""Initialize user service with Firestore client."""
|
||||
self.settings = get_settings()
|
||||
@@ -71,17 +74,32 @@ class UserService:
|
||||
return None
|
||||
|
||||
def get_or_create_user(self, email: str) -> User:
|
||||
"""Get existing user or create a new one."""
|
||||
"""
|
||||
Get existing user or create a new one.
|
||||
|
||||
New users receive a welcome credit to try the service.
|
||||
"""
|
||||
email = email.lower()
|
||||
user = self.get_user(email)
|
||||
|
||||
if user:
|
||||
return user
|
||||
|
||||
# Create new user
|
||||
user = User(email=email)
|
||||
# Create new user with welcome credit
|
||||
welcome_credit = self.NEW_USER_FREE_CREDITS
|
||||
welcome_transaction = CreditTransaction(
|
||||
id=str(uuid.uuid4()),
|
||||
amount=welcome_credit,
|
||||
reason="welcome_credit",
|
||||
)
|
||||
|
||||
user = User(
|
||||
email=email,
|
||||
credits=welcome_credit,
|
||||
credit_transactions=[welcome_transaction],
|
||||
)
|
||||
self._save_user(user)
|
||||
logger.info(f"Created new user: {email}")
|
||||
logger.info(f"Created new user: {email} with {welcome_credit} welcome credit(s)")
|
||||
return user
|
||||
|
||||
def _save_user(self, user: User) -> None:
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
# API URL for the karaoke backend
|
||||
NEXT_PUBLIC_API_URL=https://api.nomadkaraoke.com
|
||||
@@ -1,38 +0,0 @@
|
||||
# Dependencies
|
||||
node_modules/
|
||||
.pnp
|
||||
.pnp.js
|
||||
|
||||
# Build output
|
||||
.next/
|
||||
out/
|
||||
build/
|
||||
|
||||
# Debug
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
|
||||
# Local env files
|
||||
.env
|
||||
.env.local
|
||||
.env.development.local
|
||||
.env.test.local
|
||||
.env.production.local
|
||||
|
||||
# Vercel
|
||||
.vercel
|
||||
|
||||
# IDE
|
||||
.idea/
|
||||
.vscode/
|
||||
*.swp
|
||||
*.swo
|
||||
|
||||
# OS
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
|
||||
# TypeScript
|
||||
*.tsbuildinfo
|
||||
next-env.d.ts
|
||||
@@ -1,99 +0,0 @@
|
||||
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');
|
||||
|
||||
@tailwind base;
|
||||
@tailwind components;
|
||||
@tailwind utilities;
|
||||
|
||||
:root {
|
||||
--foreground: #f8fafc;
|
||||
--background: #0f172a;
|
||||
}
|
||||
|
||||
body {
|
||||
color: var(--foreground);
|
||||
background: var(--background);
|
||||
font-family: 'Inter', system-ui, sans-serif;
|
||||
}
|
||||
|
||||
/* Smooth scrolling */
|
||||
html {
|
||||
scroll-behavior: smooth;
|
||||
}
|
||||
|
||||
/* Custom scrollbar for dark theme */
|
||||
::-webkit-scrollbar {
|
||||
width: 8px;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-track {
|
||||
background: #1e293b;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-thumb {
|
||||
background: #475569;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-thumb:hover {
|
||||
background: #64748b;
|
||||
}
|
||||
|
||||
/* Glow effect for primary buttons */
|
||||
.btn-glow {
|
||||
box-shadow: 0 0 20px rgba(59, 130, 246, 0.5);
|
||||
}
|
||||
|
||||
.btn-glow:hover {
|
||||
box-shadow: 0 0 30px rgba(59, 130, 246, 0.7);
|
||||
}
|
||||
|
||||
/* Gradient text */
|
||||
.gradient-text {
|
||||
background: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 50%, #ec4899 100%);
|
||||
-webkit-background-clip: text;
|
||||
-webkit-text-fill-color: transparent;
|
||||
background-clip: text;
|
||||
}
|
||||
|
||||
/* Card hover effect */
|
||||
.card-hover {
|
||||
transition: transform 0.2s ease, box-shadow 0.2s ease;
|
||||
}
|
||||
|
||||
.card-hover:hover {
|
||||
transform: translateY(-4px);
|
||||
box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
|
||||
}
|
||||
|
||||
/* Animated background gradient */
|
||||
@keyframes gradient-shift {
|
||||
0% {
|
||||
background-position: 0% 50%;
|
||||
}
|
||||
50% {
|
||||
background-position: 100% 50%;
|
||||
}
|
||||
100% {
|
||||
background-position: 0% 50%;
|
||||
}
|
||||
}
|
||||
|
||||
.animated-gradient {
|
||||
background: linear-gradient(-45deg, #0f172a, #1e293b, #1e3a8a, #312e81);
|
||||
background-size: 400% 400%;
|
||||
animation: gradient-shift 15s ease infinite;
|
||||
}
|
||||
|
||||
/* Price highlight animation */
|
||||
@keyframes pulse-subtle {
|
||||
0%, 100% {
|
||||
opacity: 1;
|
||||
}
|
||||
50% {
|
||||
opacity: 0.8;
|
||||
}
|
||||
}
|
||||
|
||||
.pulse-subtle {
|
||||
animation: pulse-subtle 2s ease-in-out infinite;
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
import type { Metadata } from 'next';
|
||||
import './globals.css';
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: 'Nomad Karaoke - Turn Any Song Into a Karaoke Video',
|
||||
description: 'Create professional karaoke videos in minutes. AI-powered vocal separation, perfect lyrics sync, and 4K video output.',
|
||||
keywords: ['karaoke', 'karaoke video', 'karaoke maker', 'vocal removal', 'lyrics sync'],
|
||||
authors: [{ name: 'Nomad Karaoke' }],
|
||||
openGraph: {
|
||||
title: 'Nomad Karaoke - Turn Any Song Into a Karaoke Video',
|
||||
description: 'Create professional karaoke videos in minutes with AI.',
|
||||
type: 'website',
|
||||
url: 'https://buy.nomadkaraoke.com',
|
||||
images: [
|
||||
{
|
||||
url: 'https://gen.nomadkaraoke.com/nomad-logo.png',
|
||||
width: 512,
|
||||
height: 512,
|
||||
alt: 'Nomad Karaoke',
|
||||
},
|
||||
],
|
||||
},
|
||||
twitter: {
|
||||
card: 'summary_large_image',
|
||||
title: 'Nomad Karaoke - Turn Any Song Into a Karaoke Video',
|
||||
description: 'Create professional karaoke videos in minutes with AI.',
|
||||
},
|
||||
};
|
||||
|
||||
export default function RootLayout({
|
||||
children,
|
||||
}: {
|
||||
children: React.ReactNode;
|
||||
}) {
|
||||
return (
|
||||
<html lang="en">
|
||||
<head>
|
||||
<link rel="icon" href="https://nomadkaraoke.com/favicon.ico" />
|
||||
</head>
|
||||
<body className="min-h-screen animated-gradient">
|
||||
{children}
|
||||
</body>
|
||||
</html>
|
||||
);
|
||||
}
|
||||
@@ -1,585 +0,0 @@
|
||||
'use client';
|
||||
|
||||
import { useState } from 'react';
|
||||
import { Mic2, Music, Sparkles, Video, Youtube, Check, ChevronDown, Mail, Loader2, Gift, MessageSquare, CheckCircle2 } from 'lucide-react';
|
||||
import { enrollBetaTester } from '../lib/api';
|
||||
|
||||
// Credit packages (matching backend)
|
||||
const CREDIT_PACKAGES = [
|
||||
{
|
||||
id: '1_credit',
|
||||
credits: 1,
|
||||
price_cents: 500,
|
||||
name: '1 Credit',
|
||||
description: 'Create 1 karaoke video',
|
||||
popular: false,
|
||||
},
|
||||
{
|
||||
id: '3_credits',
|
||||
credits: 3,
|
||||
price_cents: 1200,
|
||||
name: '3 Credits',
|
||||
description: 'Save 20%',
|
||||
popular: false,
|
||||
},
|
||||
{
|
||||
id: '5_credits',
|
||||
credits: 5,
|
||||
price_cents: 1750,
|
||||
name: '5 Credits',
|
||||
description: 'Save 30%',
|
||||
popular: true,
|
||||
},
|
||||
{
|
||||
id: '10_credits',
|
||||
credits: 10,
|
||||
price_cents: 3000,
|
||||
name: '10 Credits',
|
||||
description: 'Save 40%',
|
||||
popular: false,
|
||||
},
|
||||
];
|
||||
|
||||
const API_BASE_URL = process.env.NEXT_PUBLIC_API_URL || 'https://api.nomadkaraoke.com';
|
||||
|
||||
function formatPrice(cents: number): string {
|
||||
return `$${(cents / 100).toFixed(0)}`;
|
||||
}
|
||||
|
||||
function pricePerCredit(priceCents: number, credits: number): string {
|
||||
return `$${(priceCents / 100 / credits).toFixed(2)}`;
|
||||
}
|
||||
|
||||
export default function Home() {
|
||||
const [selectedPackage, setSelectedPackage] = useState(CREDIT_PACKAGES[2]); // Default to 5 credits
|
||||
const [email, setEmail] = useState('');
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
const [error, setError] = useState('');
|
||||
const [expandedFaq, setExpandedFaq] = useState<number | null>(null);
|
||||
|
||||
// Beta tester form state
|
||||
const [showBetaForm, setShowBetaForm] = useState(false);
|
||||
const [betaEmail, setBetaEmail] = useState('');
|
||||
const [betaPromise, setBetaPromise] = useState('');
|
||||
const [betaAcceptCorrections, setBetaAcceptCorrections] = useState(false);
|
||||
const [betaLoading, setBetaLoading] = useState(false);
|
||||
const [betaError, setBetaError] = useState('');
|
||||
const [betaSuccess, setBetaSuccess] = useState(false);
|
||||
|
||||
const handleBetaEnroll = async (e: React.FormEvent) => {
|
||||
e.preventDefault();
|
||||
setBetaError('');
|
||||
|
||||
if (!betaEmail) {
|
||||
setBetaError('Please enter your email');
|
||||
return;
|
||||
}
|
||||
|
||||
if (!betaAcceptCorrections) {
|
||||
setBetaError('Please accept that you may need to review/correct lyrics');
|
||||
return;
|
||||
}
|
||||
|
||||
if (betaPromise.trim().length < 10) {
|
||||
setBetaError('Please write a sentence confirming your promise to provide feedback');
|
||||
return;
|
||||
}
|
||||
|
||||
setBetaLoading(true);
|
||||
|
||||
try {
|
||||
const response = await enrollBetaTester(betaEmail.toLowerCase(), betaPromise, betaAcceptCorrections);
|
||||
|
||||
// Store the session token
|
||||
if (response.session_token) {
|
||||
localStorage.setItem('nomad_karaoke_token', response.session_token);
|
||||
}
|
||||
|
||||
setBetaSuccess(true);
|
||||
|
||||
// Redirect to the main app after a short delay
|
||||
setTimeout(() => {
|
||||
window.location.href = 'https://gen.nomadkaraoke.com';
|
||||
}, 2000);
|
||||
} catch (err) {
|
||||
setBetaError(err instanceof Error ? err.message : 'Something went wrong');
|
||||
setBetaLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handleCheckout = async (e: React.FormEvent) => {
|
||||
e.preventDefault();
|
||||
setError('');
|
||||
|
||||
if (!email) {
|
||||
setError('Please enter your email');
|
||||
return;
|
||||
}
|
||||
|
||||
setIsLoading(true);
|
||||
|
||||
try {
|
||||
const response = await fetch(`${API_BASE_URL}/api/users/credits/checkout`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify({
|
||||
package_id: selectedPackage.id,
|
||||
email: email.toLowerCase(),
|
||||
}),
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
const data = await response.json();
|
||||
throw new Error(data.detail || 'Failed to create checkout');
|
||||
}
|
||||
|
||||
const data = await response.json();
|
||||
window.location.href = data.checkout_url;
|
||||
} catch (err) {
|
||||
setError(err instanceof Error ? err.message : 'Something went wrong');
|
||||
setIsLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
const faqs = [
|
||||
{
|
||||
q: 'How does it work?',
|
||||
a: 'Just enter a song (artist + title), and our AI finds the audio, removes the vocals, transcribes the lyrics, and creates a professional karaoke video with perfectly synced lyrics.',
|
||||
},
|
||||
{
|
||||
q: 'What songs can I use?',
|
||||
a: "Most popular songs are available. We search multiple high-quality audio sources to find the best version. If we can't find a song, you won't be charged.",
|
||||
},
|
||||
{
|
||||
q: 'What format is the output?',
|
||||
a: 'You get a high-quality MP4 video file (up to 4K) with the instrumental audio and synchronized lyrics. You can also upload directly to YouTube.',
|
||||
},
|
||||
{
|
||||
q: 'What if something goes wrong?',
|
||||
a: "We offer generous refunds. If the quality isn't what you expected or there's an issue with the output, contact us and we'll refund your credit.",
|
||||
},
|
||||
{
|
||||
q: 'Do credits expire?',
|
||||
a: 'No, your credits never expire. Use them whenever you want.',
|
||||
},
|
||||
];
|
||||
|
||||
return (
|
||||
<div className="min-h-screen">
|
||||
{/* Navigation */}
|
||||
<nav className="fixed top-0 left-0 right-0 z-50 bg-dark-900/80 backdrop-blur-md border-b border-dark-700">
|
||||
<div className="max-w-6xl mx-auto px-4 py-4 flex items-center justify-between">
|
||||
<div className="flex items-center gap-2">
|
||||
<Mic2 className="w-8 h-8 text-primary-500" />
|
||||
<span className="text-xl font-bold">Nomad Karaoke</span>
|
||||
</div>
|
||||
<a
|
||||
href="https://gen.nomadkaraoke.com"
|
||||
className="text-sm text-dark-300 hover:text-white transition-colors"
|
||||
>
|
||||
Already have credits? Sign in
|
||||
</a>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
{/* Hero Section */}
|
||||
<section className="pt-32 pb-16 px-4">
|
||||
<div className="max-w-4xl mx-auto text-center">
|
||||
<h1 className="text-4xl sm:text-5xl md:text-6xl font-extrabold mb-6 leading-tight">
|
||||
Turn Any Song Into a{' '}
|
||||
<span className="gradient-text">Karaoke Video</span>
|
||||
</h1>
|
||||
<p className="text-xl text-dark-300 mb-8 max-w-2xl mx-auto">
|
||||
Professional karaoke videos in minutes. AI-powered vocal removal,
|
||||
perfect lyrics sync, and stunning video output.
|
||||
</p>
|
||||
<a
|
||||
href="#pricing"
|
||||
className="inline-flex items-center gap-2 bg-primary-500 hover:bg-primary-600 text-white font-semibold px-8 py-4 rounded-xl transition-all btn-glow"
|
||||
>
|
||||
Get Started
|
||||
<ChevronDown className="w-5 h-5" />
|
||||
</a>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{/* How It Works */}
|
||||
<section className="py-16 px-4">
|
||||
<div className="max-w-6xl mx-auto">
|
||||
<h2 className="text-3xl font-bold text-center mb-12">How It Works</h2>
|
||||
<div className="grid md:grid-cols-4 gap-8">
|
||||
{[
|
||||
{
|
||||
icon: Music,
|
||||
title: 'Search',
|
||||
desc: 'Enter artist & song title',
|
||||
},
|
||||
{
|
||||
icon: Sparkles,
|
||||
title: 'AI Magic',
|
||||
desc: 'We remove vocals & sync lyrics',
|
||||
},
|
||||
{
|
||||
icon: Video,
|
||||
title: 'Review',
|
||||
desc: 'Preview and fine-tune',
|
||||
},
|
||||
{
|
||||
icon: Youtube,
|
||||
title: 'Export',
|
||||
desc: 'Download or upload to YouTube',
|
||||
},
|
||||
].map((step, i) => (
|
||||
<div key={i} className="text-center">
|
||||
<div className="w-16 h-16 bg-primary-500/20 rounded-2xl flex items-center justify-center mx-auto mb-4">
|
||||
<step.icon className="w-8 h-8 text-primary-400" />
|
||||
</div>
|
||||
<h3 className="font-semibold text-lg mb-2">{step.title}</h3>
|
||||
<p className="text-dark-400 text-sm">{step.desc}</p>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{/* Features */}
|
||||
<section className="py-16 px-4 bg-dark-800/50">
|
||||
<div className="max-w-6xl mx-auto">
|
||||
<h2 className="text-3xl font-bold text-center mb-12">What You Get</h2>
|
||||
<div className="grid md:grid-cols-3 gap-6">
|
||||
{[
|
||||
{
|
||||
title: 'Studio-Quality Separation',
|
||||
desc: 'State-of-the-art AI removes vocals cleanly, keeping the instrumental crisp.',
|
||||
},
|
||||
{
|
||||
title: 'Perfect Lyrics Sync',
|
||||
desc: 'Word-by-word timing that highlights exactly when to sing.',
|
||||
},
|
||||
{
|
||||
title: 'Multiple Instrumental Options',
|
||||
desc: 'Choose from different vocal removal levels to get the sound you want.',
|
||||
},
|
||||
{
|
||||
title: '4K Video Output',
|
||||
desc: 'Stunning video quality that looks great on any screen.',
|
||||
},
|
||||
{
|
||||
title: 'YouTube Integration',
|
||||
desc: 'Upload directly to your YouTube channel with one click.',
|
||||
},
|
||||
{
|
||||
title: 'Edit Before Export',
|
||||
desc: 'Fix any lyrics issues before generating your final video.',
|
||||
},
|
||||
].map((feature, i) => (
|
||||
<div
|
||||
key={i}
|
||||
className="bg-dark-800 border border-dark-700 rounded-xl p-6 card-hover"
|
||||
>
|
||||
<h3 className="font-semibold text-lg mb-2">{feature.title}</h3>
|
||||
<p className="text-dark-400 text-sm">{feature.desc}</p>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{/* Beta Tester Promo */}
|
||||
<section className="py-12 px-4">
|
||||
<div className="max-w-2xl mx-auto">
|
||||
{!showBetaForm && !betaSuccess ? (
|
||||
<div className="bg-gradient-to-r from-purple-900/40 to-pink-900/40 border border-purple-500/30 rounded-2xl p-8 text-center">
|
||||
<div className="inline-flex items-center gap-2 bg-purple-500/20 text-purple-300 px-4 py-2 rounded-full text-sm font-medium mb-4">
|
||||
<Gift className="w-4 h-4" />
|
||||
Beta Tester Program
|
||||
</div>
|
||||
<h3 className="text-2xl font-bold mb-3">Try It Free!</h3>
|
||||
<p className="text-dark-300 mb-6">
|
||||
Help us improve by testing the tool and sharing your feedback.
|
||||
Get a <span className="text-green-400 font-semibold">free credit</span> to create your first karaoke video!
|
||||
</p>
|
||||
<button
|
||||
onClick={() => setShowBetaForm(true)}
|
||||
className="inline-flex items-center gap-2 bg-purple-500 hover:bg-purple-600 text-white font-semibold px-6 py-3 rounded-xl transition-all"
|
||||
>
|
||||
Join Beta Program
|
||||
<MessageSquare className="w-5 h-5" />
|
||||
</button>
|
||||
</div>
|
||||
) : betaSuccess ? (
|
||||
<div className="bg-green-900/30 border border-green-500/30 rounded-2xl p-8 text-center">
|
||||
<CheckCircle2 className="w-16 h-16 text-green-400 mx-auto mb-4" />
|
||||
<h3 className="text-2xl font-bold mb-3 text-green-400">Welcome to the Beta!</h3>
|
||||
<p className="text-dark-300 mb-4">
|
||||
You've got 1 free credit! Redirecting you to create your first karaoke video...
|
||||
</p>
|
||||
<Loader2 className="w-6 h-6 animate-spin mx-auto text-green-400" />
|
||||
</div>
|
||||
) : (
|
||||
<div className="bg-dark-800 border border-purple-500/30 rounded-2xl p-8">
|
||||
<div className="flex items-center justify-between mb-6">
|
||||
<div className="inline-flex items-center gap-2 bg-purple-500/20 text-purple-300 px-4 py-2 rounded-full text-sm font-medium">
|
||||
<Gift className="w-4 h-4" />
|
||||
Beta Tester Signup
|
||||
</div>
|
||||
<button
|
||||
onClick={() => setShowBetaForm(false)}
|
||||
className="text-dark-400 hover:text-white transition-colors text-sm"
|
||||
>
|
||||
Cancel
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<h3 className="text-xl font-bold mb-2">Get 1 Free Credit</h3>
|
||||
<p className="text-dark-400 text-sm mb-6">
|
||||
In exchange for your honest feedback after trying the tool.
|
||||
</p>
|
||||
|
||||
<form onSubmit={handleBetaEnroll} className="space-y-4">
|
||||
<div>
|
||||
<label htmlFor="beta-email" className="block text-sm font-medium text-dark-300 mb-2">
|
||||
Email address
|
||||
</label>
|
||||
<div className="relative">
|
||||
<Mail className="absolute left-3 top-1/2 -translate-y-1/2 w-5 h-5 text-dark-500" />
|
||||
<input
|
||||
type="email"
|
||||
id="beta-email"
|
||||
value={betaEmail}
|
||||
onChange={(e) => setBetaEmail(e.target.value)}
|
||||
placeholder="you@example.com"
|
||||
className="w-full pl-10 pr-4 py-3 bg-dark-900 border border-dark-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-purple-500 focus:border-transparent text-white placeholder-dark-500"
|
||||
required
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="bg-dark-900/50 border border-dark-700 rounded-lg p-4">
|
||||
<h4 className="font-medium mb-3 text-sm">Your Promise</h4>
|
||||
|
||||
<label className="flex items-start gap-3 cursor-pointer mb-4">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={betaAcceptCorrections}
|
||||
onChange={(e) => setBetaAcceptCorrections(e.target.checked)}
|
||||
className="mt-1 w-4 h-4 rounded border-dark-600 bg-dark-800 text-purple-500 focus:ring-purple-500 focus:ring-offset-dark-900"
|
||||
/>
|
||||
<span className="text-sm text-dark-300">
|
||||
I understand I may need to review and correct lyrics timing to get the best results
|
||||
</span>
|
||||
</label>
|
||||
|
||||
<div>
|
||||
<label htmlFor="promise" className="block text-sm text-dark-400 mb-2">
|
||||
Write a quick sentence promising to share feedback after you try it:
|
||||
</label>
|
||||
<textarea
|
||||
id="promise"
|
||||
value={betaPromise}
|
||||
onChange={(e) => setBetaPromise(e.target.value)}
|
||||
placeholder="I promise to share my honest feedback about my experience..."
|
||||
rows={2}
|
||||
className="w-full px-4 py-3 bg-dark-800 border border-dark-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-purple-500 focus:border-transparent text-white placeholder-dark-500 text-sm resize-none"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{betaError && (
|
||||
<div className="text-red-400 text-sm bg-red-400/10 border border-red-400/20 rounded-lg p-3">
|
||||
{betaError}
|
||||
</div>
|
||||
)}
|
||||
|
||||
<button
|
||||
type="submit"
|
||||
disabled={betaLoading}
|
||||
className="w-full bg-purple-500 hover:bg-purple-600 disabled:bg-purple-500/50 text-white font-semibold py-4 rounded-xl transition-all flex items-center justify-center gap-2"
|
||||
>
|
||||
{betaLoading ? (
|
||||
<>
|
||||
<Loader2 className="w-5 h-5 animate-spin" />
|
||||
Enrolling...
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
Get My Free Credit
|
||||
<Gift className="w-5 h-5" />
|
||||
</>
|
||||
)}
|
||||
</button>
|
||||
|
||||
<p className="text-xs text-dark-500 text-center">
|
||||
We'll send you a feedback form after your video is created.
|
||||
Your feedback helps us improve the tool for everyone!
|
||||
</p>
|
||||
</form>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{/* Pricing */}
|
||||
<section id="pricing" className="py-20 px-4">
|
||||
<div className="max-w-4xl mx-auto">
|
||||
<h2 className="text-3xl font-bold text-center mb-4">Simple Pricing</h2>
|
||||
<p className="text-dark-400 text-center mb-12 max-w-xl mx-auto">
|
||||
One credit = one karaoke video. Buy more to save more.
|
||||
</p>
|
||||
|
||||
{/* Package Selection */}
|
||||
<div className="grid grid-cols-2 md:grid-cols-4 gap-4 mb-8">
|
||||
{CREDIT_PACKAGES.map((pkg) => (
|
||||
<button
|
||||
key={pkg.id}
|
||||
onClick={() => setSelectedPackage(pkg)}
|
||||
className={`relative p-4 rounded-xl border-2 transition-all ${
|
||||
selectedPackage.id === pkg.id
|
||||
? 'border-primary-500 bg-primary-500/10'
|
||||
: 'border-dark-700 hover:border-dark-500 bg-dark-800/50'
|
||||
}`}
|
||||
>
|
||||
{pkg.popular && (
|
||||
<span className="absolute -top-3 left-1/2 -translate-x-1/2 bg-primary-500 text-white text-xs font-semibold px-3 py-1 rounded-full">
|
||||
Best Value
|
||||
</span>
|
||||
)}
|
||||
<div className="text-2xl font-bold mb-1">{pkg.credits}</div>
|
||||
<div className="text-sm text-dark-400 mb-2">
|
||||
{pkg.credits === 1 ? 'credit' : 'credits'}
|
||||
</div>
|
||||
<div className="text-xl font-semibold text-primary-400">
|
||||
{formatPrice(pkg.price_cents)}
|
||||
</div>
|
||||
<div className="text-xs text-dark-500">
|
||||
{pricePerCredit(pkg.price_cents, pkg.credits)}/video
|
||||
</div>
|
||||
{pkg.credits > 1 && (
|
||||
<div className="text-xs text-green-400 mt-1">{pkg.description}</div>
|
||||
)}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
|
||||
{/* Checkout Form */}
|
||||
<div className="bg-dark-800 border border-dark-700 rounded-2xl p-8 max-w-md mx-auto">
|
||||
<div className="text-center mb-6">
|
||||
<div className="text-sm text-dark-400 mb-1">Selected package</div>
|
||||
<div className="text-2xl font-bold">
|
||||
{selectedPackage.credits} {selectedPackage.credits === 1 ? 'Credit' : 'Credits'}
|
||||
</div>
|
||||
<div className="text-3xl font-bold text-primary-400">
|
||||
{formatPrice(selectedPackage.price_cents)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<form onSubmit={handleCheckout} className="space-y-4">
|
||||
<div>
|
||||
<label htmlFor="email" className="block text-sm font-medium text-dark-300 mb-2">
|
||||
Email address
|
||||
</label>
|
||||
<div className="relative">
|
||||
<Mail className="absolute left-3 top-1/2 -translate-y-1/2 w-5 h-5 text-dark-500" />
|
||||
<input
|
||||
type="email"
|
||||
id="email"
|
||||
value={email}
|
||||
onChange={(e) => setEmail(e.target.value)}
|
||||
placeholder="you@example.com"
|
||||
className="w-full pl-10 pr-4 py-3 bg-dark-900 border border-dark-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-transparent text-white placeholder-dark-500"
|
||||
required
|
||||
/>
|
||||
</div>
|
||||
<p className="text-xs text-dark-500 mt-2">
|
||||
We'll send your login link to this email
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{error && (
|
||||
<div className="text-red-400 text-sm bg-red-400/10 border border-red-400/20 rounded-lg p-3">
|
||||
{error}
|
||||
</div>
|
||||
)}
|
||||
|
||||
<button
|
||||
type="submit"
|
||||
disabled={isLoading}
|
||||
className="w-full bg-primary-500 hover:bg-primary-600 disabled:bg-primary-500/50 text-white font-semibold py-4 rounded-xl transition-all btn-glow flex items-center justify-center gap-2"
|
||||
>
|
||||
{isLoading ? (
|
||||
<>
|
||||
<Loader2 className="w-5 h-5 animate-spin" />
|
||||
Redirecting to checkout...
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
Continue to Payment
|
||||
<Check className="w-5 h-5" />
|
||||
</>
|
||||
)}
|
||||
</button>
|
||||
</form>
|
||||
|
||||
<div className="mt-4 flex items-center justify-center gap-4 text-xs text-dark-500">
|
||||
<span>Secure checkout</span>
|
||||
<span>powered by Stripe</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{/* FAQ */}
|
||||
<section className="py-16 px-4 bg-dark-800/50">
|
||||
<div className="max-w-2xl mx-auto">
|
||||
<h2 className="text-3xl font-bold text-center mb-12">Questions?</h2>
|
||||
<div className="space-y-4">
|
||||
{faqs.map((faq, i) => (
|
||||
<div
|
||||
key={i}
|
||||
className="bg-dark-800 border border-dark-700 rounded-xl overflow-hidden"
|
||||
>
|
||||
<button
|
||||
onClick={() => setExpandedFaq(expandedFaq === i ? null : i)}
|
||||
className="w-full px-6 py-4 text-left flex items-center justify-between hover:bg-dark-700/50 transition-colors"
|
||||
>
|
||||
<span className="font-medium">{faq.q}</span>
|
||||
<ChevronDown
|
||||
className={`w-5 h-5 text-dark-400 transition-transform ${
|
||||
expandedFaq === i ? 'rotate-180' : ''
|
||||
}`}
|
||||
/>
|
||||
</button>
|
||||
{expandedFaq === i && (
|
||||
<div className="px-6 pb-4 text-dark-400">{faq.a}</div>
|
||||
)}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{/* Footer */}
|
||||
<footer className="py-12 px-4 border-t border-dark-700">
|
||||
<div className="max-w-6xl mx-auto flex flex-col md:flex-row items-center justify-between gap-4">
|
||||
<div className="flex items-center gap-2">
|
||||
<Mic2 className="w-6 h-6 text-primary-500" />
|
||||
<span className="font-semibold">Nomad Karaoke</span>
|
||||
</div>
|
||||
<div className="text-sm text-dark-500">
|
||||
© {new Date().getFullYear()} Nomad Karaoke. All rights reserved.
|
||||
</div>
|
||||
<div className="flex gap-6 text-sm text-dark-400">
|
||||
<a href="mailto:support@nomadkaraoke.com" className="hover:text-white transition-colors">
|
||||
Support
|
||||
</a>
|
||||
<a href="https://nomadkaraoke.com" className="hover:text-white transition-colors">
|
||||
About
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,120 +0,0 @@
|
||||
/**
|
||||
* API client for the Nomad Karaoke backend.
|
||||
*/
|
||||
|
||||
const API_BASE_URL = process.env.NEXT_PUBLIC_API_URL || 'https://api.nomadkaraoke.com';
|
||||
|
||||
export interface CreditPackage {
|
||||
id: string;
|
||||
credits: number;
|
||||
price_cents: number;
|
||||
name: string;
|
||||
description: string;
|
||||
}
|
||||
|
||||
export interface CreditPackagesResponse {
|
||||
packages: CreditPackage[];
|
||||
}
|
||||
|
||||
export interface CheckoutResponse {
|
||||
status: string;
|
||||
checkout_url: string;
|
||||
message: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch available credit packages.
|
||||
*/
|
||||
export async function getCreditPackages(): Promise<CreditPackage[]> {
|
||||
const response = await fetch(`${API_BASE_URL}/api/users/credits/packages`);
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error('Failed to fetch credit packages');
|
||||
}
|
||||
|
||||
const data: CreditPackagesResponse = await response.json();
|
||||
return data.packages;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a Stripe checkout session.
|
||||
*/
|
||||
export async function createCheckout(packageId: string, email: string): Promise<string> {
|
||||
const response = await fetch(`${API_BASE_URL}/api/users/credits/checkout`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify({
|
||||
package_id: packageId,
|
||||
email: email,
|
||||
}),
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
const error = await response.json();
|
||||
throw new Error(error.detail || 'Failed to create checkout session');
|
||||
}
|
||||
|
||||
const data: CheckoutResponse = await response.json();
|
||||
return data.checkout_url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Format price from cents to display string.
|
||||
*/
|
||||
export function formatPrice(cents: number): string {
|
||||
return `$${(cents / 100).toFixed(2)}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate per-credit price.
|
||||
*/
|
||||
export function pricePerCredit(pkg: CreditPackage): number {
|
||||
return pkg.price_cents / pkg.credits;
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// Beta Tester Program
|
||||
// ============================================================================
|
||||
|
||||
export interface BetaEnrollRequest {
|
||||
email: string;
|
||||
promise_text: string;
|
||||
accept_corrections_work: boolean;
|
||||
}
|
||||
|
||||
export interface BetaEnrollResponse {
|
||||
status: string;
|
||||
message: string;
|
||||
credits_granted: number;
|
||||
session_token: string | null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enroll as a beta tester to receive free credits.
|
||||
*/
|
||||
export async function enrollBetaTester(
|
||||
email: string,
|
||||
promiseText: string,
|
||||
acceptCorrectionsWork: boolean
|
||||
): Promise<BetaEnrollResponse> {
|
||||
const response = await fetch(`${API_BASE_URL}/api/users/beta/enroll`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify({
|
||||
email: email,
|
||||
promise_text: promiseText,
|
||||
accept_corrections_work: acceptCorrectionsWork,
|
||||
}),
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
const error = await response.json();
|
||||
throw new Error(error.detail || 'Failed to enroll in beta program');
|
||||
}
|
||||
|
||||
return response.json();
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
/** @type {import('next').NextConfig} */
|
||||
const nextConfig = {
|
||||
output: 'export',
|
||||
trailingSlash: true,
|
||||
images: {
|
||||
unoptimized: true,
|
||||
},
|
||||
// For GitHub Pages deployment
|
||||
basePath: '',
|
||||
assetPrefix: '',
|
||||
};
|
||||
|
||||
export default nextConfig;
|
||||
Generated
-2092
File diff suppressed because it is too large.
Load diff
@@ -1,27 +0,0 @@
|
||||
{
|
||||
"name": "buy-nomadkaraoke",
|
||||
"version": "1.0.0",
|
||||
"private": true,
|
||||
"description": "Landing page and payment flow for Nomad Karaoke",
|
||||
"scripts": {
|
||||
"dev": "next dev",
|
||||
"build": "next build",
|
||||
"start": "next start",
|
||||
"lint": "next lint"
|
||||
},
|
||||
"dependencies": {
|
||||
"next": "^15.0.0",
|
||||
"react": "^19.0.0",
|
||||
"react-dom": "^19.0.0",
|
||||
"lucide-react": "^0.468.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^22.0.0",
|
||||
"@types/react": "^19.0.0",
|
||||
"@types/react-dom": "^19.0.0",
|
||||
"typescript": "^5.0.0",
|
||||
"tailwindcss": "^3.4.0",
|
||||
"postcss": "^8.4.0",
|
||||
"autoprefixer": "^10.4.0"
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
/** @type {import('postcss-load-config').Config} */
|
||||
const config = {
|
||||
plugins: {
|
||||
tailwindcss: {},
|
||||
autoprefixer: {},
|
||||
},
|
||||
};
|
||||
|
||||
export default config;
|
||||
@@ -1,43 +0,0 @@
|
||||
/** @type {import('tailwindcss').Config} */
|
||||
module.exports = {
|
||||
content: [
|
||||
'./app/**/*.{js,ts,jsx,tsx,mdx}',
|
||||
'./components/**/*.{js,ts,jsx,tsx,mdx}',
|
||||
],
|
||||
theme: {
|
||||
extend: {
|
||||
colors: {
|
||||
// Match the existing karaoke-gen dark theme
|
||||
primary: {
|
||||
50: '#eff6ff',
|
||||
100: '#dbeafe',
|
||||
200: '#bfdbfe',
|
||||
300: '#93c5fd',
|
||||
400: '#60a5fa',
|
||||
500: '#3b82f6',
|
||||
600: '#2563eb',
|
||||
700: '#1d4ed8',
|
||||
800: '#1e40af',
|
||||
900: '#1e3a8a',
|
||||
},
|
||||
dark: {
|
||||
50: '#f8fafc',
|
||||
100: '#f1f5f9',
|
||||
200: '#e2e8f0',
|
||||
300: '#cbd5e1',
|
||||
400: '#94a3b8',
|
||||
500: '#64748b',
|
||||
600: '#475569',
|
||||
700: '#334155',
|
||||
800: '#1e293b',
|
||||
900: '#0f172a',
|
||||
950: '#020617',
|
||||
},
|
||||
},
|
||||
fontFamily: {
|
||||
sans: ['Inter', 'system-ui', 'sans-serif'],
|
||||
},
|
||||
},
|
||||
},
|
||||
plugins: [],
|
||||
};
|
||||
@@ -1,26 +0,0 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"lib": ["dom", "dom.iterable", "esnext"],
|
||||
"allowJs": true,
|
||||
"skipLibCheck": true,
|
||||
"strict": true,
|
||||
"noEmit": true,
|
||||
"esModuleInterop": true,
|
||||
"module": "esnext",
|
||||
"moduleResolution": "bundler",
|
||||
"resolveJsonModule": true,
|
||||
"isolatedModules": true,
|
||||
"jsx": "preserve",
|
||||
"incremental": true,
|
||||
"plugins": [
|
||||
{
|
||||
"name": "next"
|
||||
}
|
||||
],
|
||||
"paths": {
|
||||
"@/*": ["./*"]
|
||||
}
|
||||
},
|
||||
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
|
||||
"exclude": ["node_modules"]
|
||||
}
|
||||
@@ -34,6 +34,28 @@ Audio separation and lyrics transcription run in parallel:
|
||||
|
||||
## Common Gotchas
|
||||
|
||||
### Cross-Domain localStorage Isolation
|
||||
|
||||
**Problem**: Auth tokens stored in localStorage on one subdomain are invisible to other subdomains.
|
||||
|
||||
We had `buy.nomadkaraoke.com` for purchases and `gen.nomadkaraoke.com` for the app. Users who purchased credits on `buy.` appeared logged out when redirected to `gen.` because localStorage is domain-isolated.
|
||||
|
||||
**Symptoms**:
|
||||
- User completes purchase, redirected to app, sees "auth required"
|
||||
- Token exists in browser dev tools for one domain but not the other
|
||||
- Works fine in local dev (same localhost origin)
|
||||
|
||||
**Solution**: Keep auth on a single domain. We consolidated `buy-site/` into the main `frontend/`:
|
||||
- Landing/pricing at `/` (root)
|
||||
- Main app at `/app`
|
||||
- Single localStorage for all auth tokens
|
||||
|
||||
**Alternative** (if subdomains required): Use cookies with `domain=.nomadkaraoke.com` instead of localStorage, or implement a token exchange flow.
|
||||
|
||||
**Lesson**: Before splitting functionality across subdomains, verify your auth storage strategy works cross-domain. E2E tests that exercise the full user journey catch this; unit tests don't.
|
||||
|
||||
See `docs/archive/2025-12-29-buy-site-consolidation.md` for full details.
|
||||
|
||||
### Frontend Polling vs Tab Visibility
|
||||
|
||||
**Problem**: After completing review in a new tab (lyrics or instrumental selection), returning to the main frontend showed stale status for up to 10 seconds due to polling interval.
|
||||
|
||||
@@ -0,0 +1,234 @@
|
||||
# Product Vision
|
||||
|
||||
## What is Nomad Karaoke?
|
||||
|
||||
Nomad Karaoke is a karaoke video generation platform that creates professional-quality karaoke videos from any song in under 10 minutes. Founded by Andrew Beveridge and based in South Carolina, it combines state-of-the-art AI for audio separation and lyrics synchronization with human review to produce accurate, polished results.
|
||||
|
||||
**Mission**: Make any song singable by automating the complex, time-consuming process of creating karaoke videos.
|
||||
|
||||
## The Problem
|
||||
|
||||
Creating high-quality karaoke is surprisingly difficult:
|
||||
|
||||
1. **Vocal Removal**: Separating vocals from instrumentals without artifacts requires sophisticated AI models and significant compute power.
|
||||
|
||||
2. **Lyrics Accuracy**: Getting the right lyrics, with correct spelling, formatting, and line breaks, is error-prone when scraping from various sources.
|
||||
|
||||
3. **Timestamp Synchronization**: Aligning each word or syllable to the exact moment in the audio is the hardest part. No existing tool does this reliably for all songs.
|
||||
|
||||
4. **Multiple Formats**: Professional karaoke needs multiple output formats (MP4, MKV, CDG) at various resolutions, with proper encoding.
|
||||
|
||||
5. **Distribution**: Uploading to YouTube with proper metadata, sharing to cloud storage, and notifying users adds complexity.
|
||||
|
||||
Existing solutions either produce poor quality (DIY tools), cost too much time ($50-100/track from manual services), or don't exist at all for many songs.
|
||||
|
||||
## Target Audiences
|
||||
|
||||
### 1. Individual Karaoke Enthusiasts
|
||||
People who want custom karaoke for songs not available in commercial libraries - for home parties, personal practice, or sharing with friends.
|
||||
|
||||
### 2. Professional KJs and Venues
|
||||
Karaoke DJs ("KJs") and bars who need to fulfill on-demand song requests. When a patron asks for a song that isn't in the library, generating it in under 10 minutes means it can be ready within 1-2 performances.
|
||||
|
||||
### 3. Commercial Karaoke Producers (B2B)
|
||||
Companies that produce karaoke tracks at scale for distribution. They have their own instrumentals, branding, and distribution channels - they need automated generation infrastructure that can handle 5,000+ tracks with custom theming.
|
||||
|
||||
## Technical Approach
|
||||
|
||||
The system uses a multi-stage pipeline:
|
||||
|
||||
```
|
||||
Input (audio + metadata)
|
||||
│
|
||||
├──────────────────────────────────────┐
|
||||
│ │
|
||||
v v
|
||||
┌───────────────────┐ ┌───────────────────┐
|
||||
│ Audio Separation │ │ Lyrics Processing │
|
||||
│ (Modal GPU) │ │ (AudioShake API) │
|
||||
│ │ │ │
|
||||
│ • Clean vocal │ │ • Fetch reference │
|
||||
│ removal │ │ lyrics │
|
||||
│ • Backing vocal │ │ • Transcribe with │
|
||||
│ options │ │ timestamps │
|
||||
└─────────┬─────────┘ │ • AI correction │
|
||||
│ │ • HUMAN REVIEW │
|
||||
│ └─────────┬─────────┘
|
||||
│ │
|
||||
└──────────────┬───────────────────┘
|
||||
v
|
||||
┌───────────────────┐
|
||||
│ Video Generation │
|
||||
│ • Title screen │
|
||||
│ • Synced lyrics │
|
||||
│ • End screen │
|
||||
└─────────┬─────────┘
|
||||
│
|
||||
v
|
||||
┌───────────────────┐
|
||||
│ Output & Distro │
|
||||
│ • Multiple formats│
|
||||
│ • YouTube upload │
|
||||
│ • Cloud storage │
|
||||
└───────────────────┘
|
||||
```
|
||||
|
||||
### Why Human Review?
|
||||
|
||||
The hardest unsolved problem in karaoke generation is **reliable lyrics transcription with accurate timestamps**. Current approaches:
|
||||
|
||||
- **Whisper (open source)**: Free, but inconsistent for sung audio. Works well ~60% of the time, poorly the rest.
|
||||
- **AudioShake (paid API)**: Proprietary lyrics transcription model specifically trained for music. Much more accurate/consistent than Whisper.
|
||||
- **Agentic AI Correction**: LLM-based system that compares transcriptions against reference lyrics, fixing errors and improving sync. Costs tokens but catches many issues.
|
||||
|
||||
Even with the best AI, some songs have tricky timing, unusual pronunciations, or ambiguous lyrics. Human review catches these edge cases and ensures quality. The review UI lets users:
|
||||
- Correct misspelled words
|
||||
- Adjust word/line timing
|
||||
- Fix line breaks and formatting
|
||||
- Preview changes in real-time
|
||||
|
||||
## Open Source Philosophy
|
||||
|
||||
All code is open source (MIT license) because:
|
||||
|
||||
1. **Community**: Others can learn from, contribute to, and build upon the work
|
||||
2. **Transparency**: Users can see exactly how their data is processed
|
||||
3. **Self-hosting option**: Technical users can run their own instance
|
||||
|
||||
However, reliable fully-automated generation requires:
|
||||
- **AudioShake API**: ~$0.50-1.00 per track for high-quality transcription
|
||||
- **LLM tokens**: ~$0.50-1.00 for agentic correction workflow
|
||||
- **GPU compute**: ~$0.20-0.50 for audio separation on Modal
|
||||
- **Infrastructure**: Cloud Run, Firestore, GCS, etc.
|
||||
|
||||
**Cost per track: ~$2-3** for fully-automated processing, making a paid service necessary to sustain development.
|
||||
|
||||
The open source CLI (`karaoke-gen`) works with local processing and free APIs for users willing to accept lower reliability and do more manual correction. The hosted service (`gen.nomadkaraoke.com`) provides the premium, reliable experience.
|
||||
|
||||
## Business Model
|
||||
|
||||
### Credit-Based Pricing
|
||||
|
||||
Users purchase credits to generate karaoke videos:
|
||||
|
||||
| Credits | Price | Per Track | Savings |
|
||||
|---------|-------|-----------|---------|
|
||||
| 1 | $5 | $5.00 | - |
|
||||
| 3 | $12 | $4.00 | 20% |
|
||||
| 5 | $18 | $3.50 | 30% |
|
||||
| 10 | $30 | $3.00 | 40% |
|
||||
|
||||
This is significantly cheaper than:
|
||||
- Manual services: $10-50 per track
|
||||
- Hiring a studio: $100+ per track
|
||||
- DIY tools + your time: Hours of frustration
|
||||
|
||||
### Beta Tester Program
|
||||
|
||||
New users can join the beta program to get free credits in exchange for feedback, helping improve the system while building initial user base.
|
||||
|
||||
### B2B / White-Label
|
||||
|
||||
Commercial producers pay for API access or custom integration to generate tracks at scale with their own branding, instrumentals, and distribution.
|
||||
|
||||
## Current State (December 2025)
|
||||
|
||||
### What Works
|
||||
- Audio upload and separation (Modal API)
|
||||
- Lyrics transcription (AudioShake API)
|
||||
- Agentic AI correction (Gemini 3 Flash via Vertex AI)
|
||||
- Human lyrics review (React UI)
|
||||
- Preview video generation
|
||||
- Instrumental selection (clean vs. with backing vocals)
|
||||
- Multi-format encoding (4K, 720p, lossless, lossy)
|
||||
- Token-based authentication
|
||||
- Magic link authentication
|
||||
- Payment flow (Stripe)
|
||||
- Beta tester program
|
||||
- YouTube upload integration
|
||||
- Dropbox/Google Drive distribution
|
||||
|
||||
### Known Limitations
|
||||
- CDG format needs additional style configuration
|
||||
- Very long audio (>10 min) may timeout
|
||||
- Some edge cases in lyrics timing still need manual correction
|
||||
|
||||
## Product Ecosystem
|
||||
|
||||
### Active Products
|
||||
|
||||
1. **gen.nomadkaraoke.com** - Web application for generating karaoke videos (includes landing page, pricing, and payment)
|
||||
2. **karaoke-gen CLI** - Local command-line tool for power users
|
||||
3. **karaoke-gen-remote CLI** - CLI that uses the cloud backend
|
||||
4. **Nomad Karaoke YouTube Channel** - Hosts generated videos for users
|
||||
|
||||
### Future Products
|
||||
|
||||
1. **KaraokeHunt** (revival planned) - Song discovery app that analyzes streaming history to suggest songs you'd enjoy singing. Previously launched as a separate product; will be rebranded and integrated with the karaoke generator.
|
||||
|
||||
2. **New nomadkaraoke.com Homepage** - Replace the legacy static site with a modern landing page showcasing the generator (currently deployed from `nomadkaraoke/public-website` repo).
|
||||
|
||||
## Differentiators
|
||||
|
||||
### vs. DIY Tools (Whisper + Demucs + manual editing)
|
||||
- **Quality**: AudioShake's proprietary model beats open source transcription
|
||||
- **Speed**: 10 minutes vs. hours of manual work
|
||||
- **Convenience**: One-click generation with human review UI
|
||||
|
||||
### vs. Manual Services ($10-50/track)
|
||||
- **Price**: $3-5 per track
|
||||
- **Speed**: Minutes instead of days
|
||||
- **Scale**: Generate as many as you need, when you need them
|
||||
|
||||
### vs. Other Automated Tools
|
||||
- **Accuracy**: Human review catches AI errors
|
||||
- **Output quality**: 4K video, multiple formats, proper encoding
|
||||
- **Distribution**: YouTube upload, cloud storage, notifications built in
|
||||
- **Open source**: Transparency and community contributions
|
||||
|
||||
## Technical Stack
|
||||
|
||||
- **Backend**: FastAPI on Google Cloud Run
|
||||
- **Frontend**: Next.js on Cloudflare Pages
|
||||
- **Database**: Firestore
|
||||
- **Storage**: Google Cloud Storage
|
||||
- **Secrets**: Google Secret Manager
|
||||
- **Audio Separation**: Modal (GPU compute)
|
||||
- **Lyrics Transcription**: AudioShake API
|
||||
- **AI Correction**: Vertex AI (Gemini 3 Flash)
|
||||
- **Payments**: Stripe
|
||||
- **Email**: SendGrid
|
||||
- **IaC**: Pulumi
|
||||
- **CI/CD**: GitHub Actions (self-hosted runner on GCP)
|
||||
|
||||
## Roadmap
|
||||
|
||||
### Near-term
|
||||
- Public launch of gen.nomadkaraoke.com
|
||||
- New marketing homepage at nomadkaraoke.com
|
||||
- B2B API for commercial producer integration
|
||||
- Bulk generation features for high-volume clients
|
||||
|
||||
### Medium-term
|
||||
- KaraokeHunt revival and integration
|
||||
- Mobile-optimized experience
|
||||
- Real-time generation status notifications
|
||||
- Additional output format support
|
||||
|
||||
### Long-term
|
||||
- Karaoke Eternal integration (community request)
|
||||
- On-premises deployment option for venues
|
||||
- Live karaoke event features
|
||||
|
||||
## Links
|
||||
|
||||
- **Web App**: https://gen.nomadkaraoke.com
|
||||
- **API**: https://api.nomadkaraoke.com
|
||||
- **GitHub**: https://github.com/nomadkaraoke/karaoke-gen
|
||||
- **YouTube Channel**: https://www.youtube.com/@nomadkaraoke
|
||||
- **Updates Signup**: https://nomadkaraoke.kit.com/
|
||||
- **Contact**: https://cal.com/beveradb
|
||||
|
||||
## About the Founder
|
||||
|
||||
Andrew Beveridge is a software engineer based in South Carolina who runs a weekly karaoke night and built Nomad Karaoke to solve his own problem: wanting to sing songs that don't exist as karaoke. What started as a personal tool evolved into a platform that can help anyone create professional karaoke for any song.
|
||||
+6
-1
@@ -4,7 +4,9 @@
|
||||
|
||||
## What Works
|
||||
|
||||
- **Web App**: https://gen.nomadkaraoke.com - Upload audio, review lyrics, download videos
|
||||
- **Web App**: https://gen.nomadkaraoke.com
|
||||
- `/` - Landing page with pricing and beta enrollment
|
||||
- `/app` - Main app (upload audio, review lyrics, download videos)
|
||||
- **Backend API**: https://api.nomadkaraoke.com - FastAPI on Cloud Run
|
||||
- **CLI Tools**: `karaoke-gen` (local), `karaoke-gen-remote` (cloud)
|
||||
|
||||
@@ -34,10 +36,13 @@
|
||||
|
||||
| Doc | Purpose |
|
||||
|-----|---------|
|
||||
| [PRODUCT-VISION.md](PRODUCT-VISION.md) | Product goals, audience, business model |
|
||||
| [ARCHITECTURE.md](ARCHITECTURE.md) | System design, data flow, integrations |
|
||||
| [DEVELOPMENT.md](DEVELOPMENT.md) | Local setup, testing, deployment |
|
||||
| [API.md](API.md) | Backend endpoint reference |
|
||||
| [LESSONS-LEARNED.md](LESSONS-LEARNED.md) | Key insights for future agents |
|
||||
| [STRIPE-SETUP.md](STRIPE-SETUP.md) | Payment integration setup |
|
||||
| [MOBILE-UX-BEST-PRACTICES.md](MOBILE-UX-BEST-PRACTICES.md) | Mobile/responsive design guidelines |
|
||||
| [archive/](archive/) | Historical documentation |
|
||||
|
||||
## Workflow Summary
|
||||
|
||||
@@ -60,7 +60,7 @@ STRIPE_WEBHOOK_SECRET=whsec_your_webhook_secret
|
||||
|
||||
# Optional (defaults shown)
|
||||
FRONTEND_URL=https://gen.nomadkaraoke.com
|
||||
BUY_URL=https://buy.nomadkaraoke.com
|
||||
# BUY_URL defaults to FRONTEND_URL after site consolidation
|
||||
```
|
||||
|
||||
### For Cloud Run deployment:
|
||||
@@ -80,7 +80,7 @@ echo -n "SG.your_sendgrid_api_key" | gcloud secrets versions add sendgrid-api-ke
|
||||
```
|
||||
|
||||
4. The environment variables are configured in the Cloud Run deployment. Defaults:
|
||||
- `EMAIL_FROM=noreply@nomadkaraoke.com`
|
||||
- `EMAIL_FROM=gen@nomadkaraoke.com`
|
||||
- `EMAIL_FROM_NAME=Nomad Karaoke`
|
||||
|
||||
## 6. Test the Integration
|
||||
|
||||
@@ -0,0 +1,250 @@
|
||||
# Buy Site Architecture Analysis
|
||||
|
||||
**Date**: 2025-12-29
|
||||
**Status**: Analysis Complete - Consolidation Recommended
|
||||
|
||||
## Executive Summary
|
||||
|
||||
The current two-site architecture (buy.nomadkaraoke.com + gen.nomadkaraoke.com) has fundamental issues that break the user authentication flow. **Strong recommendation: Consolidate into a single site** to simplify the architecture, fix auth issues, and improve user experience.
|
||||
|
||||
## Critical Bugs Found
|
||||
|
||||
### 1. Token Storage Key Mismatch
|
||||
|
||||
**Location**: `buy-site/app/page.tsx:95` vs `frontend/lib/api.ts:18`
|
||||
|
||||
```javascript
|
||||
// buy-site stores token as:
|
||||
localStorage.setItem('nomad_karaoke_token', response.session_token);
|
||||
|
||||
// frontend reads token as:
|
||||
localStorage.getItem('karaoke_access_token');
|
||||
```
|
||||
|
||||
Even if the user stays on the same domain, this key mismatch means tokens wouldn't transfer.
|
||||
|
||||
### 2. Cross-Domain localStorage Isolation
|
||||
|
||||
**The fundamental problem**: localStorage is domain-specific. Data stored on `buy.nomadkaraoke.com` is completely inaccessible from `gen.nomadkaraoke.com`.
|
||||
|
||||
This means:
|
||||
- Beta tester enrollment stores a session token on buy.nomadkaraoke.com
|
||||
- Redirect to gen.nomadkaraoke.com loses the token
|
||||
- User appears unauthenticated on the main app
|
||||
|
||||
### 3. Broken Beta Tester Flow
|
||||
|
||||
**Expected user experience**:
|
||||
1. User fills beta form on buy site
|
||||
2. Gets session token
|
||||
3. Redirects to gen site
|
||||
4. Is authenticated and can create karaoke
|
||||
|
||||
**Actual experience**:
|
||||
1. User fills beta form on buy site
|
||||
2. Token stored in buy site's localStorage
|
||||
3. Redirects to gen site (different domain!)
|
||||
4. Token is NOT accessible
|
||||
5. User sees "Authentication Required" message
|
||||
6. User is confused
|
||||
|
||||
## Architecture Comparison
|
||||
|
||||
### Current: Two Sites
|
||||
|
||||
```
|
||||
buy.nomadkaraoke.com (Cloudflare Pages) gen.nomadkaraoke.com (GitHub Pages)
|
||||
├── Landing page ├── Main app
|
||||
├── Pricing ├── Job creation
|
||||
├── Beta enrollment ├── Job management
|
||||
├── Stripe checkout redirect ├── Auth dialog
|
||||
└── localStorage: nomad_karaoke_token └── localStorage: karaoke_access_token
|
||||
↓ ↑
|
||||
└───── REDIRECT (token lost!) ──────────────┘
|
||||
```
|
||||
|
||||
**Problems**:
|
||||
- Cross-domain auth doesn't work with localStorage
|
||||
- Two separate codebases to maintain
|
||||
- Two separate deployments (Cloudflare + GitHub Pages)
|
||||
- Duplicate dependencies (React, Next.js, Tailwind on both)
|
||||
- Confusing user navigation between sites
|
||||
- "Already have credits? Sign in" link goes to unauthenticated state
|
||||
|
||||
### Proposed: Single Site
|
||||
|
||||
```
|
||||
gen.nomadkaraoke.com (GitHub Pages)
|
||||
├── Landing page (new /welcome or / route)
|
||||
├── Pricing (/pricing or landing page section)
|
||||
├── Beta enrollment (modal or dedicated route)
|
||||
├── Stripe checkout redirect
|
||||
├── Main app (/app or /)
|
||||
├── Job creation
|
||||
├── Job management
|
||||
└── localStorage: karaoke_access_token (single key)
|
||||
```
|
||||
|
||||
**Benefits**:
|
||||
- Single domain = single localStorage = no auth issues
|
||||
- One codebase to maintain
|
||||
- One deployment pipeline
|
||||
- Shared components and styles
|
||||
- Clear user navigation
|
||||
- Consistent branding/experience
|
||||
|
||||
## Migration Path
|
||||
|
||||
### Phase 1: Integrate Landing/Pricing into Main Frontend
|
||||
|
||||
1. Create new routes in `frontend/`:
|
||||
- `/welcome` - Landing page (can be set as default for unauthenticated users)
|
||||
- `/pricing` - Pricing section (or integrate into landing)
|
||||
|
||||
2. Move buy-site components to frontend:
|
||||
- Copy pricing UI from `buy-site/app/page.tsx`
|
||||
- Copy beta enrollment form
|
||||
- Reuse existing auth components
|
||||
|
||||
3. Update frontend routing:
|
||||
- Unauthenticated users → Landing page
|
||||
- Authenticated users → Main app
|
||||
|
||||
### Phase 2: Update Auth Flow
|
||||
|
||||
1. Fix token key to be consistent:
|
||||
```javascript
|
||||
localStorage.setItem('karaoke_access_token', token);
|
||||
```
|
||||
|
||||
2. Beta enrollment flow:
|
||||
- Show form on gen.nomadkaraoke.com directly
|
||||
- On success, store token and redirect to app (same domain)
|
||||
- User is immediately authenticated
|
||||
|
||||
### Phase 3: Cleanup
|
||||
|
||||
1. Delete buy-site directory
|
||||
2. Remove Cloudflare Pages deployment
|
||||
3. Delete buy.nomadkaraoke.com DNS record (or redirect to gen)
|
||||
4. Update CI/CD to remove buy-site jobs
|
||||
|
||||
## Files to Delete
|
||||
|
||||
```
|
||||
buy-site/ # Entire directory
|
||||
├── app/
|
||||
│ ├── globals.css
|
||||
│ ├── layout.tsx
|
||||
│ └── page.tsx
|
||||
├── lib/
|
||||
│ └── api.ts
|
||||
├── next.config.mjs
|
||||
├── package.json
|
||||
├── package-lock.json
|
||||
├── postcss.config.mjs
|
||||
├── tailwind.config.js
|
||||
└── tsconfig.json
|
||||
```
|
||||
|
||||
## CI/CD Changes
|
||||
|
||||
In `.github/workflows/ci.yml`:
|
||||
- Remove `buy_site` from path filters
|
||||
- Remove `deploy-buy-site` job
|
||||
|
||||
## DNS/Infrastructure Changes
|
||||
|
||||
- Remove or redirect `buy.nomadkaraoke.com` → `gen.nomadkaraoke.com`
|
||||
- Delete Cloudflare Pages project `nomadkaraoke-buy`
|
||||
|
||||
## Alternative Solutions (Not Recommended)
|
||||
|
||||
### Option A: Shared Auth via URL Token
|
||||
|
||||
Pass token in URL when redirecting:
|
||||
```
|
||||
https://gen.nomadkaraoke.com?token=xxx
|
||||
```
|
||||
|
||||
**Problems**:
|
||||
- Token in URL is a security risk (logs, referrer headers)
|
||||
- Requires frontend to parse and clear URL
|
||||
- Still two codebases to maintain
|
||||
|
||||
### Option B: Cookie with Shared Domain
|
||||
|
||||
Use cookies with `domain=.nomadkaraoke.com`:
|
||||
```javascript
|
||||
document.cookie = `session=${token}; domain=.nomadkaraoke.com; secure; samesite=strict`;
|
||||
```
|
||||
|
||||
**Problems**:
|
||||
- Still two codebases to maintain
|
||||
- Cookie handling adds complexity
|
||||
- CORS issues with API calls
|
||||
|
||||
### Option C: Subdomain with Shared localStorage
|
||||
|
||||
If both sites were on same origin (e.g., `gen.nomadkaraoke.com/buy`), localStorage would be shared.
|
||||
|
||||
**This is essentially the consolidation approach** - just with a different URL structure.
|
||||
|
||||
## Testing the Fix
|
||||
|
||||
Created Playwright e2e test: `frontend/e2e/production-user-journey.spec.ts`
|
||||
|
||||
Key test scenarios:
|
||||
1. Landing page loads correctly
|
||||
2. Beta enrollment validation works
|
||||
3. Token storage is consistent
|
||||
4. Auth persists after redirect
|
||||
5. Cross-domain issues documented (will fail until fixed)
|
||||
|
||||
Run tests:
|
||||
```bash
|
||||
cd frontend
|
||||
npx playwright test production-user-journey --config=playwright.production.config.ts --headed
|
||||
```
|
||||
|
||||
## Email Testing for E2E
|
||||
|
||||
For full end-to-end magic link testing, options evaluated:
|
||||
|
||||
1. **MailSlurp** - Free tier (50 emails/month), good API
|
||||
- Set `MAILSLURP_API_KEY` env var
|
||||
- Creates temporary inbox
|
||||
- Waits for magic link email
|
||||
- Extracts and follows link
|
||||
|
||||
2. **Mailosaur** - Paid, very reliable
|
||||
|
||||
3. **Gmail API** - Works with user's personal Gmail
|
||||
|
||||
For now, tests document the flows but skip actual email verification unless `MAILSLURP_API_KEY` is set.
|
||||
|
||||
## Recommendation
|
||||
|
||||
**Strongly recommend consolidating to a single site** because:
|
||||
|
||||
1. **Fixes fundamental auth bug** - localStorage sharing isn't possible cross-domain
|
||||
2. **Simpler architecture** - One codebase, one deployment
|
||||
3. **Better UX** - No confusing navigation between sites
|
||||
4. **Easier maintenance** - Single set of dependencies
|
||||
5. **Consistent branding** - Same styles/components everywhere
|
||||
6. **Aligns with PRODUCT-VISION.md** - Single gen.nomadkaraoke.com as the product
|
||||
|
||||
## References
|
||||
|
||||
- Product Vision: `docs/PRODUCT-VISION.md`
|
||||
- Frontend auth: `frontend/lib/auth.ts`
|
||||
- Frontend API: `frontend/lib/api.ts`
|
||||
- Buy site page: `buy-site/app/page.tsx`
|
||||
- E2E tests: `frontend/e2e/production-user-journey.spec.ts`
|
||||
|
||||
## Sources
|
||||
|
||||
Research on email testing:
|
||||
- [Mailosaur Playwright guide](https://mailosaur.com/blog/playwright-email-verification)
|
||||
- [MailSlurp Next Auth testing](https://www.mailslurp.com/guides/test-next-auth-magic-links/)
|
||||
- [Better Stack signup testing guide](https://betterstack.com/community/guides/testing/playwright-signup-login/)
|
||||
@@ -0,0 +1,70 @@
|
||||
# Buy-Site Consolidation into Main Frontend
|
||||
|
||||
**Date**: 2025-12-29
|
||||
**PR**: #122
|
||||
**Branch**: `consolidate-buy-site`
|
||||
|
||||
## Summary
|
||||
|
||||
Consolidated the separate `buy-site/` Next.js application into the main `frontend/` application. This eliminates cross-domain issues and simplifies deployment.
|
||||
|
||||
## Problem
|
||||
|
||||
The original architecture had two separate frontends:
|
||||
- `gen.nomadkaraoke.com` - Main karaoke generation app
|
||||
- `buy.nomadkaraoke.com` - Credit purchase and beta enrollment
|
||||
|
||||
This caused a critical bug: **localStorage is domain-isolated**. Auth tokens stored on `buy.nomadkaraoke.com` were invisible to `gen.nomadkaraoke.com`, so users who purchased credits appeared logged out when redirected to the main app.
|
||||
|
||||
## Solution
|
||||
|
||||
Merged all buy-site functionality into the main frontend:
|
||||
- Landing page with pricing, beta enrollment at `/` (root)
|
||||
- Main app (job submission, job list) at `/app`
|
||||
- Payment success page at `/payment/success`
|
||||
|
||||
## Key Changes
|
||||
|
||||
### Route Structure
|
||||
| Before | After |
|
||||
|--------|-------|
|
||||
| `gen.nomadkaraoke.com/` | Main app (auth required) |
|
||||
| `buy.nomadkaraoke.com/` | Landing/pricing |
|
||||
|
||||
| After | Route |
|
||||
|-------|-------|
|
||||
| Landing/pricing | `/` (root) |
|
||||
| Main app | `/app` |
|
||||
| Auth verify | `/auth/verify` |
|
||||
| Payment success | `/payment/success` |
|
||||
|
||||
### Auth Flow
|
||||
- Unauthenticated users see landing page at root
|
||||
- Authenticated users are redirected to `/app`
|
||||
- Magic link verification redirects to `/app`
|
||||
- Payment success redirects to `/app`
|
||||
|
||||
### Files Changed
|
||||
- Created `frontend/app/app/page.tsx` (main app moved from root)
|
||||
- Updated `frontend/app/page.tsx` (landing page from buy-site)
|
||||
- Deleted `frontend/app/welcome/` (no longer needed)
|
||||
- Updated redirect paths in auth/payment pages
|
||||
- Updated E2E tests for new URL structure
|
||||
|
||||
### Deleted
|
||||
- Entire `buy-site/` directory (merged into frontend)
|
||||
- `buy.nomadkaraoke.com` DNS CNAME
|
||||
|
||||
## Lessons Learned
|
||||
|
||||
1. **Cross-domain localStorage isolation** is a common gotcha when splitting apps across subdomains. Unless you need true multi-tenant isolation, keep auth on a single domain.
|
||||
|
||||
2. **Token storage key consistency** matters - we also fixed a mismatch where buy-site stored tokens as `access_token` but frontend expected `auth_token`.
|
||||
|
||||
3. **E2E tests caught the real user journey bug** that unit tests missed - the redirect after payment led to an "auth required" state.
|
||||
|
||||
## Testing
|
||||
|
||||
- Updated `frontend/e2e/production-user-journey.spec.ts` for new URLs
|
||||
- Added MailSlurp integration for email verification testing
|
||||
- All E2E tests pass with new route structure
|
||||
@@ -0,0 +1,250 @@
|
||||
"use client"
|
||||
|
||||
import { useState, useEffect, useCallback } from "react"
|
||||
import { useRouter } from "next/navigation"
|
||||
import { api, Job, getAccessToken } from "@/lib/api"
|
||||
import { useAutoMode, getAutoModeFromUrl } from "@/lib/auto-mode"
|
||||
import { useJobNotifications, useVisibilityRefresh } from "@/hooks/use-notifications"
|
||||
import { Button } from "@/components/ui/button"
|
||||
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"
|
||||
import { Music2, RefreshCw, Loader2, Zap, ZapOff, Moon, Sun } from "lucide-react"
|
||||
import { JobCard } from "@/components/job"
|
||||
import { JobSubmission } from "@/components/job/JobSubmission"
|
||||
import { AuthStatus } from "@/components/auth"
|
||||
import { AutoProcessor } from "@/components/AutoProcessor"
|
||||
import { VersionFooter } from "@/components/version-footer"
|
||||
import { useTheme } from "@/lib/theme"
|
||||
import {
|
||||
Tooltip,
|
||||
TooltipContent,
|
||||
TooltipProvider,
|
||||
TooltipTrigger,
|
||||
} from "@/components/ui/tooltip"
|
||||
|
||||
export default function AppPage() {
|
||||
const router = useRouter()
|
||||
const [jobs, setJobs] = useState<Job[]>([])
|
||||
const [isLoadingJobs, setIsLoadingJobs] = useState(true)
|
||||
const [isAuthenticated, setIsAuthenticated] = useState<boolean | null>(null)
|
||||
const { enabled: autoModeEnabled, setEnabled: setAutoMode, toggle: toggleAutoMode } = useAutoMode()
|
||||
const { isDarkMode, toggleTheme, mounted } = useTheme()
|
||||
|
||||
// Memoize loadJobs for use with visibility refresh
|
||||
const loadJobs = useCallback(async () => {
|
||||
if (!getAccessToken()) {
|
||||
setIsLoadingJobs(false)
|
||||
return
|
||||
}
|
||||
try {
|
||||
const data = await api.listJobs({ limit: 20 })
|
||||
setJobs(data)
|
||||
} catch (err: any) {
|
||||
// Don't log auth errors - user just needs to authenticate
|
||||
if (err?.status !== 401) {
|
||||
console.error("Failed to load jobs:", err)
|
||||
}
|
||||
} finally {
|
||||
setIsLoadingJobs(false)
|
||||
}
|
||||
}, [])
|
||||
|
||||
// Enable notifications for job status changes (sound + title animation)
|
||||
useJobNotifications(jobs)
|
||||
|
||||
// Refresh jobs immediately when tab becomes visible (after returning from review UIs)
|
||||
useVisibilityRefresh(loadJobs, isAuthenticated === true)
|
||||
|
||||
// Check auth status on mount and redirect if not authenticated
|
||||
useEffect(() => {
|
||||
const token = getAccessToken()
|
||||
if (!token) {
|
||||
// Redirect to landing page if not authenticated
|
||||
router.replace('/')
|
||||
return
|
||||
}
|
||||
setIsAuthenticated(true)
|
||||
}, [router])
|
||||
|
||||
// Initialize auto-mode from URL parameter on mount
|
||||
useEffect(() => {
|
||||
const urlAutoMode = getAutoModeFromUrl()
|
||||
if (urlAutoMode) {
|
||||
setAutoMode(true)
|
||||
}
|
||||
}, [setAutoMode])
|
||||
|
||||
// Load jobs on mount (only if authenticated)
|
||||
useEffect(() => {
|
||||
if (isAuthenticated !== true) {
|
||||
setIsLoadingJobs(false)
|
||||
return
|
||||
}
|
||||
loadJobs()
|
||||
// Poll for updates every 10 seconds
|
||||
const interval = setInterval(loadJobs, 10000)
|
||||
return () => clearInterval(interval)
|
||||
}, [isAuthenticated, loadJobs])
|
||||
|
||||
// Show nothing while checking auth (prevents flash)
|
||||
if (isAuthenticated === null) {
|
||||
return (
|
||||
<div className="min-h-screen flex items-center justify-center" style={{ background: 'var(--bg)' }}>
|
||||
<Loader2 className="w-8 h-8 animate-spin" style={{ color: 'var(--text-muted)' }} />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="min-h-screen" style={{ background: 'var(--bg)' }}>
|
||||
{/* AutoProcessor - handles non-interactive mode */}
|
||||
<AutoProcessor jobs={jobs} onJobsChanged={loadJobs} />
|
||||
|
||||
{/* Header */}
|
||||
<header className="border-b backdrop-blur-sm sticky top-0 z-10" style={{ borderColor: 'var(--card-border)', backgroundColor: 'var(--card)' }}>
|
||||
<div className="px-3 sm:px-4 py-2 sm:py-3 flex items-center justify-between gap-2">
|
||||
<div className="flex items-center gap-2 sm:gap-3 min-w-0">
|
||||
<img src="/nomad-karaoke-logo.svg" alt="Nomad Karaoke" className="h-8 sm:h-10 shrink-0" />
|
||||
<div className="min-w-0">
|
||||
<h1 className="text-base sm:text-xl font-bold truncate" style={{ color: 'var(--text)' }}>Karaoke Generator</h1>
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex items-center gap-1 sm:gap-2 shrink-0">
|
||||
<TooltipProvider>
|
||||
<Tooltip>
|
||||
<TooltipTrigger asChild>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
onClick={toggleAutoMode}
|
||||
className={`min-h-[40px] px-2 sm:px-3 ${autoModeEnabled ? "text-amber-400 hover:text-amber-300 bg-amber-500/10" : ""}`}
|
||||
style={!autoModeEnabled ? { color: 'var(--text-muted)' } : undefined}
|
||||
>
|
||||
{autoModeEnabled ? (
|
||||
<Zap className="w-4 h-4 sm:mr-2" />
|
||||
) : (
|
||||
<ZapOff className="w-4 h-4 sm:mr-2" />
|
||||
)}
|
||||
<span className="hidden sm:inline">Auto</span>
|
||||
</Button>
|
||||
</TooltipTrigger>
|
||||
<TooltipContent side="bottom" className="max-w-xs">
|
||||
<p className="font-medium">
|
||||
{autoModeEnabled ? "Auto Mode Enabled" : "Auto Mode Disabled"}
|
||||
</p>
|
||||
<p className="text-xs mt-1" style={{ color: 'var(--text-muted)' }}>
|
||||
{autoModeEnabled
|
||||
? "Jobs will auto-complete review and select clean instrumental (like -y flag)"
|
||||
: "Click to enable non-interactive mode"}
|
||||
</p>
|
||||
</TooltipContent>
|
||||
</Tooltip>
|
||||
</TooltipProvider>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
onClick={loadJobs}
|
||||
disabled={isLoadingJobs || !isAuthenticated}
|
||||
className="min-h-[40px] px-2 sm:px-3"
|
||||
style={{ color: 'var(--text-muted)' }}
|
||||
>
|
||||
<RefreshCw className={`w-4 h-4 sm:mr-2 ${isLoadingJobs ? 'animate-spin' : ''}`} />
|
||||
<span className="hidden sm:inline">Refresh</span>
|
||||
</Button>
|
||||
<AuthStatus />
|
||||
{mounted && (
|
||||
<TooltipProvider>
|
||||
<Tooltip>
|
||||
<TooltipTrigger asChild>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
onClick={toggleTheme}
|
||||
className="min-h-[40px] px-2 sm:px-3"
|
||||
style={{ color: 'var(--text-muted)' }}
|
||||
>
|
||||
{isDarkMode ? (
|
||||
<Sun className="w-4 h-4" />
|
||||
) : (
|
||||
<Moon className="w-4 h-4" />
|
||||
)}
|
||||
</Button>
|
||||
</TooltipTrigger>
|
||||
<TooltipContent side="bottom">
|
||||
<p>{isDarkMode ? "Switch to light mode" : "Switch to dark mode"}</p>
|
||||
</TooltipContent>
|
||||
</Tooltip>
|
||||
</TooltipProvider>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<main className="px-4 py-8 space-y-6">
|
||||
{/* Auto Mode Banner */}
|
||||
{autoModeEnabled && (
|
||||
<div className="bg-amber-500/10 border border-amber-500/30 rounded-lg p-4 flex items-center gap-3">
|
||||
<Zap className="w-5 h-5 text-amber-400 flex-shrink-0" />
|
||||
<div className="flex-1">
|
||||
<p className="text-sm text-amber-200 font-medium">Non-Interactive Mode Active</p>
|
||||
<p className="text-xs text-amber-200/70 mt-0.5">
|
||||
Jobs will automatically accept lyrics and select clean instrumental (equivalent to -y flag)
|
||||
</p>
|
||||
</div>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
onClick={toggleAutoMode}
|
||||
className="text-amber-200 hover:text-amber-100 hover:bg-amber-500/20"
|
||||
>
|
||||
Disable
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className="grid lg:grid-cols-2 gap-8">
|
||||
{/* Submit Job Card */}
|
||||
<Card className="backdrop-blur" style={{ borderColor: 'var(--card-border)', backgroundColor: 'var(--card)' }}>
|
||||
<CardHeader>
|
||||
<CardTitle style={{ color: 'var(--text)' }}>Create Karaoke Video</CardTitle>
|
||||
<CardDescription style={{ color: 'var(--text-muted)' }}>
|
||||
Upload an audio file, provide a YouTube URL, or search for audio by artist & title
|
||||
</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<JobSubmission onJobCreated={loadJobs} />
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
{/* Jobs List Card */}
|
||||
<Card className="backdrop-blur" style={{ borderColor: 'var(--card-border)', backgroundColor: 'var(--card)' }}>
|
||||
<CardHeader>
|
||||
<CardTitle className="flex items-center justify-between" style={{ color: 'var(--text)' }}>
|
||||
Recent Jobs
|
||||
{isLoadingJobs && <Loader2 className="w-4 h-4 animate-spin" style={{ color: 'var(--text-muted)' }} />}
|
||||
</CardTitle>
|
||||
<CardDescription style={{ color: 'var(--text-muted)' }}>
|
||||
{jobs.length} job{jobs.length !== 1 ? 's' : ''} found
|
||||
</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
{jobs.length === 0 ? (
|
||||
<div className="text-center py-8" style={{ color: 'var(--text-muted)' }}>
|
||||
<Music2 className="w-12 h-12 mx-auto mb-3 opacity-50" />
|
||||
<p>No jobs yet. Create one to get started!</p>
|
||||
</div>
|
||||
) : (
|
||||
<div className="space-y-3 max-h-[500px] overflow-y-auto pr-2">
|
||||
{jobs.map((job) => (
|
||||
<JobCard key={job.job_id} job={job} onRefresh={loadJobs} />
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<VersionFooter />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -37,7 +37,7 @@ function VerifyMagicLinkContent() {
|
||||
setState("success")
|
||||
// Redirect to main app after short delay
|
||||
setTimeout(() => {
|
||||
router.push("/")
|
||||
router.push("/app")
|
||||
}, 2000)
|
||||
} else {
|
||||
setState("error")
|
||||
@@ -90,7 +90,7 @@ function VerifyMagicLinkContent() {
|
||||
</p>
|
||||
<div className="space-y-2">
|
||||
<Button
|
||||
onClick={() => router.push("/")}
|
||||
onClick={() => router.push("/app")}
|
||||
className="w-full bg-blue-600 hover:bg-blue-500"
|
||||
>
|
||||
Go to App
|
||||
|
||||
@@ -96,3 +96,57 @@
|
||||
@apply bg-background text-foreground;
|
||||
}
|
||||
}
|
||||
|
||||
/* Landing page utilities */
|
||||
@layer utilities {
|
||||
/* Glow effect for primary buttons */
|
||||
.btn-glow {
|
||||
box-shadow: 0 0 20px rgba(59, 130, 246, 0.5);
|
||||
}
|
||||
.btn-glow:hover {
|
||||
box-shadow: 0 0 30px rgba(59, 130, 246, 0.7);
|
||||
}
|
||||
|
||||
/* Gradient text */
|
||||
.gradient-text {
|
||||
background: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 50%, #ec4899 100%);
|
||||
-webkit-background-clip: text;
|
||||
-webkit-text-fill-color: transparent;
|
||||
background-clip: text;
|
||||
}
|
||||
|
||||
/* Card hover effect */
|
||||
.card-hover {
|
||||
transition: transform 0.2s ease, box-shadow 0.2s ease;
|
||||
}
|
||||
.card-hover:hover {
|
||||
transform: translateY(-4px);
|
||||
box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
|
||||
}
|
||||
|
||||
/* Animated background gradient */
|
||||
@keyframes gradient-shift {
|
||||
0% { background-position: 0% 50%; }
|
||||
50% { background-position: 100% 50%; }
|
||||
100% { background-position: 0% 50%; }
|
||||
}
|
||||
.animated-gradient {
|
||||
background: linear-gradient(-45deg, #0f172a, #1e293b, #1e3a8a, #312e81);
|
||||
background-size: 400% 400%;
|
||||
animation: gradient-shift 15s ease infinite;
|
||||
}
|
||||
|
||||
/* Dark theme color utilities for landing page */
|
||||
.text-dark-300 { color: #d1d5db; }
|
||||
.text-dark-400 { color: #9ca3af; }
|
||||
.text-dark-500 { color: #6b7280; }
|
||||
.bg-dark-700 { background-color: #374151; }
|
||||
.bg-dark-800 { background-color: #1f2937; }
|
||||
.bg-dark-900 { background-color: #111827; }
|
||||
.border-dark-600 { border-color: #4b5563; }
|
||||
.border-dark-700 { border-color: #374151; }
|
||||
.text-primary-400 { color: #60a5fa; }
|
||||
.text-primary-500 { color: #3b82f6; }
|
||||
.bg-primary-500 { background-color: #3b82f6; }
|
||||
.hover\:bg-primary-600:hover { background-color: #2563eb; }
|
||||
}
|
||||
+534
-220
@@ -1,244 +1,558 @@
|
||||
"use client"
|
||||
'use client';
|
||||
|
||||
import { useState, useEffect, useCallback } from "react"
|
||||
import { api, Job, getAccessToken } from "@/lib/api"
|
||||
import { useAutoMode, getAutoModeFromUrl } from "@/lib/auto-mode"
|
||||
import { useJobNotifications, useVisibilityRefresh } from "@/hooks/use-notifications"
|
||||
import { Button } from "@/components/ui/button"
|
||||
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"
|
||||
import { Music2, RefreshCw, Loader2, Zap, ZapOff, KeyRound, Moon, Sun } from "lucide-react"
|
||||
import { JobCard } from "@/components/job"
|
||||
import { JobSubmission } from "@/components/job/JobSubmission"
|
||||
import { AuthStatus } from "@/components/auth"
|
||||
import { AutoProcessor } from "@/components/AutoProcessor"
|
||||
import { VersionFooter } from "@/components/version-footer"
|
||||
import { useTheme } from "@/lib/theme"
|
||||
import { useState, useEffect, useRef } from 'react';
|
||||
import { useRouter } from 'next/navigation';
|
||||
import {
|
||||
Tooltip,
|
||||
TooltipContent,
|
||||
TooltipProvider,
|
||||
TooltipTrigger,
|
||||
} from "@/components/ui/tooltip"
|
||||
MicVocal,
|
||||
Music,
|
||||
Sparkles,
|
||||
Video,
|
||||
Youtube,
|
||||
ChevronDown,
|
||||
Check,
|
||||
Gift,
|
||||
MessageSquare,
|
||||
Mail,
|
||||
Loader2,
|
||||
} from 'lucide-react';
|
||||
import { api, setAccessToken, getAccessToken, CreditPackage, BetaEnrollResponse } from '@/lib/api';
|
||||
import { AuthDialog } from '@/components/auth/AuthDialog';
|
||||
|
||||
export default function HomePage() {
|
||||
const [jobs, setJobs] = useState<Job[]>([])
|
||||
const [isLoadingJobs, setIsLoadingJobs] = useState(true)
|
||||
const [isAuthenticated, setIsAuthenticated] = useState(false)
|
||||
const { enabled: autoModeEnabled, setEnabled: setAutoMode, toggle: toggleAutoMode } = useAutoMode()
|
||||
const { isDarkMode, toggleTheme, mounted } = useTheme()
|
||||
// FAQ data
|
||||
const faqs = [
|
||||
{
|
||||
question: 'How does it work?',
|
||||
answer:
|
||||
'Enter the artist and song title, and our AI finds the audio, removes the vocals, transcribes and syncs the lyrics, then generates a professional karaoke video. You can review and edit the lyrics before final export.',
|
||||
},
|
||||
{
|
||||
question: 'What songs can I use?',
|
||||
answer:
|
||||
'Any song! Our system searches multiple audio sources to find high-quality versions. If a song exists online, we can likely create a karaoke video for it.',
|
||||
},
|
||||
{
|
||||
question: 'What format is the output?',
|
||||
answer:
|
||||
'You get a 4K MP4 video file with perfectly synced lyrics. We also offer direct YouTube upload and cloud storage integration.',
|
||||
},
|
||||
{
|
||||
question: 'What if something goes wrong?',
|
||||
answer:
|
||||
"If the AI makes mistakes, you can edit the lyrics and timing before generating the final video. If there's a technical issue, contact us and we'll make it right.",
|
||||
},
|
||||
{
|
||||
question: 'Do credits expire?',
|
||||
answer:
|
||||
'No! Your credits never expire. Use them whenever you want.',
|
||||
},
|
||||
];
|
||||
|
||||
// Memoize loadJobs for use with visibility refresh
|
||||
const loadJobs = useCallback(async () => {
|
||||
if (!getAccessToken()) {
|
||||
setIsLoadingJobs(false)
|
||||
return
|
||||
}
|
||||
try {
|
||||
const data = await api.listJobs({ limit: 20 })
|
||||
setJobs(data)
|
||||
} catch (err: any) {
|
||||
// Don't log auth errors - user just needs to authenticate
|
||||
if (err?.status !== 401) {
|
||||
console.error("Failed to load jobs:", err)
|
||||
export default function LandingPage() {
|
||||
const router = useRouter();
|
||||
const [isCheckingAuth, setIsCheckingAuth] = useState(true);
|
||||
const [packages, setPackages] = useState<CreditPackage[]>([]);
|
||||
const [packagesLoading, setPackagesLoading] = useState(true);
|
||||
const [packagesError, setPackagesError] = useState<string | null>(null);
|
||||
const [selectedPackage, setSelectedPackage] = useState<CreditPackage | null>(null);
|
||||
const [email, setEmail] = useState('');
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
|
||||
// Beta form state
|
||||
const [showBetaForm, setShowBetaForm] = useState(false);
|
||||
const [betaEmail, setBetaEmail] = useState('');
|
||||
const [betaPromise, setBetaPromise] = useState('');
|
||||
const [betaAccept, setBetaAccept] = useState(false);
|
||||
const [betaLoading, setBetaLoading] = useState(false);
|
||||
const [betaError, setBetaError] = useState<string | null>(null);
|
||||
const [betaSuccess, setBetaSuccess] = useState(false);
|
||||
const [betaWillRedirect, setBetaWillRedirect] = useState(false);
|
||||
|
||||
// FAQ expansion state
|
||||
const [expandedFaq, setExpandedFaq] = useState<number | null>(null);
|
||||
|
||||
// Auth dialog state
|
||||
const [showAuthDialog, setShowAuthDialog] = useState(false);
|
||||
|
||||
// Ref for redirect timeout cleanup
|
||||
const redirectTimeoutRef = useRef<NodeJS.Timeout | null>(null);
|
||||
|
||||
// Cleanup timeout on unmount
|
||||
useEffect(() => {
|
||||
return () => {
|
||||
if (redirectTimeoutRef.current) {
|
||||
clearTimeout(redirectTimeoutRef.current);
|
||||
}
|
||||
};
|
||||
}, []);
|
||||
|
||||
// Check if already logged in and redirect to app
|
||||
useEffect(() => {
|
||||
const token = getAccessToken();
|
||||
if (token) {
|
||||
router.replace('/app');
|
||||
return;
|
||||
}
|
||||
setIsCheckingAuth(false);
|
||||
}, [router]);
|
||||
|
||||
// Handle successful auth from dialog
|
||||
const handleAuthSuccess = () => {
|
||||
setShowAuthDialog(false);
|
||||
router.push('/app');
|
||||
};
|
||||
|
||||
// Load credit packages on mount
|
||||
useEffect(() => {
|
||||
if (isCheckingAuth) return;
|
||||
|
||||
async function loadPackages() {
|
||||
try {
|
||||
const pkgs = await api.getCreditPackages();
|
||||
setPackages(pkgs);
|
||||
// Default to 5 credits (best value)
|
||||
const bestValue = pkgs.find((p) => p.credits === 5);
|
||||
setSelectedPackage(bestValue || pkgs[0]);
|
||||
} catch (err) {
|
||||
console.error('Failed to load packages:', err);
|
||||
setPackagesError('Failed to load pricing. Please refresh the page.');
|
||||
} finally {
|
||||
setPackagesLoading(false);
|
||||
}
|
||||
}
|
||||
loadPackages();
|
||||
}, [isCheckingAuth]);
|
||||
|
||||
// Handle checkout
|
||||
const handleCheckout = async (e: React.FormEvent) => {
|
||||
e.preventDefault();
|
||||
if (!selectedPackage || !email) return;
|
||||
|
||||
setIsLoading(true);
|
||||
setError(null);
|
||||
|
||||
try {
|
||||
const checkoutUrl = await api.createCheckout(selectedPackage.id, email);
|
||||
// Validate that the URL is a Stripe checkout URL
|
||||
if (!checkoutUrl.startsWith('https://checkout.stripe.com/')) {
|
||||
throw new Error('Invalid checkout URL received');
|
||||
}
|
||||
window.location.href = checkoutUrl;
|
||||
} catch (err) {
|
||||
setError(err instanceof Error ? err.message : 'Failed to create checkout session');
|
||||
setIsLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
// Handle beta enrollment
|
||||
const handleBetaEnroll = async (e: React.FormEvent) => {
|
||||
e.preventDefault();
|
||||
setBetaError(null);
|
||||
|
||||
// Validation
|
||||
if (!betaEmail) {
|
||||
setBetaError('Please enter your email address');
|
||||
return;
|
||||
}
|
||||
if (!betaAccept) {
|
||||
setBetaError('Please accept the corrections work agreement');
|
||||
return;
|
||||
}
|
||||
if (!betaPromise || betaPromise.length < 10) {
|
||||
setBetaError('Please write a sentence about a song you want to make into karaoke');
|
||||
return;
|
||||
}
|
||||
|
||||
setBetaLoading(true);
|
||||
|
||||
try {
|
||||
const response: BetaEnrollResponse = await api.enrollBetaTester(
|
||||
betaEmail,
|
||||
betaPromise,
|
||||
betaAccept
|
||||
);
|
||||
|
||||
// If we got a session token, store it and redirect to main app
|
||||
if (response.session_token) {
|
||||
setAccessToken(response.session_token);
|
||||
setBetaSuccess(true);
|
||||
setBetaWillRedirect(true);
|
||||
// Redirect to main app after showing success message
|
||||
redirectTimeoutRef.current = setTimeout(() => {
|
||||
router.push('/app');
|
||||
}, 2000);
|
||||
} else {
|
||||
// No token means email verification needed
|
||||
setBetaSuccess(true);
|
||||
setBetaWillRedirect(false);
|
||||
}
|
||||
} catch (err) {
|
||||
setBetaError(err instanceof Error ? err.message : 'Failed to enroll in beta program');
|
||||
} finally {
|
||||
setIsLoadingJobs(false)
|
||||
setBetaLoading(false);
|
||||
}
|
||||
}, [])
|
||||
};
|
||||
|
||||
// Enable notifications for job status changes (sound + title animation)
|
||||
useJobNotifications(jobs)
|
||||
const formatPrice = (cents: number) => `$${(cents / 100).toFixed(0)}`;
|
||||
const pricePerVideo = (pkg: CreditPackage) =>
|
||||
`$${(pkg.price_cents / 100 / pkg.credits).toFixed(2)}`;
|
||||
|
||||
// Refresh jobs immediately when tab becomes visible (after returning from review UIs)
|
||||
useVisibilityRefresh(loadJobs, isAuthenticated)
|
||||
|
||||
// Check auth status on mount
|
||||
useEffect(() => {
|
||||
setIsAuthenticated(!!getAccessToken())
|
||||
}, [])
|
||||
|
||||
// Initialize auto-mode from URL parameter on mount
|
||||
useEffect(() => {
|
||||
const urlAutoMode = getAutoModeFromUrl()
|
||||
if (urlAutoMode) {
|
||||
setAutoMode(true)
|
||||
}
|
||||
}, [setAutoMode])
|
||||
|
||||
// Load jobs on mount (only if authenticated)
|
||||
useEffect(() => {
|
||||
if (!isAuthenticated) {
|
||||
setIsLoadingJobs(false)
|
||||
return
|
||||
}
|
||||
loadJobs()
|
||||
// Poll for updates every 10 seconds
|
||||
const interval = setInterval(loadJobs, 10000)
|
||||
return () => clearInterval(interval)
|
||||
}, [isAuthenticated, loadJobs])
|
||||
// Show loading while checking auth
|
||||
if (isCheckingAuth) {
|
||||
return (
|
||||
<div className="min-h-screen flex items-center justify-center animated-gradient">
|
||||
<Loader2 className="w-8 h-8 animate-spin text-white" />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="min-h-screen" style={{ background: 'var(--bg)' }}>
|
||||
{/* AutoProcessor - handles non-interactive mode */}
|
||||
<AutoProcessor jobs={jobs} onJobsChanged={loadJobs} />
|
||||
|
||||
{/* Header */}
|
||||
<header className="border-b backdrop-blur-sm sticky top-0 z-10" style={{ borderColor: 'var(--card-border)', backgroundColor: 'var(--card)' }}>
|
||||
<div className="px-3 sm:px-4 py-2 sm:py-3 flex items-center justify-between gap-2">
|
||||
<div className="flex items-center gap-2 sm:gap-3 min-w-0">
|
||||
<img src="/nomad-karaoke-logo.svg" alt="Nomad Karaoke" className="h-8 sm:h-10 shrink-0" />
|
||||
<div className="min-w-0">
|
||||
<h1 className="text-base sm:text-xl font-bold truncate" style={{ color: 'var(--text)' }}>Karaoke Generator</h1>
|
||||
</div>
|
||||
<div className="min-h-screen animated-gradient">
|
||||
{/* Navigation */}
|
||||
<nav className="fixed top-0 left-0 right-0 z-50 bg-dark-900/80 backdrop-blur-md border-b border-dark-700">
|
||||
<div className="max-w-6xl mx-auto px-4 py-4 flex items-center justify-between">
|
||||
<div className="flex items-center gap-2">
|
||||
<MicVocal className="w-8 h-8 text-primary-500" />
|
||||
<span className="text-xl font-bold">Nomad Karaoke</span>
|
||||
</div>
|
||||
<div className="flex items-center gap-1 sm:gap-2 shrink-0">
|
||||
<TooltipProvider>
|
||||
<Tooltip>
|
||||
<TooltipTrigger asChild>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
onClick={toggleAutoMode}
|
||||
className={`min-h-[40px] px-2 sm:px-3 ${autoModeEnabled ? "text-amber-400 hover:text-amber-300 bg-amber-500/10" : ""}`}
|
||||
style={!autoModeEnabled ? { color: 'var(--text-muted)' } : undefined}
|
||||
>
|
||||
{autoModeEnabled ? (
|
||||
<Zap className="w-4 h-4 sm:mr-2" />
|
||||
) : (
|
||||
<ZapOff className="w-4 h-4 sm:mr-2" />
|
||||
)}
|
||||
<span className="hidden sm:inline">Auto</span>
|
||||
</Button>
|
||||
</TooltipTrigger>
|
||||
<TooltipContent side="bottom" className="max-w-xs">
|
||||
<p className="font-medium">
|
||||
{autoModeEnabled ? "Auto Mode Enabled" : "Auto Mode Disabled"}
|
||||
</p>
|
||||
<p className="text-xs mt-1" style={{ color: 'var(--text-muted)' }}>
|
||||
{autoModeEnabled
|
||||
? "Jobs will auto-complete review and select clean instrumental (like -y flag)"
|
||||
: "Click to enable non-interactive mode"}
|
||||
</p>
|
||||
</TooltipContent>
|
||||
</Tooltip>
|
||||
</TooltipProvider>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
onClick={loadJobs}
|
||||
disabled={isLoadingJobs || !isAuthenticated}
|
||||
className="min-h-[40px] px-2 sm:px-3"
|
||||
style={{ color: 'var(--text-muted)' }}
|
||||
>
|
||||
<RefreshCw className={`w-4 h-4 sm:mr-2 ${isLoadingJobs ? 'animate-spin' : ''}`} />
|
||||
<span className="hidden sm:inline">Refresh</span>
|
||||
</Button>
|
||||
<AuthStatus />
|
||||
{mounted && (
|
||||
<TooltipProvider>
|
||||
<Tooltip>
|
||||
<TooltipTrigger asChild>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
onClick={toggleTheme}
|
||||
className="min-h-[40px] px-2 sm:px-3"
|
||||
style={{ color: 'var(--text-muted)' }}
|
||||
>
|
||||
{isDarkMode ? (
|
||||
<Sun className="w-4 h-4" />
|
||||
) : (
|
||||
<Moon className="w-4 h-4" />
|
||||
)}
|
||||
</Button>
|
||||
</TooltipTrigger>
|
||||
<TooltipContent side="bottom">
|
||||
<p>{isDarkMode ? "Switch to light mode" : "Switch to dark mode"}</p>
|
||||
</TooltipContent>
|
||||
</Tooltip>
|
||||
</TooltipProvider>
|
||||
<button
|
||||
onClick={() => setShowAuthDialog(true)}
|
||||
className="text-sm text-dark-300 hover:text-white transition-colors"
|
||||
>
|
||||
Already have credits? Sign in
|
||||
</button>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
{/* Hero Section */}
|
||||
<section className="pt-32 pb-16 px-4">
|
||||
<div className="max-w-4xl mx-auto text-center">
|
||||
<h1 className="text-4xl sm:text-5xl md:text-6xl font-extrabold mb-6 leading-tight">
|
||||
Turn Any Song Into a{' '}
|
||||
<span className="gradient-text">Karaoke Video</span>
|
||||
</h1>
|
||||
<p className="text-xl text-dark-300 mb-8 max-w-2xl mx-auto">
|
||||
Professional karaoke videos in minutes. AI-powered vocal removal,
|
||||
perfect lyrics sync, and stunning video output.
|
||||
</p>
|
||||
<a
|
||||
href="#pricing"
|
||||
className="inline-flex items-center gap-2 bg-primary-500 hover:bg-primary-600 text-white font-semibold px-8 py-4 rounded-xl transition-all btn-glow"
|
||||
>
|
||||
Get Started
|
||||
<ChevronDown className="w-5 h-5" />
|
||||
</a>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{/* How It Works */}
|
||||
<section className="py-16 px-4">
|
||||
<div className="max-w-6xl mx-auto">
|
||||
<h2 className="text-3xl font-bold text-center mb-12">How It Works</h2>
|
||||
<div className="grid md:grid-cols-4 gap-8">
|
||||
{[
|
||||
{ icon: Music, title: 'Search', desc: 'Enter artist & song title' },
|
||||
{ icon: Sparkles, title: 'AI Magic', desc: 'We remove vocals & sync lyrics' },
|
||||
{ icon: Video, title: 'Review', desc: 'Preview and fine-tune' },
|
||||
{ icon: Youtube, title: 'Export', desc: 'Download or upload to YouTube' },
|
||||
].map((step, i) => (
|
||||
<div key={i} className="text-center">
|
||||
<div className="w-16 h-16 bg-primary-500/20 rounded-2xl flex items-center justify-center mx-auto mb-4">
|
||||
<step.icon className="w-8 h-8 text-primary-400" />
|
||||
</div>
|
||||
<h3 className="font-semibold text-lg mb-2">{step.title}</h3>
|
||||
<p className="text-dark-400 text-sm">{step.desc}</p>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{/* Features */}
|
||||
<section className="py-16 px-4 bg-dark-800/50">
|
||||
<div className="max-w-6xl mx-auto">
|
||||
<h2 className="text-3xl font-bold text-center mb-12">What You Get</h2>
|
||||
<div className="grid md:grid-cols-3 gap-6">
|
||||
{[
|
||||
{ title: 'Studio-Quality Separation', desc: 'State-of-the-art AI removes vocals cleanly, keeping the instrumental crisp.' },
|
||||
{ title: 'Perfect Lyrics Sync', desc: 'Word-by-word timing that highlights exactly when to sing.' },
|
||||
{ title: 'Multiple Instrumental Options', desc: 'Choose from different vocal removal levels to get the sound you want.' },
|
||||
{ title: '4K Video Output', desc: 'Stunning video quality that looks great on any screen.' },
|
||||
{ title: 'YouTube Integration', desc: 'Upload directly to your YouTube channel with one click.' },
|
||||
{ title: 'Edit Before Export', desc: 'Fix any lyrics issues before generating your final video.' },
|
||||
].map((feature, i) => (
|
||||
<div key={i} className="bg-dark-800 border border-dark-700 rounded-xl p-6 card-hover">
|
||||
<h3 className="font-semibold text-lg mb-2">{feature.title}</h3>
|
||||
<p className="text-dark-400 text-sm">{feature.desc}</p>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{/* Beta Tester Program */}
|
||||
<section className="py-12 px-4">
|
||||
<div className="max-w-2xl mx-auto">
|
||||
<div className="bg-gradient-to-r from-purple-900/40 to-pink-900/40 border border-purple-500/30 rounded-2xl p-8 text-center">
|
||||
<div className="inline-flex items-center gap-2 bg-purple-500/20 text-purple-300 px-4 py-2 rounded-full text-sm font-medium mb-4">
|
||||
<Gift className="w-4 h-4" />
|
||||
Beta Tester Program
|
||||
</div>
|
||||
<h3 className="text-2xl font-bold mb-3">Try It Free!</h3>
|
||||
<p className="text-dark-300 mb-6">
|
||||
Help us improve by testing the tool and sharing your feedback. Get a{' '}
|
||||
<span className="text-green-400 font-semibold">free credit</span> to
|
||||
create your first karaoke video!
|
||||
</p>
|
||||
|
||||
{!showBetaForm && !betaSuccess && (
|
||||
<button
|
||||
onClick={() => setShowBetaForm(true)}
|
||||
className="inline-flex items-center gap-2 bg-purple-500 hover:bg-purple-600 text-white font-semibold px-6 py-3 rounded-xl transition-all"
|
||||
>
|
||||
Join Beta Program
|
||||
<MessageSquare className="w-5 h-5" />
|
||||
</button>
|
||||
)}
|
||||
|
||||
{showBetaForm && !betaSuccess && (
|
||||
<form onSubmit={handleBetaEnroll} className="mt-6 text-left space-y-4">
|
||||
<div>
|
||||
<label htmlFor="beta-email" className="block text-sm font-medium text-dark-300 mb-2">
|
||||
Email address
|
||||
</label>
|
||||
<input
|
||||
type="email"
|
||||
id="beta-email"
|
||||
value={betaEmail}
|
||||
onChange={(e) => setBetaEmail(e.target.value)}
|
||||
placeholder="you@example.com"
|
||||
className="w-full px-4 py-3 bg-dark-900 border border-dark-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-purple-500 text-white placeholder-dark-500"
|
||||
required
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label htmlFor="beta-promise" className="block text-sm font-medium text-dark-300 mb-2">
|
||||
What song do you want to make into karaoke?
|
||||
</label>
|
||||
<textarea
|
||||
id="beta-promise"
|
||||
value={betaPromise}
|
||||
onChange={(e) => setBetaPromise(e.target.value)}
|
||||
placeholder="Tell us about a song you'd love to sing..."
|
||||
rows={3}
|
||||
className="w-full px-4 py-3 bg-dark-900 border border-dark-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-purple-500 text-white placeholder-dark-500 resize-none"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="flex items-start gap-3">
|
||||
<input
|
||||
type="checkbox"
|
||||
id="beta-accept"
|
||||
checked={betaAccept}
|
||||
onChange={(e) => setBetaAccept(e.target.checked)}
|
||||
className="mt-1 w-4 h-4 rounded border-dark-600 bg-dark-900 text-purple-500 focus:ring-purple-500"
|
||||
/>
|
||||
<label htmlFor="beta-accept" className="text-sm text-dark-300">
|
||||
I understand that beta testers help improve lyrics accuracy by reviewing and correcting AI-generated lyrics
|
||||
</label>
|
||||
</div>
|
||||
|
||||
{betaError && (
|
||||
<p className="text-red-400 text-sm">{betaError}</p>
|
||||
)}
|
||||
|
||||
<button
|
||||
type="submit"
|
||||
disabled={betaLoading}
|
||||
className="w-full bg-purple-500 hover:bg-purple-600 disabled:bg-purple-500/50 text-white font-semibold py-3 rounded-xl transition-all flex items-center justify-center gap-2"
|
||||
>
|
||||
{betaLoading ? 'Enrolling...' : 'Get My Free Credit'}
|
||||
{!betaLoading && <Gift className="w-5 h-5" />}
|
||||
</button>
|
||||
</form>
|
||||
)}
|
||||
|
||||
{betaSuccess && (
|
||||
<div className="mt-6 p-4 bg-green-500/20 border border-green-500/30 rounded-xl">
|
||||
<p className="text-green-400 font-semibold">
|
||||
Welcome to the beta program!{' '}
|
||||
{betaWillRedirect
|
||||
? 'Redirecting to the app...'
|
||||
: 'Check your email for a sign-in link.'}
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
</section>
|
||||
|
||||
<main className="px-4 py-8 space-y-6">
|
||||
{/* Auto Mode Banner */}
|
||||
{autoModeEnabled && (
|
||||
<div className="bg-amber-500/10 border border-amber-500/30 rounded-lg p-4 flex items-center gap-3">
|
||||
<Zap className="w-5 h-5 text-amber-400 flex-shrink-0" />
|
||||
<div className="flex-1">
|
||||
<p className="text-sm text-amber-200 font-medium">Non-Interactive Mode Active</p>
|
||||
<p className="text-xs text-amber-200/70 mt-0.5">
|
||||
Jobs will automatically accept lyrics and select clean instrumental (equivalent to -y flag)
|
||||
</p>
|
||||
{/* Pricing */}
|
||||
<section id="pricing" className="py-20 px-4">
|
||||
<div className="max-w-4xl mx-auto">
|
||||
<h2 className="text-3xl font-bold text-center mb-4">Simple Pricing</h2>
|
||||
<p className="text-dark-400 text-center mb-12 max-w-xl mx-auto">
|
||||
One credit = one karaoke video. Buy more to save more.
|
||||
</p>
|
||||
|
||||
{/* Package Selection */}
|
||||
{packagesLoading && (
|
||||
<div className="flex items-center justify-center py-8">
|
||||
<Loader2 className="w-8 h-8 animate-spin text-primary-400" />
|
||||
</div>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
onClick={toggleAutoMode}
|
||||
className="text-amber-200 hover:text-amber-100 hover:bg-amber-500/20"
|
||||
>
|
||||
Disable
|
||||
</Button>
|
||||
)}
|
||||
{packagesError && (
|
||||
<div className="text-center py-8 text-red-400">
|
||||
{packagesError}
|
||||
</div>
|
||||
)}
|
||||
<div className="grid grid-cols-2 md:grid-cols-4 gap-4 mb-8">
|
||||
{packages.map((pkg) => {
|
||||
const isSelected = selectedPackage?.id === pkg.id;
|
||||
const isBestValue = pkg.credits === 5;
|
||||
const savings = pkg.credits > 1 ? Math.round((1 - pkg.price_cents / (pkg.credits * 500)) * 100) : 0;
|
||||
|
||||
return (
|
||||
<button
|
||||
key={pkg.id}
|
||||
onClick={() => setSelectedPackage(pkg)}
|
||||
className={`relative p-4 rounded-xl border-2 transition-all ${
|
||||
isSelected
|
||||
? 'border-primary-500 bg-primary-500/10'
|
||||
: 'border-dark-700 hover:border-dark-500 bg-dark-800/50'
|
||||
}`}
|
||||
>
|
||||
{isBestValue && (
|
||||
<span className="absolute -top-3 left-1/2 -translate-x-1/2 bg-primary-500 text-white text-xs font-semibold px-3 py-1 rounded-full">
|
||||
Best Value
|
||||
</span>
|
||||
)}
|
||||
<div className="text-2xl font-bold mb-1">{pkg.credits}</div>
|
||||
<div className="text-sm text-dark-400 mb-2">
|
||||
{pkg.credits === 1 ? 'credit' : 'credits'}
|
||||
</div>
|
||||
<div className="text-xl font-semibold text-primary-400">
|
||||
{formatPrice(pkg.price_cents)}
|
||||
</div>
|
||||
<div className="text-xs text-dark-500">{pricePerVideo(pkg)}/video</div>
|
||||
{savings > 0 && (
|
||||
<div className="text-xs text-green-400 mt-1">Save {savings}%</div>
|
||||
)}
|
||||
</button>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Unauthenticated state */}
|
||||
{!isAuthenticated && (
|
||||
<div className="bg-amber-500/10 border border-amber-500/30 rounded-lg p-6 text-center">
|
||||
<KeyRound className="w-8 h-8 text-amber-400 mx-auto mb-3" />
|
||||
<h3 className="text-lg font-medium mb-2" style={{ color: 'var(--text)' }}>Authentication Required</h3>
|
||||
<p className="text-sm mb-4" style={{ color: 'var(--text-muted)' }}>
|
||||
Click the Login button in the header to enter your access token
|
||||
</p>
|
||||
{/* Checkout Form */}
|
||||
<div className="bg-dark-800 border border-dark-700 rounded-2xl p-8 max-w-md mx-auto">
|
||||
<div className="text-center mb-6">
|
||||
<div className="text-sm text-dark-400 mb-1">Selected package</div>
|
||||
<div className="text-2xl font-bold">
|
||||
{selectedPackage?.credits} Credits
|
||||
</div>
|
||||
<div className="text-3xl font-bold text-primary-400">
|
||||
{selectedPackage && formatPrice(selectedPackage.price_cents)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<form onSubmit={handleCheckout} className="space-y-4">
|
||||
<div>
|
||||
<label htmlFor="email" className="block text-sm font-medium text-dark-300 mb-2">
|
||||
Email address
|
||||
</label>
|
||||
<div className="relative">
|
||||
<Mail className="absolute left-3 top-1/2 -translate-y-1/2 w-5 h-5 text-dark-500" />
|
||||
<input
|
||||
type="email"
|
||||
id="email"
|
||||
value={email}
|
||||
onChange={(e) => setEmail(e.target.value)}
|
||||
placeholder="you@example.com"
|
||||
className="w-full pl-10 pr-4 py-3 bg-dark-900 border border-dark-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-transparent text-white placeholder-dark-500"
|
||||
required
|
||||
/>
|
||||
</div>
|
||||
<p className="text-xs text-dark-500 mt-2">
|
||||
We'll send your login link to this email
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{error && <p className="text-red-400 text-sm">{error}</p>}
|
||||
|
||||
<button
|
||||
type="submit"
|
||||
disabled={isLoading || !selectedPackage}
|
||||
className="w-full bg-primary-500 hover:bg-primary-600 disabled:bg-primary-500/50 text-white font-semibold py-4 rounded-xl transition-all btn-glow flex items-center justify-center gap-2"
|
||||
>
|
||||
{isLoading ? 'Redirecting...' : 'Continue to Payment'}
|
||||
{!isLoading && <Check className="w-5 h-5" />}
|
||||
</button>
|
||||
</form>
|
||||
|
||||
<div className="mt-4 flex items-center justify-center gap-4 text-xs text-dark-500">
|
||||
<span>Secure checkout</span>
|
||||
<span>powered by Stripe</span>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className="grid lg:grid-cols-2 gap-8">
|
||||
{/* Submit Job Card */}
|
||||
<Card className="backdrop-blur" style={{ borderColor: 'var(--card-border)', backgroundColor: 'var(--card)' }}>
|
||||
<CardHeader>
|
||||
<CardTitle style={{ color: 'var(--text)' }}>Create Karaoke Video</CardTitle>
|
||||
<CardDescription style={{ color: 'var(--text-muted)' }}>
|
||||
Upload an audio file, provide a YouTube URL, or search for audio by artist & title
|
||||
</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<JobSubmission onJobCreated={loadJobs} />
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
{/* Jobs List Card */}
|
||||
<Card className="backdrop-blur" style={{ borderColor: 'var(--card-border)', backgroundColor: 'var(--card)' }}>
|
||||
<CardHeader>
|
||||
<CardTitle className="flex items-center justify-between" style={{ color: 'var(--text)' }}>
|
||||
Recent Jobs
|
||||
{isLoadingJobs && <Loader2 className="w-4 h-4 animate-spin" style={{ color: 'var(--text-muted)' }} />}
|
||||
</CardTitle>
|
||||
<CardDescription style={{ color: 'var(--text-muted)' }}>
|
||||
{jobs.length} job{jobs.length !== 1 ? 's' : ''} found
|
||||
</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
{jobs.length === 0 ? (
|
||||
<div className="text-center py-8" style={{ color: 'var(--text-muted)' }}>
|
||||
<Music2 className="w-12 h-12 mx-auto mb-3 opacity-50" />
|
||||
<p>No jobs yet. Create one to get started!</p>
|
||||
</div>
|
||||
) : (
|
||||
<div className="space-y-3 max-h-[500px] overflow-y-auto pr-2">
|
||||
{jobs.map((job) => (
|
||||
<JobCard key={job.job_id} job={job} onRefresh={loadJobs} />
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
</main>
|
||||
</section>
|
||||
|
||||
<VersionFooter />
|
||||
{/* FAQ */}
|
||||
<section className="py-16 px-4 bg-dark-800/50">
|
||||
<div className="max-w-2xl mx-auto">
|
||||
<h2 className="text-3xl font-bold text-center mb-12">Questions?</h2>
|
||||
<div className="space-y-4">
|
||||
{faqs.map((faq, i) => (
|
||||
<div key={i} className="bg-dark-800 border border-dark-700 rounded-xl overflow-hidden">
|
||||
<button
|
||||
onClick={() => setExpandedFaq(expandedFaq === i ? null : i)}
|
||||
aria-expanded={expandedFaq === i}
|
||||
className="w-full px-6 py-4 text-left flex items-center justify-between hover:bg-dark-700/50 transition-colors"
|
||||
>
|
||||
<span className="font-medium">{faq.question}</span>
|
||||
<ChevronDown
|
||||
className={`w-5 h-5 text-dark-400 transition-transform ${
|
||||
expandedFaq === i ? 'rotate-180' : ''
|
||||
}`}
|
||||
/>
|
||||
</button>
|
||||
{expandedFaq === i && (
|
||||
<div className="px-6 pb-4 text-dark-300 text-sm">{faq.answer}</div>
|
||||
)}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{/* Footer */}
|
||||
<footer className="py-12 px-4 border-t border-dark-700">
|
||||
<div className="max-w-6xl mx-auto flex flex-col md:flex-row items-center justify-between gap-4">
|
||||
<div className="flex items-center gap-2">
|
||||
<MicVocal className="w-6 h-6 text-primary-500" />
|
||||
<span className="font-semibold">Nomad Karaoke</span>
|
||||
</div>
|
||||
<div className="text-sm text-dark-500">
|
||||
© {new Date().getFullYear()} Nomad Karaoke. All rights reserved.
|
||||
</div>
|
||||
<div className="flex gap-6 text-sm text-dark-400">
|
||||
<a href="mailto:support@nomadkaraoke.com" className="hover:text-white transition-colors">
|
||||
Support
|
||||
</a>
|
||||
<a href="https://nomadkaraoke.com" className="hover:text-white transition-colors">
|
||||
About
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
{/* Auth Dialog for sign-in */}
|
||||
<AuthDialog
|
||||
open={showAuthDialog}
|
||||
onClose={() => setShowAuthDialog(false)}
|
||||
onSuccess={handleAuthSuccess}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
);
|
||||
}
|
||||
@@ -53,7 +53,7 @@ function PaymentSuccessContent() {
|
||||
|
||||
<div className="space-y-3">
|
||||
<Button
|
||||
onClick={() => router.push("/")}
|
||||
onClick={() => router.push("/app")}
|
||||
className="w-full bg-blue-600 hover:bg-blue-500"
|
||||
>
|
||||
Start Creating Karaoke
|
||||
|
||||
@@ -41,13 +41,12 @@ export function AuthStatus({ onAuthChange }: AuthStatusProps) {
|
||||
}
|
||||
|
||||
const handleBuyCredits = () => {
|
||||
// Navigate to buy site with email prefilled if available
|
||||
const buyBaseUrl = process.env.NEXT_PUBLIC_BUY_URL || "https://buy.nomadkaraoke.com"
|
||||
const buyUrl = new URL(buyBaseUrl)
|
||||
// Navigate to landing page pricing section with email prefilled if available
|
||||
const buyUrl = new URL('/#pricing', window.location.origin)
|
||||
if (user?.email) {
|
||||
buyUrl.searchParams.set("email", user.email)
|
||||
}
|
||||
window.open(buyUrl.toString(), "_blank")
|
||||
window.location.href = buyUrl.toString()
|
||||
}
|
||||
|
||||
// Don't render until mounted (avoids hydration issues)
|
||||
|
||||
@@ -0,0 +1,170 @@
|
||||
/**
|
||||
* Email Testing Utilities using MailSlurp
|
||||
*
|
||||
* MailSlurp provides disposable email inboxes for e2e testing.
|
||||
* Free tier: 50 emails/month - perfect for CI/CD testing.
|
||||
*
|
||||
* Setup:
|
||||
* 1. Create account at https://app.mailslurp.com
|
||||
* 2. Get API key from dashboard
|
||||
* 3. Set MAILSLURP_API_KEY environment variable
|
||||
*
|
||||
* Usage in tests:
|
||||
* const emailHelper = await createEmailHelper();
|
||||
* const inbox = await emailHelper.createInbox();
|
||||
* // ... trigger email send to inbox.emailAddress ...
|
||||
* const email = await emailHelper.waitForEmail(inbox.id);
|
||||
* const magicLink = emailHelper.extractMagicLink(email);
|
||||
*/
|
||||
|
||||
import { MailSlurp, InboxDto, Email } from 'mailslurp-client';
|
||||
|
||||
const MAILSLURP_API_KEY = process.env.MAILSLURP_API_KEY;
|
||||
|
||||
export interface EmailHelper {
|
||||
isAvailable: boolean;
|
||||
createInbox: () => Promise<InboxDto>;
|
||||
waitForEmail: (inboxId: string, timeout?: number) => Promise<Email>;
|
||||
extractMagicLink: (email: Email) => string | null;
|
||||
extractVerificationCode: (email: Email) => string | null;
|
||||
deleteInbox: (inboxId: string) => Promise<void>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an email testing helper.
|
||||
* Returns a helper with isAvailable=false if MAILSLURP_API_KEY is not set.
|
||||
*/
|
||||
export async function createEmailHelper(): Promise<EmailHelper> {
|
||||
if (!MAILSLURP_API_KEY) {
|
||||
console.warn('MAILSLURP_API_KEY not set - email testing disabled');
|
||||
return createDisabledHelper();
|
||||
}
|
||||
|
||||
const mailslurp = new MailSlurp({ apiKey: MAILSLURP_API_KEY });
|
||||
|
||||
return {
|
||||
isAvailable: true,
|
||||
|
||||
/**
|
||||
* Create a new disposable inbox for testing
|
||||
*/
|
||||
async createInbox(): Promise<InboxDto> {
|
||||
const inbox = await mailslurp.createInbox();
|
||||
console.log(`Created test inbox: ${inbox.emailAddress}`);
|
||||
return inbox;
|
||||
},
|
||||
|
||||
/**
|
||||
* Wait for an email to arrive in the inbox
|
||||
* @param inboxId - The inbox ID to check
|
||||
* @param timeout - Timeout in ms (default: 60000 = 1 minute)
|
||||
*/
|
||||
async waitForEmail(inboxId: string, timeout = 60000): Promise<Email> {
|
||||
console.log(`Waiting for email in inbox ${inboxId}...`);
|
||||
const email = await mailslurp.waitForLatestEmail(inboxId, timeout);
|
||||
console.log(`Received email: ${email.subject}`);
|
||||
return email;
|
||||
},
|
||||
|
||||
/**
|
||||
* Extract magic link URL from email body
|
||||
*/
|
||||
extractMagicLink(email: Email): string | null {
|
||||
const body = email.body || '';
|
||||
|
||||
// Debug: Log email structure
|
||||
console.log('Email subject:', email.subject);
|
||||
console.log('Email body length:', body.length);
|
||||
console.log('Email body preview (first 500 chars):', body.substring(0, 500));
|
||||
|
||||
// Look for common magic link patterns
|
||||
const patterns = [
|
||||
// gen.nomadkaraoke.com verify link
|
||||
/https:\/\/gen\.nomadkaraoke\.com\/auth\/verify\?token=[a-zA-Z0-9_-]+/,
|
||||
// api.nomadkaraoke.com verify link
|
||||
/https:\/\/api\.nomadkaraoke\.com\/api\/users\/auth\/verify\?token=[a-zA-Z0-9_-]+/,
|
||||
// Generic magic link patterns - allow URL-encoded characters
|
||||
/https?:\/\/[^\s<>"]+\/auth\/verify[^\s<>"]*/,
|
||||
/https?:\/\/[^\s<>"]+verify\?token=[a-zA-Z0-9_%-]+/,
|
||||
/https?:\/\/[^\s<>"]+token=[a-zA-Z0-9_%-]+/,
|
||||
];
|
||||
|
||||
for (const pattern of patterns) {
|
||||
const match = body.match(pattern);
|
||||
if (match) {
|
||||
console.log(`Found magic link with pattern ${pattern}: ${match[0]}`);
|
||||
return match[0];
|
||||
}
|
||||
}
|
||||
|
||||
// Also check HTML links
|
||||
if (email.body) {
|
||||
const htmlLinkPattern = /href=["']([^"']*(?:verify|token)[^"']*)["']/i;
|
||||
const htmlMatch = email.body.match(htmlLinkPattern);
|
||||
if (htmlMatch) {
|
||||
console.log(`Found magic link in HTML href: ${htmlMatch[1]}`);
|
||||
return htmlMatch[1];
|
||||
}
|
||||
}
|
||||
|
||||
// Debug: Log all URLs found in the email
|
||||
const allUrls = body.match(/https?:\/\/[^\s<>"]+/g) || [];
|
||||
console.log('All URLs found in email:', allUrls);
|
||||
|
||||
console.warn('No magic link found in email');
|
||||
return null;
|
||||
},
|
||||
|
||||
/**
|
||||
* Extract verification code from email body
|
||||
*/
|
||||
extractVerificationCode(email: Email): string | null {
|
||||
const body = email.body || '';
|
||||
|
||||
// Look for 6-digit codes
|
||||
const codePattern = /\b(\d{6})\b/;
|
||||
const match = body.match(codePattern);
|
||||
|
||||
if (match) {
|
||||
console.log(`Found verification code: ${match[1]}`);
|
||||
return match[1];
|
||||
}
|
||||
|
||||
console.warn('No verification code found in email');
|
||||
return null;
|
||||
},
|
||||
|
||||
/**
|
||||
* Delete an inbox after testing
|
||||
*/
|
||||
async deleteInbox(inboxId: string): Promise<void> {
|
||||
await mailslurp.deleteInbox(inboxId);
|
||||
console.log(`Deleted inbox ${inboxId}`);
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a disabled helper for when MailSlurp is not configured
|
||||
*/
|
||||
function createDisabledHelper(): EmailHelper {
|
||||
const notAvailable = () => {
|
||||
throw new Error('Email testing not available - set MAILSLURP_API_KEY');
|
||||
};
|
||||
|
||||
return {
|
||||
isAvailable: false,
|
||||
createInbox: notAvailable,
|
||||
waitForEmail: notAvailable,
|
||||
extractMagicLink: () => null,
|
||||
extractVerificationCode: () => null,
|
||||
deleteInbox: notAvailable,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if email testing is available
|
||||
*/
|
||||
export function isEmailTestingAvailable(): boolean {
|
||||
return !!MAILSLURP_API_KEY;
|
||||
}
|
||||
@@ -0,0 +1,532 @@
|
||||
import { test, expect, Page } from '@playwright/test';
|
||||
import { createEmailHelper, isEmailTestingAvailable } from './helpers/email-testing';
|
||||
|
||||
/**
|
||||
* Production User Journey E2E Test
|
||||
*
|
||||
* Tests the complete user flow from landing page to karaoke generation:
|
||||
* 1. Visit landing page at / (root)
|
||||
* 2. Beta enrollment OR payment checkout
|
||||
* 3. Magic link verification
|
||||
* 4. Main app authentication at /app
|
||||
* 5. Job submission
|
||||
*
|
||||
* Run with:
|
||||
* npx playwright test production-user-journey --config=playwright.production.config.ts --headed
|
||||
*
|
||||
* Environment variables:
|
||||
* - MAILSLURP_API_KEY: For email testing (free tier: 50 emails/month)
|
||||
* - TEST_EMAIL: Use a specific email for testing
|
||||
* - KARAOKE_ACCESS_TOKEN: Skip auth flow and use existing token
|
||||
*/
|
||||
|
||||
// After consolidation, landing page is at root and app is at /app
|
||||
const BASE_URL = 'https://gen.nomadkaraoke.com';
|
||||
const LANDING_URL = BASE_URL; // Landing page at root
|
||||
const APP_URL = `${BASE_URL}/app`; // Main app
|
||||
const API_URL = 'https://api.nomadkaraoke.com';
|
||||
|
||||
// Test data
|
||||
const TEST_ARTIST = 'piri';
|
||||
const TEST_TITLE = 'dog';
|
||||
|
||||
test.describe('User Journey - Landing Page', () => {
|
||||
|
||||
test('Landing page loads and displays correctly', async ({ page }) => {
|
||||
await page.goto(LANDING_URL);
|
||||
await page.waitForLoadState('networkidle');
|
||||
|
||||
// Check hero section
|
||||
await expect(page.locator('h1')).toContainText('Karaoke Video');
|
||||
|
||||
// Check navigation
|
||||
await expect(page.locator('nav')).toBeVisible();
|
||||
await expect(page.getByRole('navigation').getByText('Nomad Karaoke')).toBeVisible();
|
||||
|
||||
// Check pricing section exists
|
||||
await expect(page.locator('#pricing')).toBeVisible();
|
||||
|
||||
// Check beta tester program section
|
||||
await expect(page.getByText('Beta Tester Program')).toBeVisible();
|
||||
|
||||
// Check FAQ section
|
||||
await expect(page.getByText('Questions?')).toBeVisible();
|
||||
|
||||
await page.screenshot({ path: 'test-results/journey-01-landing.png', fullPage: true });
|
||||
});
|
||||
|
||||
test('Pricing packages display correctly', async ({ page }) => {
|
||||
await page.goto(LANDING_URL);
|
||||
await page.waitForLoadState('networkidle');
|
||||
|
||||
// Scroll to pricing and wait for content to be visible
|
||||
await page.locator('#pricing').scrollIntoViewIfNeeded();
|
||||
|
||||
// Check all 4 credit packages are displayed (case-insensitive, as page has "credit" lowercase)
|
||||
await expect(page.getByRole('button', { name: /1\s+credit/i })).toBeVisible();
|
||||
await expect(page.getByRole('button', { name: /3\s+credits/i })).toBeVisible();
|
||||
await expect(page.getByRole('button', { name: /5\s+credits/i })).toBeVisible();
|
||||
await expect(page.getByRole('button', { name: /10\s+credits/i })).toBeVisible();
|
||||
|
||||
// Check "Best Value" badge on 5 credits
|
||||
await expect(page.getByText('Best Value')).toBeVisible();
|
||||
|
||||
await page.screenshot({ path: 'test-results/journey-02-pricing.png' });
|
||||
});
|
||||
|
||||
test('Package selection updates checkout form', async ({ page }) => {
|
||||
await page.goto(LANDING_URL);
|
||||
await page.waitForLoadState('networkidle');
|
||||
|
||||
await page.locator('#pricing').scrollIntoViewIfNeeded();
|
||||
|
||||
// Default should be 5 credits - look for summary section
|
||||
await expect(page.getByText('Selected package')).toBeVisible();
|
||||
|
||||
// Click on 10 credits button and wait for it to be pressed/selected
|
||||
const tenCreditsBtn = page.getByRole('button', { name: /10\s+credits/i });
|
||||
await tenCreditsBtn.click();
|
||||
|
||||
// Wait for the package selection summary to update
|
||||
// The summary section contains "Selected package", "10 Credits", and "$30"
|
||||
// We need to verify the summary (not the button) shows $30
|
||||
const summaryContainer = page.locator('text=Selected package').locator('..');
|
||||
await expect(summaryContainer.getByText('10 Credits')).toBeVisible({ timeout: 10000 });
|
||||
await expect(summaryContainer.getByText('$30')).toBeVisible();
|
||||
|
||||
await page.screenshot({ path: 'test-results/journey-03-package-selected.png' });
|
||||
});
|
||||
|
||||
test('Checkout form validates email', async ({ page }) => {
|
||||
await page.goto(LANDING_URL);
|
||||
await page.waitForLoadState('networkidle');
|
||||
|
||||
await page.locator('#pricing').scrollIntoViewIfNeeded();
|
||||
|
||||
// Try to checkout without email
|
||||
await page.getByRole('button', { name: /continue to payment/i }).click();
|
||||
|
||||
// Should show error (browser validation)
|
||||
const emailInput = page.locator('input[type="email"]').first();
|
||||
await expect(emailInput).toBeVisible();
|
||||
|
||||
// Enter invalid email - the button should require valid email
|
||||
await emailInput.fill('invalid');
|
||||
|
||||
await page.screenshot({ path: 'test-results/journey-04-email-validation.png' });
|
||||
});
|
||||
|
||||
test('Checkout redirects to Stripe', async ({ page }) => {
|
||||
test.skip(!process.env.TEST_CHECKOUT, 'Skipping actual checkout - set TEST_CHECKOUT=true to enable');
|
||||
|
||||
await page.goto(LANDING_URL);
|
||||
await page.waitForLoadState('networkidle');
|
||||
|
||||
await page.locator('#pricing').scrollIntoViewIfNeeded();
|
||||
|
||||
// Fill email
|
||||
const testEmail = process.env.TEST_EMAIL || 'test@example.com';
|
||||
await page.locator('input[type="email"]').first().fill(testEmail);
|
||||
|
||||
// Click checkout
|
||||
await page.getByRole('button', { name: /continue to payment/i }).click();
|
||||
|
||||
// Wait for redirect to Stripe
|
||||
await page.waitForURL(/checkout\.stripe\.com/, { timeout: 30000 });
|
||||
|
||||
await expect(page.url()).toContain('stripe.com');
|
||||
await page.screenshot({ path: 'test-results/journey-05-stripe-redirect.png' });
|
||||
});
|
||||
|
||||
test('Logged in users are redirected to /app', async ({ page }) => {
|
||||
// Set a token in storage
|
||||
await page.goto(LANDING_URL);
|
||||
await page.evaluate(() => {
|
||||
localStorage.setItem('karaoke_access_token', 'test-redirect-token');
|
||||
});
|
||||
|
||||
// Reload the page - should redirect to /app
|
||||
await page.goto(LANDING_URL);
|
||||
await page.waitForURL(/\/app/, { timeout: 5000 });
|
||||
|
||||
expect(page.url()).toContain('/app');
|
||||
await page.screenshot({ path: 'test-results/journey-05b-logged-in-redirect.png' });
|
||||
|
||||
// Cleanup
|
||||
await page.evaluate(() => {
|
||||
localStorage.removeItem('karaoke_access_token');
|
||||
});
|
||||
});
|
||||
|
||||
test('Sign in button opens auth dialog on landing page', async ({ page }) => {
|
||||
await page.goto(LANDING_URL);
|
||||
await page.waitForLoadState('networkidle');
|
||||
|
||||
// Click "Sign in" button in nav
|
||||
await page.getByRole('button', { name: /sign in/i }).click();
|
||||
|
||||
// Auth dialog should open
|
||||
const dialog = page.locator('[role="dialog"]');
|
||||
await expect(dialog).toBeVisible();
|
||||
await expect(dialog.getByText('Enter your email to receive a sign-in link')).toBeVisible();
|
||||
await expect(dialog.locator('input[type="email"]')).toBeVisible();
|
||||
|
||||
await page.screenshot({ path: 'test-results/journey-05c-landing-signin-dialog.png' });
|
||||
});
|
||||
});
|
||||
|
||||
test.describe('User Journey - Beta Enrollment', () => {
|
||||
|
||||
test('Beta form opens and validates input', async ({ page }) => {
|
||||
await page.goto(LANDING_URL);
|
||||
await page.waitForLoadState('networkidle');
|
||||
|
||||
// Click "Join Beta Program" and wait for form to appear
|
||||
await page.getByRole('button', { name: /join beta program/i }).click();
|
||||
await expect(page.getByRole('button', { name: /get my free credit/i })).toBeVisible();
|
||||
|
||||
await page.screenshot({ path: 'test-results/journey-06-beta-form.png' });
|
||||
|
||||
// Email input has 'required' attribute, so browser native validation will block submission
|
||||
// Test by filling email but not accepting terms to trigger JS validation
|
||||
await page.locator('#beta-email').fill('test@example.com');
|
||||
|
||||
// Try to submit without accepting terms
|
||||
await page.getByRole('button', { name: /get my free credit/i }).click();
|
||||
|
||||
// Should show validation error for missing checkbox
|
||||
await expect(page.getByText(/please accept/i)).toBeVisible();
|
||||
});
|
||||
|
||||
test('Beta form requires checkbox and promise', async ({ page }) => {
|
||||
await page.goto(LANDING_URL);
|
||||
await page.waitForLoadState('networkidle');
|
||||
|
||||
// Open beta form and wait for email field to be visible
|
||||
await page.getByRole('button', { name: /join beta program/i }).click();
|
||||
await expect(page.locator('#beta-email')).toBeVisible();
|
||||
|
||||
// Fill email
|
||||
await page.locator('#beta-email').fill('test@example.com');
|
||||
|
||||
// Submit without checkbox
|
||||
await page.getByRole('button', { name: /get my free credit/i }).click();
|
||||
await expect(page.getByText(/please accept/i)).toBeVisible();
|
||||
|
||||
// Check the checkbox
|
||||
await page.locator('input[type="checkbox"]').check();
|
||||
|
||||
// Submit without promise
|
||||
await page.getByRole('button', { name: /get my free credit/i }).click();
|
||||
await expect(page.getByText(/please write a sentence/i)).toBeVisible();
|
||||
|
||||
// Add promise text (too short)
|
||||
await page.locator('textarea').fill('ok');
|
||||
await page.getByRole('button', { name: /get my free credit/i }).click();
|
||||
await expect(page.getByText(/please write a sentence/i)).toBeVisible();
|
||||
|
||||
await page.screenshot({ path: 'test-results/journey-07-beta-validation.png' });
|
||||
});
|
||||
});
|
||||
|
||||
test.describe('User Journey - Main App', () => {
|
||||
|
||||
test('Unauthenticated users are redirected to landing page', async ({ page }) => {
|
||||
// Clear any existing token
|
||||
await page.goto(LANDING_URL);
|
||||
await page.evaluate(() => {
|
||||
localStorage.removeItem('karaoke_access_token');
|
||||
});
|
||||
|
||||
// Try to go to /app
|
||||
await page.goto(APP_URL);
|
||||
|
||||
// Should redirect to landing page
|
||||
await page.waitForURL(LANDING_URL, { timeout: 5000 });
|
||||
|
||||
// Should see the landing page hero
|
||||
await expect(page.locator('h1')).toContainText('Karaoke Video');
|
||||
|
||||
await page.screenshot({ path: 'test-results/journey-08-unauth-redirect.png' });
|
||||
});
|
||||
|
||||
test('Auth dialog opens and shows magic link option', async ({ page }) => {
|
||||
// First set a token to access the app (any token allows the page to render,
|
||||
// even if API calls will fail with 401 - token validation happens on API calls, not page load)
|
||||
await page.goto(LANDING_URL);
|
||||
await page.evaluate(() => {
|
||||
localStorage.setItem('karaoke_access_token', 'test-token');
|
||||
});
|
||||
|
||||
await page.goto(APP_URL);
|
||||
await page.waitForLoadState('networkidle');
|
||||
|
||||
// Click login button and wait for auth dialog to open
|
||||
await page.getByRole('button', { name: /login|sign in/i }).click();
|
||||
|
||||
// Wait for dialog and check it has the expected content
|
||||
const dialog = page.locator('[role="dialog"]');
|
||||
await expect(dialog).toBeVisible();
|
||||
await expect(dialog.getByText('Enter your email to receive a sign-in link')).toBeVisible();
|
||||
await expect(dialog.locator('input[type="email"]')).toBeVisible();
|
||||
|
||||
await page.screenshot({ path: 'test-results/journey-09-auth-dialog.png' });
|
||||
|
||||
// Cleanup
|
||||
await page.evaluate(() => {
|
||||
localStorage.removeItem('karaoke_access_token');
|
||||
});
|
||||
});
|
||||
|
||||
test('Authenticated user can see the main app', async ({ page }) => {
|
||||
const accessToken = process.env.KARAOKE_ACCESS_TOKEN;
|
||||
test.skip(!accessToken, 'Skipping - set KARAOKE_ACCESS_TOKEN env var');
|
||||
|
||||
// Set token and go to app
|
||||
await page.goto(LANDING_URL);
|
||||
await page.evaluate((token) => {
|
||||
localStorage.setItem('karaoke_access_token', token);
|
||||
}, accessToken);
|
||||
|
||||
await page.goto(APP_URL);
|
||||
await page.waitForLoadState('networkidle');
|
||||
|
||||
// Should see the job creation form
|
||||
await expect(page.getByText(/create karaoke video/i)).toBeVisible();
|
||||
|
||||
await page.screenshot({ path: 'test-results/journey-10-authenticated.png' });
|
||||
});
|
||||
});
|
||||
|
||||
test.describe('User Journey - Same Domain Token Persistence', () => {
|
||||
|
||||
test('LocalStorage persists on same domain after consolidation', async ({ page }) => {
|
||||
/**
|
||||
* REGRESSION TEST: Verify single-domain solution works
|
||||
*
|
||||
* After consolidation, landing page and main app are on the same domain,
|
||||
* so localStorage should persist across navigation.
|
||||
*
|
||||
* Note: We use a test key (not karaoke_access_token) because:
|
||||
* 1. The landing page redirects to /app when a token is present
|
||||
* 2. The /app page clears invalid tokens when API calls return 401
|
||||
* This is correct behavior, but not what we're testing here.
|
||||
*/
|
||||
|
||||
// Navigate to landing page
|
||||
await page.goto(LANDING_URL);
|
||||
await page.waitForLoadState('networkidle');
|
||||
|
||||
// Store a test value in localStorage (using a test key, not the auth token)
|
||||
await page.evaluate(() => {
|
||||
localStorage.setItem('karaoke_test_persistence', 'test-value-123');
|
||||
});
|
||||
|
||||
// Navigate to pricing section (still on same domain)
|
||||
await page.goto(`${LANDING_URL}#pricing`);
|
||||
await page.waitForLoadState('networkidle');
|
||||
|
||||
// Value should still be accessible (same domain)
|
||||
const valueAfterNavigation = await page.evaluate(() =>
|
||||
localStorage.getItem('karaoke_test_persistence')
|
||||
);
|
||||
|
||||
// Verify value persisted
|
||||
expect(valueAfterNavigation).toBe('test-value-123');
|
||||
console.log('LocalStorage persisted correctly across same-domain navigation');
|
||||
|
||||
// Also verify by navigating to a different section
|
||||
await page.goto(`${LANDING_URL}#faq`);
|
||||
await page.waitForLoadState('networkidle');
|
||||
|
||||
const valueAfterSecondNav = await page.evaluate(() =>
|
||||
localStorage.getItem('karaoke_test_persistence')
|
||||
);
|
||||
expect(valueAfterSecondNav).toBe('test-value-123');
|
||||
|
||||
await page.screenshot({ path: 'test-results/journey-11-same-domain-token.png' });
|
||||
|
||||
// Cleanup
|
||||
await page.evaluate(() => {
|
||||
localStorage.removeItem('karaoke_test_persistence');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
test.describe('User Journey - Complete Flow with Email', () => {
|
||||
|
||||
test('Full flow: Beta enrollment with session token and welcome email', async ({ page, request }) => {
|
||||
/**
|
||||
* Tests the complete beta enrollment flow:
|
||||
* 1. Fill out beta form with a MailSlurp test inbox
|
||||
* 2. Submit form and receive session token immediately (no email verification needed)
|
||||
* 3. Get redirected to /app
|
||||
* 4. Verify welcome email was received
|
||||
*
|
||||
* Note: Beta enrollment for NEW users returns a session token directly.
|
||||
* The welcome email is informational only (no magic link).
|
||||
*/
|
||||
test.skip(!isEmailTestingAvailable(), 'Skipping email flow - set MAILSLURP_API_KEY for full test');
|
||||
|
||||
const emailHelper = await createEmailHelper();
|
||||
|
||||
if (!emailHelper.isAvailable) {
|
||||
test.skip();
|
||||
return;
|
||||
}
|
||||
|
||||
// Step 1: Create a test inbox
|
||||
console.log('\n=== STEP 1: Creating test inbox ===');
|
||||
const inbox = await emailHelper.createInbox();
|
||||
if (!inbox.id || !inbox.emailAddress) {
|
||||
throw new Error('MailSlurp inbox creation failed - missing id or email');
|
||||
}
|
||||
console.log(`Test email: ${inbox.emailAddress}`);
|
||||
|
||||
try {
|
||||
// Step 2: Go to landing page and enroll in beta
|
||||
console.log('\n=== STEP 2: Beta enrollment ===');
|
||||
await page.goto(LANDING_URL);
|
||||
await page.waitForLoadState('networkidle');
|
||||
|
||||
// Click "Join Beta Program" and wait for form
|
||||
await page.getByRole('button', { name: /join beta program/i }).click();
|
||||
await expect(page.locator('#beta-email')).toBeVisible();
|
||||
|
||||
// Fill the beta form
|
||||
await page.locator('#beta-email').fill(inbox.emailAddress);
|
||||
await page.locator('textarea').fill('I want to create karaoke for my favorite indie songs that nobody has made yet!');
|
||||
await page.locator('input[type="checkbox"]').check();
|
||||
|
||||
await page.screenshot({ path: 'test-results/email-flow-01-beta-form.png' });
|
||||
|
||||
// Submit the form
|
||||
await page.getByRole('button', { name: /get my free credit/i }).click();
|
||||
|
||||
// Step 3: Verify successful enrollment
|
||||
console.log('\n=== STEP 3: Verifying enrollment success ===');
|
||||
|
||||
// Wait for success message - "Redirecting to the app..." means we got a session token
|
||||
await expect(
|
||||
page.getByText(/welcome to the beta|redirecting to the app/i)
|
||||
).toBeVisible({ timeout: 15000 });
|
||||
await page.screenshot({ path: 'test-results/email-flow-02-after-submit.png' });
|
||||
|
||||
// Step 4: Wait for redirect to /app
|
||||
console.log('\n=== STEP 4: Waiting for redirect to /app ===');
|
||||
await page.waitForURL(/\/app/, { timeout: 10000 });
|
||||
|
||||
// Verify we're authenticated
|
||||
const token = await page.evaluate(() => localStorage.getItem('karaoke_access_token'));
|
||||
expect(token).toBeTruthy();
|
||||
console.log('Session token received successfully!');
|
||||
|
||||
// Verify app is loaded
|
||||
await expect(page.getByText('Create Karaoke Video')).toBeVisible();
|
||||
await page.screenshot({ path: 'test-results/email-flow-03-app-authenticated.png' });
|
||||
|
||||
// Step 5: Verify welcome email was received
|
||||
console.log('\n=== STEP 5: Verifying welcome email ===');
|
||||
const email = await emailHelper.waitForEmail(inbox.id, 60000); // 1 minute timeout
|
||||
console.log(`Received email: "${email.subject}"`);
|
||||
|
||||
// Verify it's the beta welcome email
|
||||
expect(email.subject).toMatch(/welcome.*beta|beta.*tester/i);
|
||||
console.log('Welcome email received successfully!');
|
||||
|
||||
await page.screenshot({ path: 'test-results/email-flow-04-completed.png' });
|
||||
console.log('\n=== Beta enrollment flow completed successfully! ===');
|
||||
|
||||
} finally {
|
||||
// Cleanup: delete the test inbox
|
||||
if (inbox.id) {
|
||||
await emailHelper.deleteInbox(inbox.id);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
test('Full flow: Payment checkout with email verification', async ({ page, request }) => {
|
||||
// Skip if no email testing capability
|
||||
test.skip(!isEmailTestingAvailable(), 'Skipping email flow - set MAILSLURP_API_KEY for full test');
|
||||
test.skip(!process.env.TEST_PAYMENT_FLOW, 'Skipping payment flow - set TEST_PAYMENT_FLOW=true');
|
||||
|
||||
const emailHelper = await createEmailHelper();
|
||||
|
||||
if (!emailHelper.isAvailable) {
|
||||
test.skip();
|
||||
return;
|
||||
}
|
||||
|
||||
// Create a test inbox
|
||||
const inbox = await emailHelper.createInbox();
|
||||
if (!inbox.id || !inbox.emailAddress) {
|
||||
throw new Error('MailSlurp inbox creation failed - missing id or email');
|
||||
}
|
||||
|
||||
try {
|
||||
// Go to landing page
|
||||
await page.goto(LANDING_URL);
|
||||
await page.waitForLoadState('networkidle');
|
||||
|
||||
// Scroll to pricing
|
||||
await page.locator('#pricing').scrollIntoViewIfNeeded();
|
||||
|
||||
// Fill email and submit
|
||||
await page.locator('#email').fill(inbox.emailAddress);
|
||||
await page.getByRole('button', { name: /continue to payment/i }).click();
|
||||
|
||||
// Should redirect to Stripe
|
||||
await page.waitForURL(/checkout\.stripe\.com/, { timeout: 30000 });
|
||||
await page.screenshot({ path: 'test-results/email-payment-01-stripe.png' });
|
||||
|
||||
// Note: We don't complete the Stripe payment in tests
|
||||
// After payment, Stripe would redirect back and trigger email
|
||||
|
||||
} finally {
|
||||
if (inbox.id) {
|
||||
await emailHelper.deleteInbox(inbox.id);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
test.describe('User Journey - API Health', () => {
|
||||
|
||||
test('API endpoints are responding', async ({ request }) => {
|
||||
// Health check
|
||||
const healthResponse = await request.get(`${API_URL}/api/health`);
|
||||
expect(healthResponse.ok()).toBe(true);
|
||||
|
||||
// Root endpoint
|
||||
const rootResponse = await request.get(`${API_URL}/`);
|
||||
expect(rootResponse.ok()).toBe(true);
|
||||
const rootData = await rootResponse.json();
|
||||
expect(rootData.service).toContain('karaoke-gen');
|
||||
expect(rootData.version).toBeTruthy();
|
||||
|
||||
console.log(`API Version: ${rootData.version}`);
|
||||
});
|
||||
|
||||
test('Credit packages endpoint works', async ({ request }) => {
|
||||
interface CreditPackageResponse {
|
||||
id: string;
|
||||
credits: number;
|
||||
price_cents: number;
|
||||
}
|
||||
|
||||
const response = await request.get(`${API_URL}/api/users/credits/packages`);
|
||||
expect(response.ok()).toBe(true);
|
||||
|
||||
const data = await response.json();
|
||||
expect(data.packages).toBeInstanceOf(Array);
|
||||
expect(data.packages.length).toBeGreaterThan(0);
|
||||
|
||||
// Verify package structure
|
||||
const pkg = data.packages[0] as CreditPackageResponse;
|
||||
expect(pkg.id).toBeTruthy();
|
||||
expect(pkg.credits).toBeGreaterThan(0);
|
||||
expect(pkg.price_cents).toBeGreaterThan(0);
|
||||
|
||||
console.log('Credit packages:', data.packages.map((p: CreditPackageResponse) => `${p.credits} credits @ $${p.price_cents/100}`).join(', '));
|
||||
});
|
||||
});
|
||||
@@ -586,7 +586,80 @@ export const api = {
|
||||
});
|
||||
return handleResponse(response);
|
||||
},
|
||||
|
||||
// ==========================================================================
|
||||
// Credits/Payment API endpoints
|
||||
// ==========================================================================
|
||||
|
||||
/**
|
||||
* Get available credit packages
|
||||
*/
|
||||
async getCreditPackages(): Promise<CreditPackage[]> {
|
||||
const response = await fetch(`${API_BASE_URL}/api/users/credits/packages`);
|
||||
const data = await handleResponse<{ packages: CreditPackage[] }>(response);
|
||||
return data.packages;
|
||||
},
|
||||
|
||||
/**
|
||||
* Create a Stripe checkout session
|
||||
*/
|
||||
async createCheckout(packageId: string, email: string): Promise<string> {
|
||||
const response = await fetch(`${API_BASE_URL}/api/users/credits/checkout`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify({
|
||||
package_id: packageId,
|
||||
email: email.toLowerCase(),
|
||||
}),
|
||||
});
|
||||
const data = await handleResponse<{ checkout_url: string }>(response);
|
||||
return data.checkout_url;
|
||||
},
|
||||
|
||||
// ==========================================================================
|
||||
// Beta Tester API endpoints
|
||||
// ==========================================================================
|
||||
|
||||
/**
|
||||
* Enroll as a beta tester to receive free credits
|
||||
*/
|
||||
async enrollBetaTester(
|
||||
email: string,
|
||||
promiseText: string,
|
||||
acceptCorrectionsWork: boolean
|
||||
): Promise<BetaEnrollResponse> {
|
||||
const response = await fetch(`${API_BASE_URL}/api/users/beta/enroll`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify({
|
||||
email: email.toLowerCase(),
|
||||
promise_text: promiseText,
|
||||
accept_corrections_work: acceptCorrectionsWork,
|
||||
}),
|
||||
});
|
||||
return handleResponse(response);
|
||||
},
|
||||
};
|
||||
|
||||
// Types for credits/payment
|
||||
export interface CreditPackage {
|
||||
id: string;
|
||||
credits: number;
|
||||
price_cents: number;
|
||||
name: string;
|
||||
description: string;
|
||||
}
|
||||
|
||||
export interface BetaEnrollResponse {
|
||||
status: string;
|
||||
message: string;
|
||||
credits_granted: number;
|
||||
session_token: string | null;
|
||||
}
|
||||
|
||||
export { ApiError };
|
||||
|
||||
Generated
+69
-2
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "karaoke-gen-frontend",
|
||||
"version": "0.76.26",
|
||||
"version": "0.77.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "karaoke-gen-frontend",
|
||||
"version": "0.76.26",
|
||||
"version": "0.77.0",
|
||||
"dependencies": {
|
||||
"@hookform/resolvers": "^3.10.0",
|
||||
"@radix-ui/react-accordion": "1.2.2",
|
||||
@@ -75,6 +75,7 @@
|
||||
"concurrently": "^9.2.1",
|
||||
"jest": "^29.7.0",
|
||||
"jest-environment-jsdom": "^29.7.0",
|
||||
"mailslurp-client": "^16.0.0",
|
||||
"postcss": "^8.5",
|
||||
"tailwindcss": "^4.1.9",
|
||||
"ts-node": "^10.9.2",
|
||||
@@ -4503,6 +4504,16 @@
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/cross-fetch": {
|
||||
"version": "4.1.0",
|
||||
"resolved": "https://registry.npmjs.org/cross-fetch/-/cross-fetch-4.1.0.tgz",
|
||||
"integrity": "sha512-uKm5PU+MHTootlWEY+mZ4vvXoCn4fLQxT9dSc1sXVMSFkINTJVN8cAQROpwcKm8bJ/c7rgZVIBWzH5T78sNZZw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"node-fetch": "^2.7.0"
|
||||
}
|
||||
},
|
||||
"node_modules/cross-spawn": {
|
||||
"version": "7.0.6",
|
||||
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz",
|
||||
@@ -7092,6 +7103,16 @@
|
||||
"@jridgewell/sourcemap-codec": "^1.5.5"
|
||||
}
|
||||
},
|
||||
"node_modules/mailslurp-client": {
|
||||
"version": "16.0.0",
|
||||
"resolved": "https://registry.npmjs.org/mailslurp-client/-/mailslurp-client-16.0.0.tgz",
|
||||
"integrity": "sha512-4g3Zauq5vcHZ2HAanfLpdcXcsZhZj6ToL/hUY10YS1vHK2DGt9EEO43ms5wzLFHCMFOCsx6So1JMIER/n8rIXw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"cross-fetch": "^4.1.0"
|
||||
}
|
||||
},
|
||||
"node_modules/make-dir": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/make-dir/-/make-dir-4.0.0.tgz",
|
||||
@@ -7334,6 +7355,52 @@
|
||||
"node": "^10 || ^12 || >=14"
|
||||
}
|
||||
},
|
||||
"node_modules/node-fetch": {
|
||||
"version": "2.7.0",
|
||||
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz",
|
||||
"integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"whatwg-url": "^5.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": "4.x || >=6.0.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"encoding": "^0.1.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"encoding": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/node-fetch/node_modules/tr46": {
|
||||
"version": "0.0.3",
|
||||
"resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz",
|
||||
"integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/node-fetch/node_modules/webidl-conversions": {
|
||||
"version": "3.0.1",
|
||||
"resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz",
|
||||
"integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==",
|
||||
"dev": true,
|
||||
"license": "BSD-2-Clause"
|
||||
},
|
||||
"node_modules/node-fetch/node_modules/whatwg-url": {
|
||||
"version": "5.0.0",
|
||||
"resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz",
|
||||
"integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"tr46": "~0.0.3",
|
||||
"webidl-conversions": "^3.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/node-int64": {
|
||||
"version": "0.4.0",
|
||||
"resolved": "https://registry.npmjs.org/node-int64/-/node-int64-0.4.0.tgz",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "karaoke-gen-frontend",
|
||||
"version": "0.76.27",
|
||||
"version": "0.77.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"build": "next build",
|
||||
@@ -92,6 +92,7 @@
|
||||
"concurrently": "^9.2.1",
|
||||
"jest": "^29.7.0",
|
||||
"jest-environment-jsdom": "^29.7.0",
|
||||
"mailslurp-client": "^16.0.0",
|
||||
"postcss": "^8.5",
|
||||
"tailwindcss": "^4.1.9",
|
||||
"ts-node": "^10.9.2",
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
[tool.poetry]
|
||||
name = "karaoke-gen"
|
||||
version = "0.76.30"
|
||||
version = "0.78.0"
|
||||
description = "Generate karaoke videos with synchronized lyrics. Handles the entire process from downloading audio and lyrics to creating the final video with title screens."
|
||||
authors = ["Andrew Beveridge <andrew@beveridge.uk>"]
|
||||
license = "MIT"
|
||||
|
||||
Reference in new issue
Block a user