Skip to content

myloadcircle/mymotivationai

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

myMotivationAI - QR Code Landing Page Implementation

Overview

This project implements a QR code landing page for myMotivationAI that allows users to bypass app stores and directly install the Progressive Web App (PWA). The implementation follows the specifications outlined in the redesign plan.

Features Implemented

1. QR Code Landing Page (/qr-landing)

  • Mobile-optimized landing page for QR code scanning
  • Dynamic QR code parameter tracking (UTM sources)
  • Device detection and platform-specific installation instructions
  • Value proposition and app preview sections
  • Trust signals and social proof elements

2. PWA Installation Flow

  • Automatic install prompts for supported browsers (Chrome, Edge, Firefox)
  • iOS-specific manual installation guide with step-by-step instructions
  • Installation success/failure tracking
  • Service worker for offline functionality
  • Web App Manifest for PWA metadata

3. Analytics & Tracking

  • Comprehensive event tracking for QR scans, installs, and conversions
  • Conversion funnel tracking from scan to install to value
  • Device and browser detection
  • Offline event queuing with background sync
  • Real-time analytics dashboard (API endpoint)

4. Technical Implementation

  • Next.js 14 with TypeScript and Tailwind CSS
  • PWA capabilities via next-pwa
  • Service worker for offline support
  • Responsive mobile-first design
  • Performance optimized for fast loading (< 3 seconds)

Project Structure

mymotivationAi/
├── app/
│   ├── qr-landing/
│   │   └── page.tsx          # Main QR code landing page
│   ├── api/
│   │   └── analytics/
│   │       └── route.ts      # Analytics API endpoint
│   ├── layout.tsx            # Root layout with PWA metadata
│   └── globals.css           # Global styles
├── components/
│   ├── QRCodeInstallButton.tsx  # PWA install button component
│   ├── IOSInstallGuide.tsx      # iOS installation guide
│   └── AnalyticsTracker.tsx     # Analytics tracking component
├── lib/
│   └── analytics.ts          # Analytics library
├── public/
│   ├── manifest.json         # PWA manifest
│   ├── sw.js                 # Service worker
│   └── icons/                # App icons (placeholder)
├── plans/                    # Project documentation
└── package.json              # Dependencies and scripts

Getting Started

Prerequisites

  • Node.js 18+ and npm/yarn/pnpm

Installation

cd mymotivationAi
npm install

Development

npm run dev

Open http://localhost:3000/qr-landing to view the QR code landing page.

Production Build

npm run build
npm start

QR Code Integration

Generating QR Codes

QR codes should point to:

https://yourdomain.com/qr-landing?utm_source=SOURCE&utm_medium=qr-code&utm_campaign=CAMPAIGN

Tracking Parameters

  • utm_source: Source of QR code (e.g., "printed-flyer", "social-media")
  • utm_medium: Always "qr-code"
  • utm_campaign: Campaign identifier
  • utm_content: Specific QR code variant
  • utm_term: Optional keyword

Example QR Code URL

Stripe Payment Integration (Phase 2)

Overview

The Stripe payment integration enables subscription-based monetization for myMotivationAI with three pricing tiers: Free, Basic, and Pro. The implementation includes:

  • Secure checkout flow with Stripe Checkout
  • Customer portal for subscription management
  • Webhook handling for payment events
  • User subscription status tracking
  • Pricing page with tier comparison

Features Implemented

1. Subscription Management

  • Three pricing tiers: Free, Basic, and Pro
  • Free tier includes: Daily motivation quotes & basic goal tracking
  • Secure payment processing via Stripe Checkout for paid plans
  • Automatic subscription renewal for paid plans
  • Free trial support (14 days) for paid plans
  • Prorated upgrades/downgrades

2. Customer Experience

  • Clean, responsive pricing page (/pricing)
  • Transparent feature comparison
  • Secure customer portal for subscription management
  • Email notifications for payment events
  • Mobile-optimized checkout flow

3. Admin & Analytics

  • Webhook handling for real-time subscription updates
  • User subscription status tracking
  • Payment failure handling
  • Revenue analytics integration
  • Churn prevention features

Setup Instructions

1. Environment Configuration

# Copy environment template
cp .env.example .env.local

# Edit .env.local with your Stripe keys
# Get keys from: https://dashboard.stripe.com/test/apikeys
STRIPE_SECRET_KEY=sk_test_XXXXXXXXXXXXXXXX
STRIPE_PUBLISHABLE_KEY=pk_test_XXXXXXXXXXXXXXXX
STRIPE_WEBHOOK_SECRET=whsec_XXXXXXXXXXXXXXXX

2. Create Stripe Products & Prices

# Run the setup script (requires Stripe CLI or manual setup)
node scripts/setup-stripe.js

# Or manually create in Stripe Dashboard:
# 1. Create products: Basic, Pro, Enterprise
# 2. Create monthly/yearly prices for each
# 3. Update .env.local with price IDs

3. Configure Webhooks (Development)

# Install Stripe CLI: https://stripe.com/docs/stripe-cli
stripe login
stripe listen --forward-to localhost:3000/api/webhooks/stripe

# Copy the webhook secret to .env.local
STRIPE_WEBHOOK_SECRET=whsec_XXXXXXXXXXXXXXXX

4. Test the Payment Flow

  1. Start development server: npm run dev
  2. Visit: http://localhost:3000/pricing
  3. Select a plan and click "Get Started"
  4. Use Stripe test card: 4242 4242 4242 4242
  5. Complete checkout to test the full flow

Testing Cards

Use these test cards in Stripe Checkout:

  • Success: 4242 4242 4242 4242
  • Requires authentication: 4000 0025 0000 3155
  • Decline: 4000 0000 0000 0002
  • 3D Secure: 4000 0027 6000 3184

API Endpoints

  • POST /api/checkout - Create checkout session
  • POST /api/customer-portal - Create customer portal session
  • POST /api/webhooks/stripe - Handle Stripe webhooks

Project Structure Updates

mymotivationAi/
├── app/
│   ├── pricing/                 # Pricing page
│   │   └── page.tsx
│   ├── api/
│   │   ├── checkout/            # Checkout API
│   │   │   └── route.ts
│   │   ├── customer-portal/     # Customer portal API
│   │   │   └── route.ts
│   │   └── webhooks/stripe/     # Webhook handler
│   │       └── route.ts
├── components/
│   └── PricingCard.tsx          # Pricing card component
├── lib/
│   ├── stripe.ts               # Stripe configuration & utilities
│   └── user-context.tsx        # User subscription context
└── scripts/
    └── setup-stripe.js         # Stripe setup script

Next Steps for Production

  1. Update environment variables with live Stripe keys
  2. Configure webhooks in Stripe Dashboard for production
  3. Set up database for user subscription persistence
  4. Implement email notifications for payment events
  5. Add analytics tracking for conversion funnel
  6. Test with real payment methods before launch

Security Considerations

  • Never expose Stripe secret keys in client-side code
  • Validate webhook signatures to prevent fraud
  • Implement rate limiting on API endpoints
  • Use HTTPS in production
  • Regularly audit subscription statuses
  • Monitor failed payment attempts
https://mymotivationai.com/qr-landing?utm_source=conference-badge&utm_medium=qr-code&utm_campaign=tech-conference-2024&utm_content=day1-variant-a

Analytics Dashboard

Access analytics data at:

GET /api/analytics

Example response:

{
  "total_events": 1250,
  "event_types": {
    "qr_scan_detected": 500,
    "landing_page_view": 450,
    "install_initiated": 200,
    "install_successful": 150,
    "install_failed": 50
  },
  "qr_sources": {
    "printed-flyer": 300,
    "social-media": 150,
    "conference-badge": 50
  },
  "device_types": {
    "mobile": 400,
    "desktop": 50
  }
}

PWA Features

Installation

  • Android/Chrome: Automatic install prompt after user engagement
  • iOS/Safari: Manual "Add to Home Screen" via share menu
  • Other browsers: Platform-specific installation methods

Offline Support

  • Core landing page works offline
  • Service worker caches essential assets
  • Analytics events queued for sync when online

App Features

  • Standalone app experience (no browser UI)
  • Home screen icon with branding
  • Push notification support (configured but not implemented)
  • Background sync for analytics

Performance Metrics

Target Metrics

  • First Contentful Paint: < 1.5 seconds
  • Time to Interactive: < 3 seconds
  • Largest Contentful Paint: < 2.5 seconds
  • Cumulative Layout Shift: < 0.1

Optimization Strategies

  • Image optimization and lazy loading
  • Code splitting and tree shaking
  • Service worker caching
  • CDN distribution for static assets

Testing

Manual Testing Checklist

  1. QR Code Scanning: Test with different QR code scanners
  2. Device Compatibility: Test on iOS, Android, desktop
  3. Installation Flow: Verify install prompts work correctly
  4. Analytics Tracking: Confirm events are being captured
  5. Offline Functionality: Test with network disabled
  6. Performance: Verify loading times meet targets

Automated Testing (To Be Implemented)

  • Unit tests for components
  • Integration tests for API endpoints
  • E2E tests for user flows
  • Performance regression tests

Deployment

Recommended Hosting

  • Frontend: Vercel (optimized for Next.js)
  • Backend: Railway/Render (for analytics API)
  • Database: PostgreSQL (for analytics storage)
  • CDN: Vercel Edge Network

Environment Variables

NEXT_PUBLIC_ANALYTICS_ENDPOINT=/api/analytics
NEXT_PUBLIC_SITE_URL=https://mymotivationai.com
DATABASE_URL=postgresql://...

Success Metrics

Primary KPIs

  1. Scan to Install Rate: > 40% of QR scanners install the app
  2. Install to Launch Rate: > 80% of installs launch the app
  3. Time to Value: < 60 seconds from scan to first value experience
  4. Conversion to Paid: > 5% of QR installs convert to paid within 30 days

Secondary Metrics

  • Platform distribution (iOS vs Android)
  • Campaign performance by QR source
  • User retention (Day 1, Day 7, Day 30)
  • Error rates and troubleshooting frequency

Next Steps

Phase 1: Launch Preparation

  1. Generate initial QR codes for marketing materials
  2. Set up production analytics dashboard
  3. Conduct user testing with target audience
  4. Optimize based on initial feedback

Phase 2: Scale & Optimization

  1. Implement A/B testing framework
  2. Add multi-language support
  3. Integrate with marketing automation
  4. Expand QR code placement strategies

Phase 3: Advanced Features

  1. Implement push notifications for re-engagement
  2. Add social sharing capabilities
  3. Create QR code management dashboard
  4. Integrate with CRM for lead tracking

Support & Documentation

For additional documentation, see the plans/ directory:

  • qr_code_landing_page_specifications.md - Detailed technical specifications
  • pwa_installation_flow_specification.md - PWA implementation details
  • qr_code_strategy_summary.md - Overall strategy and implementation summary

License

Proprietary - All rights reserved by myMotivationAI

About

MotivationAI is a behavioural‑intelligence engine that delivers daily insights, predictions, and adaptive motivation through a fast, privacy‑first architecture. Built with Supabase, NextAuth, Stripe, and Gemini for deterministic, production‑ready performance.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages