Fullstack Next.js App for Aaron Curtis Yoga
This app is designed to help current and future yoga students:
- Learn about Aaron Curtis
- Find weekly schedules
- Sign up for the newsletter
- Register for events (work in progress)
cp .env.example .envFor complete environment variable documentation, see Environment Variables Reference Guide
npm run devto start the development servernpm run buildfor production buildnpm run lintto run ESLintnpm run lint:fixto fix linting errors
The application automatically syncs yoga classes from two sources:
- Bright Bear Yoga - Aaron's public class schedule
- DC Bouldering Project - Aaron's teaching schedule via ZoomShift
Architecture:
- All Environments: Exclusively uses Browserless.io cloud browser service for consistent and reliable web scraping
- Required Token: The
BROWSERLESS_API_TOKENenvironment variable must be set for the application to function
Setup:
- Sign up for free Browserless account at https://account.browserless.io/signup/email?plan=free (1,000 pages/month free)
- Add
BROWSERLESS_API_TOKENto your environment variables (both local.envand Vercel) - The crawler will fail with an error if this token is not present - this is by design to ensure consistent behavior
Testing the Crawlers:
Test individual crawlers (no database update):
-
Bright Bear only:
curl http://localhost:3000/api/test-sync/simple- Returns scraped Bright Bear classes as JSON without saving to database
-
DCBP only:
curl http://localhost:3000/api/test-sync/dcbp- Returns scraped DCBP classes from ZoomShift as JSON without saving to database
- Requires
ZOOMSHIFT_EMAILandZOOMSHIFT_PASSWORDenvironment variables
-
Both crawlers:
curl http://localhost:3000/api/test-sync/both- Tests both Bright Bear and DCBP crawlers simultaneously
- Returns results from both sources with success/failure status for each
Test full sync with database:
- Start the development server:
npm run dev - Navigate to:
http://localhost:3000/api/test-sync- Or use curl:
curl http://localhost:3000/api/test-sync - This scrapes classes AND saves them to the database
- Or use curl:
Manual sync to database (POST):
- Start the development server:
npm run dev - Make a POST request:
curl -X POST http://localhost:3000/api/dev-sync - Check
http://localhost:3000to see the updated events
Test browser connection (Browserless):
- Start the development server:
npm run dev - Navigate to:
http://localhost:3000/api/test-sync/playwright-debug- Tests whether Browserless connection is working correctly
- Will fail if
BROWSERLESS_API_TOKENis not set (this is intentional)
Automated Sync:
- A Vercel cron job runs daily at 8:00 AM UTC to sync events from both sources automatically
- Configured in
vercel.jsonat path/api/cron/sync-eventswith 120s timeout for both crawlers - To test the cron endpoint locally:
Note: Replace
curl -H "Authorization: Bearer YOUR_CRON_SECRET" http://localhost:3000/api/cron/sync-eventsYOUR_CRON_SECRETwith the value from your.envfile
Vercel Pro Optimization:
- Function timeout set to 180 seconds for combined sync operations (includes retries)
- Crawlers optimized for Vercel Pro limits (300s max duration)
- Rate limit protection: 3 retries with exponential backoff (5s, 10s, 20s delays)
- Sequential execution: Cron jobs run crawlers one at a time to avoid concurrent connection limits
- Fallback handling: If one crawler fails, the other continues independently
- Browserless.io ensures consistent browser environment across all deployments
-
Next.js (docs) (TypeScript)
-
HeroUI (docs)
-
React Hook Form (docs)
-
Vercel Postgres (docs)
-
Vercel Blob Storage (docs)
Third-Party APIs
-
Clerk (docs)
-
Stripe (docs)
-
Mailchimp Marketing API (docs)
- Newsletter: Stay up-to-date with upcoming events by signing up for the newsletter.
- Authentication: Role-Based Access Control (RBAC) powered by Clerk.
- Events Management: Admins can create, read, update, and delete events. End users can view events.
- Search & Filter: Users can search and filter events.
- Checkout and Payment: Secure payments powered by Stripe.
You can use Prisma Studio to view and manage your Vercel Postgres database schema and data. Depending on the environment, use one of the following commands:
-
Local Development Database:
npx prisma studio
Opens Prisma Studio using your local
.envconfiguration, connecting to your development database. -
Production Database:
dotenv -e .env.production -- npx prisma studio
Opens Prisma Studio using the
.env.productionfile, connecting to your production database.
Tip: Ensure each environment file has the correct
DATABASE_URLfor seamless connections.
This application includes comprehensive analytics and user behavior tracking powered by Vercel Analytics (free tier).
Vercel Dashboard:
- Go to vercel.com/dashboard
- Select your project
- Click "Analytics" in the left sidebar
- View real-time data including:
- Page views and unique visitors
- Top pages and referrers
- Geographic data
- Custom events (see tracking details below)
Analytics Tab Features:
- Overview: Traffic summary, page views, unique visitors
- Pages: Most visited pages, bounce rates
- Referrers: Traffic sources (direct, social, search, etc.)
- Events: Custom click tracking and conversions
- Audiences: User behavior patterns
Comprehensive click tracking across all interactive elements:
- Logo clicks (home navigation)
- Desktop/mobile navigation menu interactions
- User dropdown toggles and admin link clicks
- Authentication actions (sign in/out from various sources)
- Hamburger menu open/close (mobile)
- Event signup button clicks with full event context:
- Event ID, title, category
- Free vs paid events
- External vs internal registration
- Source (mobile vs desktop card)
- Admin event management (edit/delete clicks)
- Search queries and terms
- Category filter selections
- Pagination (next/previous page navigation)
- Calendar subscription interactions (Google Calendar, iCal)
- Session count adjustments (increment/decrement/presets)
- Session type selections
- Purchase button clicks
- "Sign in to purchase" conversions
- Social media clicks (YouTube, Spotify, Instagram)
- Footer social link interactions
- Theme changes (light/dark/system)
Created utility functions for enhanced tracking:
/app/_lib/analytics.ts - Helper functions for:
- Conversion tracking with values
- E-commerce events
- Form completion tracking
- Error tracking
- Page engagement metrics
Custom Hooks Created:
/app/_hooks/usePageTracking.ts - Automatic page analytics:
- Page view tracking
- Time on page measurement
- Scroll depth tracking
- Session duration
/app/_hooks/useFormAnalytics.ts - Form behavior tracking:
- Form start/completion/abandonment
- Field interaction tracking
- Validation error tracking
- Form completion time
/app/_hooks/useABTest.ts - Simple A/B testing:
- Variant assignment based on user ID
- Conversion tracking per variant
- Weighted distribution support
/app/_components/ErrorBoundary.tsx - Error tracking:
- JavaScript error capture
- React error boundary tracking
- User-friendly error display
High-Value Conversions:
event_signup- Event registrationsprivate_session_booking- Private session purchasescalendar_subscription- Calendar integrationsnewsletter_signup- Email subscriptions
User Engagement:
navigation- Site navigation patternssearch- Content discovery behaviorfiltering- Event filtering usagesocial_media- External link engagement
Technical Insights:
page_view/page_exit- Traffic flowerror- Application issuesform_completion- Form performance
- All tracking uses Vercel's free Analytics tier
- No personal data is collected (GDPR friendly)
- Click tracking includes contextual metadata
- Error tracking helps identify technical issues
- A/B testing setup for future optimization
- Analytics data helps optimize user experience and conversion funnels
- Monitor Weekly: Check analytics weekly for trends
- Focus on Conversions: Track event signups and private session bookings
- Optimize High-Traffic Pages: Use page analytics to improve popular content
- Monitor Errors: Address technical issues quickly
- Test Changes: Use A/B testing hook for major UI changes
This application uses Playwright for end-to-end testing.
-
Run Tests Locally: To execute all tests from the terminal, use the following command:
npx playwright testNote: The development server must be running prior to executing this command.
-
CI Smoke Tests: GitHub Actions run a focused smoke test on every push to
devand on PRs tomain. The smoke test verifies:- The landing page loads without server errors (no 500s)
- The page title is correct
- At least one event is displayed
This lightweight test runs in ~15-25 seconds and catches critical runtime errors before they reach production. A separate workflow runs the same smoke test after production deployments to verify the live site.
-
Full Test Suite: Additional tests for header navigation, footer, and other components are available locally but not run in CI to keep deployment times fast.
-
IDE Recommendation: Regardless of your preferred IDE, it is recommended to leverage the Playwright Test extension for Visual Studio Code. This extension provides a comprehensive set of tools for efficiently running and monitoring tests.
- Instagram: @aaroncurtisyoga
- Email: aaroncurtisyoga@gmail.com