A full-stack implementation of the Rewards page feature for the Flowva Hub platform. This project strictly follows the requirement to use Supabase for all backend logic (Auth, Database, Storage).
Live URL: https://flowva-rewards-sigma.vercel.app
- Frontend: React 18 (Next.js 16 App Router), TypeScript, TailwindCSS, Shadcn UI
- Backend: Supabase (PostgreSQL, Authentication, Storage, Edge Functions)
- State Management: React Server Components (RSC) + Server Actions + Optimistic UI
- Deployment: Vercel
- Data Fetching: All initial data (points balance, streak, user profile) is fetched server side in
page.tsx. This ensures fast First Contentful Paint (FCP) and secure data access without exposing API keys. - Interactivity: Client components (
GoogleAuthButton,EarnTabContent) handle user interactions. - Optimistic UI: When a user claims a streak or reward, the UI updates instantly via local state while the Server Action processes the request in the background. If the request fails, the UI reverts.
- Authentication:
- Uses Supabase Auth with Google OAuth for secure sign-in.
- Middleware protects private routes (
/dashboard) and handles session refreshing.
- Database:
- Row Level Security (RLS) policies are enforced to ensure users can only access their own data.
profilestable acts as a public extension of theauth.userstable to store custom fields likepoints_balanceandcurrent_streak.
- Storage:
- "Reclaim Proof" screenshots are uploaded to a private Supabase Storage bucket (
proofs) accessible only by the uploader and admins.
- "Reclaim Proof" screenshots are uploaded to a private Supabase Storage bucket (
- Type Safety: Fully typed with TypeScript interfaces matching the Database Schema.
- Modularity: Features are split into small, single-responsibility components (e.g.,
DailyStreakCard,SpotlightCard). - Server Actions: No API routes were used; all mutations happen via Next.js Server Actions for type safety and reduced boilerplate.
-
Clone the repository:
git clone https://github.com/Daniel4000-dev/flowva-rewards cd flowva-rewards -
Install dependencies:
npm install
-
Environment Variables: Create a
.env.localfile in the root directory:NEXT_PUBLIC_SUPABASE_URL=your_supabase_url NEXT_PUBLIC_SUPABASE_ANON_KEY=your_supabase_anon_key NEXT_PUBLIC_SITE_URL=http://localhost:3000
-
Database Setup:
- Run the SQL script provided in
schema.sql(if included) or manually create theprofiles,rewards, andclaim_requeststables in Supabase. - Enable Google Auth Provider in Supabase.
- Run the SQL script provided in
-
Run Locally:
npm run dev
- Spotlight Bonus: I assumed the "Claim" button for the Spotlight feature should instantly consistently award points for this demo, triggering an optimized RPC call (
increment_points) for concurrency safety. - Stacks Feature: Since I did not have access to the real "Stack" infrastructure, I hardcoded the
checkStackStatusto returnfalseto demonstrate the "Empty State" modal as requested in the web design. - Streak Logic: The daily streak logic allows for a 48-hour window (grace period) to keep the streak alive if a user misses one day, which is a common gamification pattern to prevent user churn.