A production-ready fantasy cricket web application built with Next.js, Supabase, and Razorpay.
- Authentication - Google & Email auth via Supabase
- Premium Subscription - ₹49 one-time payment via Razorpay
- Private Leagues - Create & join leagues with invite codes
- Fantasy Team Builder - Budget-based team selection with constraints
- Live Matches - Real-time match data with caching
- Real-time Leaderboards - WebSocket-powered rankings
- League Chat - Real-time chat with meme reactions
- Points Engine - Server-side fantasy points calculation
- Dark Theme - Stunning UI with neon accents
- Mobile-first - Responsive design for all devices
- SEO Optimized - Server-side rendering, meta tags, sitemap
- Frontend: Next.js 14 (App Router), TypeScript, Tailwind CSS, Framer Motion
- Backend: Next.js API Routes, Supabase Edge Functions
- Database: Supabase PostgreSQL with Realtime
- Auth: Supabase Auth (Google + Email)
- Payments: Razorpay
- State: Zustand
- Validation: Zod
fantasy-cricket/
├── src/
│ ├── app/ # Next.js App Router
│ │ ├── (auth)/ # Auth pages (login, register)
│ │ ├── (dashboard)/ # Protected dashboard pages
│ │ └── api/ # API routes
│ ├── components/
│ │ ├── ui/ # Reusable UI components
│ │ └── features/ # Feature-specific components
│ ├── lib/
│ │ ├── supabase/ # Supabase clients
│ │ ├── razorpay/ # Payment utilities
│ │ └── cricket-api/ # Cricket data fetching
│ ├── hooks/ # Custom React hooks
│ ├── stores/ # Zustand stores
│ ├── types/ # TypeScript types
│ └── validators/ # Zod schemas
├── supabase/
│ └── migrations/ # Database migrations
└── public/ # Static assets
- Node.js 18+
- npm or yarn
- Supabase account
- Razorpay account (test mode)
cd fantasy-cricketnpm install- Create a new project at supabase.com
- Go to SQL Editor and run the migration script from
supabase/migrations/001_initial_schema.sql - Enable Google Auth in Authentication > Providers
- Copy your project URL and anon key
- Create account at razorpay.com
- Switch to Test Mode
- Copy your test API keys from Dashboard > Settings > API Keys
cp .env.example .env.localEdit .env.local:
NEXT_PUBLIC_SUPABASE_URL=https://your-project.supabase.co
NEXT_PUBLIC_SUPABASE_ANON_KEY=your-anon-key
NEXT_PUBLIC_RAZORPAY_KEY_ID=rzp_test_xxxxx
RAZORPAY_KEY_ID=rzp_test_xxxxx
RAZORPAY_KEY_SECRET=your-secret-key
CRON_SECRET=your-random-secret
NEXT_PUBLIC_APP_URL=http://localhost:3000npm run dev| Variable | Description |
|---|---|
NEXT_PUBLIC_SUPABASE_URL |
Supabase project URL |
NEXT_PUBLIC_SUPABASE_ANON_KEY |
Supabase anonymous key |
NEXT_PUBLIC_RAZORPAY_KEY_ID |
Razorpay key ID (live) |
RAZORPAY_KEY_ID |
Razorpay key ID (live) |
RAZORPAY_KEY_SECRET |
Razorpay secret key (live) |
CRON_SECRET |
Secret for cron job auth |
NEXT_PUBLIC_APP_URL |
Your production URL |
- profiles - User profiles with points and premium status
- leagues - Fantasy leagues with invite codes
- league_members - League membership junction
- fantasy_teams - User's fantasy team selections
- players - Cricket players with stats
- matches - Cricket matches
- chat_messages - League chat messages
- leaderboards - Real-time rankings
- JWT authentication with refresh tokens (Supabase)
- Row Level Security (RLS) on all tables
- Input validation with Zod
- Rate limiting via middleware
- Secure payment verification with signatures
- Server-side team locking before match start
- Go to Dashboard → Create League
- Enter league name and settings
- Share the invite code with friends
- Get invite code from friend
- Go to Dashboard → Join League
- Enter the 6-character code
- Select a match
- Pick 11 players within 100 credits
- Choose Captain (2x points) and Vice Captain (1.5x)
- Save before team locks
Use Razorpay test mode with these cards:
- Success: 4111 1111 1111 1111
- Failure: 4000 0000 0000 0002
Made with 🏏 in India