AI-powered platform that discovers eligible government welfare schemes for Indian citizens.
Upload your ID → Verify your identity → Get personalized benefit recommendations — in minutes.
- Face Verification — 3-angle selfie capture (front, left, right) for identity verification
- Smart Recommendations — Rule-based eligibility scoring matches users to welfare schemes
- Admin Panel — Manage schemes, view user profiles, monitor applications
- 10+ Seeded Schemes — National and state-level schemes (PM-KISAN, Ayushman Bharat, PM Awas, etc.)
| Layer | Technology |
|---|---|
| Framework | Next.js 16 (App Router, Turbopack) |
| Language | TypeScript 5.9 |
| UI | shadcn/ui + Tailwind CSS 4 + Framer Motion |
| Auth & DB | Supabase (Auth, PostgreSQL, Storage, RLS) |
| Camera | react-webcam |
| Package Manager | pnpm |
- Node.js 18+
- pnpm (
npm install -g pnpm) - Supabase project
- Google AI Studio API key
git clone <repo-url> CitizenScheme
cd CitizenScheme
pnpm installCopy .env.example to .env.local and fill in your values:
cp .env.example .env.localRequired variables:
| Variable | Description |
|---|---|
NEXT_PUBLIC_SUPABASE_URL |
Your Supabase project URL |
NEXT_PUBLIC_SUPABASE_ANON_KEY |
Supabase anonymous/public key |
SUPABASE_SERVICE_ROLE_KEY |
Supabase service role key (server-side only) |
GEMINI_API_KEY |
Google Gemini API key |
Run the migration SQL files in order against your Supabase project:
# Via Supabase Dashboard → SQL Editor, run each file in order:
supabase/migrations/001_create_tables.sql
supabase/migrations/002_rls_policies.sql
supabase/migrations/003_storage_buckets.sql
supabase/migrations/004_seed_schemes.sqlOr with the Supabase CLI:
supabase db push- Go to Supabase Dashboard → Authentication → Providers
- Enable Google provider
- Add your Google OAuth client ID and secret
- Set redirect URL to:
http://localhost:3000/api/auth/callback
After signing in for the first time, run this SQL in Supabase SQL Editor:
INSERT INTO admin_users (id, role) VALUES ('<your-user-uuid>', 'super_admin');pnpm devOpen http://localhost:3000.
src/
├── app/
│ ├── page.tsx # Landing page
│ ├── layout.tsx # Root layout (Inter font, Sonner)
│ ├── globals.css # Theme & Tailwind config
│ ├── login/page.tsx # Google OAuth login
│ ├── onboarding/page.tsx # 4-step onboarding wizard
│ ├── home/page.tsx # Scheme recommendations
│ ├── scheme/[slug]/page.tsx # Scheme detail + apply
│ ├── admin/
│ │ ├── layout.tsx # Admin sidebar layout
│ │ ├── page.tsx # Dashboard stats
│ │ ├── users/page.tsx # User management
│ │ └── schemes/
│ │ ├── page.tsx # Scheme list + deactivate
│ │ └── new/page.tsx # Create/edit scheme form
│ └── api/
│ ├── auth/callback/route.ts # OAuth callback handler
│ ├── ocr/route.ts # Gemini OCR processing
│ ├── upload/faces/route.ts # Face image upload
│ ├── profile/complete/route.ts # Profile completion
│ ├── schemes/
│ │ ├── route.ts # List active schemes
│ │ └── recommend/route.ts # Personalized recommendations
│ ├── applications/route.ts # Apply + list applications
│ └── admin/
│ ├── schemes/route.ts # Admin CRUD for schemes
│ └── users/route.ts # Admin: list all users
├── components/
│ ├── ui/ # shadcn/ui components (15)
│ └── verification/
│ └── FaceCapture.tsx # Webcam face capture
├── lib/
│ ├── types.ts # TypeScript interfaces
│ ├── utils.ts # cn(), formatDate, etc.
│ ├── gemini.ts # Gemini OCR prompts
│ ├── recommendation.ts # Eligibility scoring engine
│ └── supabase/
│ ├── client.ts # Browser Supabase client
│ ├── server.ts # Server Supabase client
│ └── proxy.ts # Session management
└── proxy.ts # Next.js 16 proxy (auth routing)
supabase/
└── migrations/
├── 001_create_tables.sql # Tables, indexes, triggers
├── 002_rls_policies.sql # Row-level security
├── 003_storage_buckets.sql # Storage buckets + policies
└── 004_seed_schemes.sql # 10 sample schemes
Landing (/) → Login (/login) → OAuth callback → Onboarding (/onboarding)
Step 1: Upload ID document
Step 2: Review OCR-extracted data
Step 3: Additional info (income, caste, occupation)
Step 4: Face verification (3 angles)
→ Home (/home) — Personalized scheme cards
→ Scheme Detail (/scheme/[slug]) — Full info + apply
/admin — Dashboard with stats
/admin/users — User list with search & filters
/admin/schemes — Scheme management (view, edit, deactivate)
/admin/schemes/new — Create or edit schemes with eligibility rules
| Method | Route | Description |
|---|---|---|
| GET | /api/auth/callback |
OAuth code exchange |
| POST | /api/ocr |
Document OCR with Gemini |
| POST | /api/upload/faces |
Upload 3 face images |
| POST | /api/profile/complete |
Save profile & complete onboarding |
| GET | /api/schemes |
List active schemes |
| GET | /api/schemes/recommend |
Personalized recommendations |
| GET/POST | /api/applications |
List/create applications |
| GET/POST/PUT/DELETE | /api/admin/schemes |
Admin scheme CRUD |
| GET | /api/admin/users |
Admin: list all users |
Stores citizen data — personal info, OCR-extracted fields, verification status, document/face URLs.
Government welfare schemes with JSONB eligibility_rules for age, income, gender, caste, state, occupation, disability criteria.
Tracks user applications with eligibility scores and review status.
Admin access control with admin and super_admin roles.
The recommendation engine in src/lib/recommendation.ts uses rule-based scoring:
- Extracts eligibility rules from each scheme's JSONB config
- Checks each criterion (age, income, gender, caste, state, occupation, disability)
- Calculates a percentage match score
- Returns sorted results with matching/missing criteria breakdown
- Row-Level Security (RLS) on all Supabase tables
- Users can only access their own profiles and applications
- Admin routes verify
admin_userstable membership - Storage buckets have per-user folder isolation
- Face verification images stored in separate restricted bucket
- Service role key only used server-side
pnpm dev # Start dev server (Turbopack)
pnpm build # Production build
pnpm start # Start production server
pnpm lint # ESLint checkMIT