A premium, subscription-driven web application combining golf performance tracking, monthly prize draws, and charitable giving. Built as a technical demonstration for real-world scaling, dynamic algorithm computation, and multi-tier authentication.
- Framework: Next.js 16 (App Router)
- Frontend: React 19, Vanilla CSS Modules (Custom Design System)
- Backend/Database: Supabase (PostgreSQL)
- Authentication: Supabase Auth (Email + Google OAuth PKCE Flow)
- Payments: Stripe Checkout & Webhooks
- Deployment: Vercel (Turbopack)
- Robust Subscription Engine: Complete SaaS lifecycle logic with plan selection (Monthly/Yearly) leveraging secure Stripe Checkout sessions. Features real-time client-side polling to resolve Stripe Webhook race conditions seamlessly.
- Algorithmic Draw Engine: Admin-controlled lottery simulator capable of generating Pure Random or Frequency-Weighted winning numbers based on global user score histories.
- Dynamic Prize Calculations: Automated 40/35/25% prize pool distribution with 5-match jackpot rollover tracking.
- Stableford Score Tracker: Rolling retention system automatically drops players' oldest scores and uses their 5 most recent rounds as their lottery ticket.
- Charity Routing: Users can assign a minimum of 10% (up to 50%) of their subscription fee to a dynamically routed charity from the live directory.
- Row-Level Security (RLS): Fully implemented in PostgreSQL to ensure standard users can only perform
SELECT,UPDATE, andINSERTon their own UUID-bound data rows. - Admin Promotion System: Utilizes
SECURITY DEFINERfunctions to prevent infinite recursion during permission bypass checks. - Webhook Synchronization: Real-time database polling eliminates frontend state desyncs during Stripe background payment processing.
- Durable Routing: Protected routes enforce hard-redirection to prevent React Suspense caching deadlocks during unauthorized access attempts.
Create a .env.local file in the root directory and configure the following:
NEXT_PUBLIC_SITE_URL=http://localhost:3000
# Supabase Configurations
NEXT_PUBLIC_SUPABASE_URL=your-supabase-url
NEXT_PUBLIC_SUPABASE_ANON_KEY=your-supabase-anon-key
SUPABASE_SERVICE_ROLE_KEY=your-service-role-key
# Stripe Configurations
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=pk_test_...
STRIPE_SECRET_KEY=sk_test_...
STRIPE_WEBHOOK_SECRET=whsec_...
STRIPE_MONTHLY_PRICE_ID=price_...
STRIPE_YEARLY_PRICE_ID=price_...Run the SQL migration scripts located in supabase/migrations/ sequentially in your Supabase SQL Editor to build the schema, initialize the seed data, and enforce strict RLS policies.
npm install
npm run devThis repository satisfies all mandatory deliverables and logic explicitly defined in the provided Product Requirements Document (PRD).
- ✅ Subscription Gateway: Direct Stripe integration, replacing any mock abstractions.
- ✅ Algorithmic Drawings: Custom weighting algorithm natively implemented.
- ✅ Resilient Edge-Cases: Graceful fallbacks for unauthenticated dashboard access and empty state metrics.