Skip to content

Repository files navigation

GolfStake ⛳

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.

🚀 Tech Stack

  • 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)

✨ Core Features

  1. 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.
  2. Algorithmic Draw Engine: Admin-controlled lottery simulator capable of generating Pure Random or Frequency-Weighted winning numbers based on global user score histories.
  3. Dynamic Prize Calculations: Automated 40/35/25% prize pool distribution with 5-match jackpot rollover tracking.
  4. Stableford Score Tracker: Rolling retention system automatically drops players' oldest scores and uses their 5 most recent rounds as their lottery ticket.
  5. 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.

🔒 Security & Architecture

  • Row-Level Security (RLS): Fully implemented in PostgreSQL to ensure standard users can only perform SELECT, UPDATE, and INSERT on their own UUID-bound data rows.
  • Admin Promotion System: Utilizes SECURITY DEFINER functions 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.

🛠️ Local Development

1. Environment Setup

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_...

2. Database Setup

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.

3. Start the Server

npm install
npm run dev

📋 Evaluation Notes (Digital Heroes)

This 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.

About

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages