A modern, responsive rewards and gamification platform built with React, TypeScript, and Supabase. Users can earn points through daily check-ins, referrals, and engagement, then redeem them for rewards.
Live URL: https://flowva-reward.vercel.app/
- Authentication System: Secure sign-up/sign-in with Supabase Auth
- Points & Rewards: Earn points through various activities and redeem for rewards
- Daily Check-ins: Streak tracking with calendar visualization
- Referral System: Share referral codes and earn points
- Responsive Design: Fully optimized for mobile, tablet, and desktop
- Real-time Updates: Live data synchronization with Supabase
- Frontend: React 18 + TypeScript + Vite
- Styling: Tailwind CSS
- Backend: Supabase (PostgreSQL + Auth)
- Icons: Lucide React
- Deployment: Vercel
Before you begin, ensure you have:
- Node.js 18+ and npm/yarn installed
- A Supabase account (free tier works)
- Git installed on your machine
git clone https://github.com/Tallest18/FlowvaReward.git
cd FlowvaRewardnpm install
# or
yarn install- Go to supabase.com and create a new project
- Wait for the project to finish setting up (2-3 minutes)
- In your Supabase dashboard, go to the SQL Editor
- Copy and paste the following schema:
-- Create user_profiles table
CREATE TABLE user_profiles (
id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
user_id UUID REFERENCES auth.users(id) ON DELETE CASCADE UNIQUE NOT NULL,
points_balance INTEGER DEFAULT 0,
current_streak INTEGER DEFAULT 0,
longest_streak INTEGER DEFAULT 0,
last_check_in TIMESTAMP WITH TIME ZONE,
created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
updated_at TIMESTAMP WITH TIME ZONE DEFAULT NOW()
);
-- Create check_ins table
CREATE TABLE check_ins (
id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
user_id UUID REFERENCES auth.users(id) ON DELETE CASCADE NOT NULL,
check_in_date DATE NOT NULL,
points_earned INTEGER DEFAULT 5,
created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
UNIQUE(user_id, check_in_date)
);
-- Create rewards table
CREATE TABLE rewards (
id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
name TEXT NOT NULL,
description TEXT,
points_required INTEGER NOT NULL,
available BOOLEAN DEFAULT true,
image_url TEXT,
created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW()
);
-- Create referrals table
CREATE TABLE referrals (
id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
referrer_id UUID REFERENCES auth.users(id) ON DELETE CASCADE NOT NULL,
referred_user_id UUID REFERENCES auth.users(id) ON DELETE CASCADE,
referral_code TEXT NOT NULL,
status TEXT DEFAULT 'pending',
points_earned INTEGER DEFAULT 0,
created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW()
);
-- Enable Row Level Security
ALTER TABLE user_profiles ENABLE ROW LEVEL SECURITY;
ALTER TABLE check_ins ENABLE ROW LEVEL SECURITY;
ALTER TABLE rewards ENABLE ROW LEVEL SECURITY;
ALTER TABLE referrals ENABLE ROW LEVEL SECURITY;
-- Create RLS Policies
-- user_profiles policies
CREATE POLICY "Users can view own profile" ON user_profiles
FOR SELECT USING (auth.uid() = user_id);
CREATE POLICY "Users can insert own profile" ON user_profiles
FOR INSERT WITH CHECK (auth.uid() = user_id);
CREATE POLICY "Users can update own profile" ON user_profiles
FOR UPDATE USING (auth.uid() = user_id);
-- check_ins policies
CREATE POLICY "Users can view own check-ins" ON check_ins
FOR SELECT USING (auth.uid() = user_id);
CREATE POLICY "Users can insert own check-ins" ON check_ins
FOR INSERT WITH CHECK (auth.uid() = user_id);
-- rewards policies
CREATE POLICY "Anyone can view available rewards" ON rewards
FOR SELECT USING (available = true);
-- referrals policies
CREATE POLICY "Users can view own referrals" ON referrals
FOR SELECT USING (auth.uid() = referrer_id);
CREATE POLICY "Users can create referrals" ON referrals
FOR INSERT WITH CHECK (auth.uid() = referrer_id);
-- Create indexes for better performance
CREATE INDEX idx_user_profiles_user_id ON user_profiles(user_id);
CREATE INDEX idx_check_ins_user_id ON check_ins(user_id);
CREATE INDEX idx_check_ins_date ON check_ins(check_in_date);
CREATE INDEX idx_referrals_referrer_id ON referrals(referrer_id);
-- Insert sample rewards
INSERT INTO rewards (name, description, points_required, available) VALUES
('$5 Amazon Gift Card', 'Redeem for a $5 Amazon gift card', 500, true),
('$10 Starbucks Card', 'Enjoy your favorite coffee on us', 1000, true),
('Premium Feature Access', 'Unlock premium features for 1 month', 750, true),
('$25 Gift Card', 'Choose from multiple retailers', 2500, true);- Click "Run" to execute the schema
- In your Supabase dashboard, go to Settings > API
- Copy your:
- Project URL (looks like:
https://xxxxxxxxxxxxx.supabase.co) - Anon/Public Key (starts with
eyJ...)
- Project URL (looks like:
Create a .env file in the root directory:
VITE_SUPABASE_URL=your_supabase_project_url
VITE_SUPABASE_ANON_KEY=your_supabase_anon_keyImportant: Add .env to your .gitignore file to keep credentials secure!
npm run dev
# or
yarn devThe application will be available at http://localhost:5173
-
Install Vercel CLI (optional)
npm i -g vercel
-
Push to GitHub
git add . git commit -m "Initial commit" git branch -M main git remote add origin https://github.com/YOUR_USERNAME/flowva-rewards-hub.git git push -u origin main
-
Deploy via Vercel Dashboard
- Go to vercel.com
- Click "New Project"
- Import your GitHub repository
- Add environment variables:
VITE_SUPABASE_URLVITE_SUPABASE_ANON_KEY
- Click "Deploy"
The application can be deployed to any static hosting service that supports Vite/React:
- GitHub Pages
- Cloudflare Pages
- Railway
- Render
- Sign Up: Create an account with email/password
- Daily Check-in: Click the check-in button to earn 5 points daily
- Build Streaks: Check in consecutively to build your streak
- Refer Friends: Share your referral code to earn bonus points
- Redeem Rewards: Use your points to claim rewards
# Development
npm run dev
# Build for production
npm run build
# Preview production build
npm run preview
# Lint code
npm run lintflowva-rewards-hub/
โโโ src/
โ โโโ components/ # React components
โ โ โโโ AuthForm.tsx
โ โ โโโ Sidebar.tsx
โ โ โโโ PointsBalance.tsx
โ โ โโโ StreakCalendar.tsx
โ โ โโโ RewardCard.tsx
โ โ โโโ ReferralSection.tsx
โ โโโ lib/
โ โ โโโ supabase.ts # Supabase client configuration
โ โโโ types.ts # TypeScript type definitions
โ โโโ App.tsx # Main application component
โ โโโ main.tsx # Application entry point
โโโ public/ # Static assets
โโโ .env # Environment variables (not in git)
โโโ package.json
โโโ tsconfig.json
โโโ vite.config.ts
โโโ README.md
- Environment variables are never committed to Git
- Row Level Security (RLS) is enabled on all Supabase tables
- Users can only access their own data
- Authentication is handled securely through Supabase Auth
-
Email Verification: Email confirmation is disabled for faster testing. In production, you should enable email verification in Supabase Auth settings.
-
Point Values: Fixed point values are hardcoded:
- Daily check-in: 5 points
- Referral completion: 50 points (configurable)
- These can be made dynamic by adding a configuration table
-
Reward Distribution: The app shows a success message but doesn't actually send rewards. In production, you'd integrate with:
- Email service (SendGrid, Mailgun)
- Gift card API providers
- Payment processing
-
Referral Tracking: Simplified referral system using user ID prefixes. Production should use:
- Unique referral codes
- Analytics tracking
- Fraud prevention
-
Responsive Breakpoints: Using Tailwind's default breakpoints:
- Mobile: < 640px
- Tablet: 640px - 1024px
- Desktop: > 1024px
- Choice: Using React useState instead of Redux/Zustand
- Why: Simpler setup for this scope, fewer dependencies
- Trade-off: May need refactoring if state complexity grows
- Choice: Denormalized some data (e.g., points_balance in user_profiles)
- Why: Faster queries, reduced joins
- Trade-off: Need to keep balances in sync, potential inconsistency
- Choice: Manual refetch instead of Supabase realtime subscriptions
- Why: Simpler implementation, lower complexity
- Trade-off: Not truly real-time, requires page refresh for some updates
- Choice: Simple error messages shown in UI
- Why: Quick implementation, good for MVP
- Trade-off: No error logging service, harder to debug production issues
- Choice: CSS-only responsive design without separate mobile views
- Why: Maintainability, single codebase
- Trade-off: Some compromises on mobile UX vs native apps
- Choice: No caching layer (direct API calls)
- Why: Simpler architecture, always fresh data
- Trade-off: More API calls, higher latency
- Push notifications for streak reminders
- Social sharing previews (Open Graph)
- Analytics dashboard
- Admin panel for reward management
- Gamification: badges, leaderboards
- Multi-language support
- Dark mode
- Progressive Web App (PWA) support
- Email notifications
- Integration with payment providers
- Make sure you ran the SQL schema in Supabase
- Check that all tables were created successfully
- Verify RLS policies are created
- Check that you're authenticated
- Ensure user_id matches auth.uid()
- Clear node_modules and reinstall:
rm -rf node_modules && npm install - Check Node version:
node -v(should be 18+)
- Verify environment variables are set correctly
- Check Supabase project status
- Ensure API keys are correct and not expired
MIT License - feel free to use this project for learning or commercial purposes.
Contributions are welcome! Please feel free to submit a Pull Request.
For questions or feedback, please open an issue on GitHub
Built with โค๏ธ using React, TypeScript, and Supabase