Every bedtime becomes a butterfly of imagination.
Amari is a production-ready Next.js application that creates personalized, AI-generated bedtime stories for families. Children pick random items, and Amari weaves them into magical stories perfect for bedtime.
- AI-Powered Story Generation: Uses OpenAI GPT-4 to create unique, engaging stories
- Interactive Story Creation: Multi-step wizard for children to input their creative ideas
- Text-to-Speech: Built-in read-aloud feature using Web Speech API
- User Authentication: Secure authentication with Clerk
- Subscription Management: Stripe integration for premium subscriptions
- Story Library: Save and organize all your created stories
- Beautiful UI: Dreamy, child-friendly design with Tailwind CSS
- Responsive Design: Works on desktop, tablet, and mobile devices
- Framework: Next.js 14 (App Router)
- Language: TypeScript
- Styling: Tailwind CSS
- Authentication: Clerk
- Database: Supabase (PostgreSQL)
- Payments: Stripe
- AI: OpenAI GPT-4
- UI Components: Radix UI + Custom Components
- Animations: Framer Motion
Before you begin, ensure you have:
- Node.js 18+ installed
- npm or yarn package manager
- Accounts set up for:
- Clone the repository
git clone <your-repo-url>
cd amair- Install dependencies
npm install- Set up environment variables
Copy .env.example to .env and fill in your credentials:
cp .env.example .envRequired environment variables:
# Clerk Authentication
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=your_clerk_publishable_key
CLERK_SECRET_KEY=your_clerk_secret_key
CLERK_WEBHOOK_SECRET=your_clerk_webhook_secret
# Supabase
NEXT_PUBLIC_SUPABASE_URL=your_supabase_url
NEXT_PUBLIC_SUPABASE_ANON_KEY=your_supabase_anon_key
SUPABASE_SERVICE_ROLE_KEY=your_supabase_service_role_key
# Stripe
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=your_stripe_publishable_key
STRIPE_SECRET_KEY=your_stripe_secret_key
STRIPE_WEBHOOK_SECRET=your_stripe_webhook_secret
NEXT_PUBLIC_STRIPE_MONTHLY_PRICE_ID=your_monthly_price_id
# OpenAI
OPENAI_API_KEY=your_openai_api_key
# App Configuration
NEXT_PUBLIC_APP_URL=http://localhost:3000- Set up Supabase Database
Run the SQL schema in your Supabase project:
# Copy the contents of supabase/schema.sql
# Paste into Supabase SQL Editor and run- Configure Webhooks
Clerk Webhook:
- Go to Clerk Dashboard β Webhooks
- Add endpoint:
https://your-domain.com/api/webhooks/clerk - Subscribe to:
user.created,user.deleted
Stripe Webhook:
- Go to Stripe Dashboard β Developers β Webhooks
- Add endpoint:
https://your-domain.com/api/webhooks/stripe - Subscribe to:
checkout.session.completed,customer.subscription.updated,customer.subscription.deleted,invoice.payment_failed
- Create Stripe Products
In Stripe Dashboard, create:
- Product: "Amari Premium"
- Price: $9.99/month (recurring)
- Copy the Price ID to
NEXT_PUBLIC_STRIPE_MONTHLY_PRICE_ID
- Run the development server
npm run devOpen http://localhost:3000 in your browser.
amair/
βββ app/ # Next.js app directory
β βββ (app)/ # Authenticated app routes
β β βββ create/ # Story creation page
β β βββ dashboard/ # User dashboard
β β βββ stories/ # Stories library
β β βββ pricing/ # Pricing page
β βββ (auth)/ # Authentication pages
β β βββ sign-in/
β β βββ sign-up/
β βββ api/ # API routes
β β βββ webhooks/ # Webhook handlers
β β βββ generate-story/ # Story generation
β β βββ create-checkout-session/
β βββ globals.css # Global styles
β βββ layout.tsx # Root layout
β βββ page.tsx # Landing page
βββ components/ # React components
β βββ ui/ # Base UI components
β βββ story/ # Story-specific components
βββ lib/ # Utility libraries
β βββ stripe/ # Stripe configuration
β βββ supabase/ # Supabase client
β βββ utils.ts # Helper functions
βββ supabase/ # Database schema
β βββ schema.sql # SQL schema
βββ middleware.ts # Clerk middleware
βββ tailwind.config.ts # Tailwind configuration
βββ package.json # Dependencies
- Step 1: Enter number of children (1-5)
- Step 2: For each child:
- Enter their name
- Choose number of items (1-5)
- Step 3: Enter random items for each child
- Step 4: Select tone and length
- Generate: AI creates a personalized story
- π Bedtime Calm: Gentle, soothing stories perfect for sleep
- π Funny: Humorous adventures that make kids giggle
- πΊοΈ Adventure: Exciting journeys with challenges to overcome
- π Mystery: Gentle mysteries with clues to discover
- Quick: 2-3 minutes (300-400 words)
- Medium: 5 minutes (600-800 words)
- Epic: 10 minutes (1200-1500 words)
- 3 stories per month
- All story tones
- Read aloud feature
- Download stories
- Unlimited stories
- All features from Free
- Save favorite stories
- Priority support
- Early access to new features
- Row Level Security (RLS) in Supabase
- Secure webhook verification
- Environment variable protection
- Clerk authentication
- HTTPS-only in production
-
Push your code to GitHub
-
Import project in Vercel:
- Go to vercel.com
- Click "New Project"
- Import your repository
-
Configure environment variables in Vercel:
- Go to Project Settings β Environment Variables
- Add all variables from
.env.example
-
Deploy!
-
Update webhook URLs:
- Update Clerk webhook to your production URL
- Update Stripe webhook to your production URL
Make sure to set all environment variables in your deployment platform:
- All Clerk keys
- All Supabase keys
- All Stripe keys
- OpenAI API key
- Set
NEXT_PUBLIC_APP_URLto your production domain
Use Stripe CLI and ngrok for local webhook testing:
# Install Stripe CLI
brew install stripe/stripe-cli/stripe
# Login
stripe login
# Forward webhooks
stripe listen --forward-to localhost:3000/api/webhooks/stripe
# Use ngrok for Clerk webhooks
ngrok http 3000- Set up proper error monitoring (Sentry)
- Add analytics (PostHog, Google Analytics)
- Implement rate limiting
- Add email notifications
- Create admin dashboard
- Add story illustrations (DALL-E integration)
- Implement daily challenge feature
- Add child profile management
- Create storybook compilation feature
- Add social sharing features
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License.
For support, email support@amari.app or open an issue in the repository.
Built with β€οΈ for magical bedtimes π¦πβ¨