Skip to content

ayanffee/paddilottery

Repository files navigation

Paddilottery MVP

Nigeria's most transparent digital raffle platform. Win real assets at affordable ticket prices.

Tech Stack

  • Frontend: Next.js 16 (App Router) + TypeScript + Tailwind CSS v4
  • Backend: Supabase (Auth + Postgres + RLS)
  • Payments: Paystack
  • Hosting: Vercel

Setup

1. Install dependencies

npm install --include=dev

Note: --include=dev is required to install Tailwind CSS (a devDependency).

2. Supabase

  1. Create a project at supabase.com
  2. Run the full schema in Supabase > SQL Editor:
    supabase/migrations/001_initial_schema.sql
    
  3. Copy your project URL and API keys from Settings > API

3. Paystack

  1. Get your keys from paystack.com Dashboard
  2. Register webhook URL: https://yourdomain.com/api/webhooks/paystack
  3. Enable charge.success event

4. Environment variables

Copy .env.example to .env.local and fill in all values:

NEXT_PUBLIC_SUPABASE_URL=https://xxxx.supabase.co
NEXT_PUBLIC_SUPABASE_ANON_KEY=eyJ...
SUPABASE_SERVICE_ROLE_KEY=eyJ...

NEXT_PUBLIC_PAYSTACK_PUBLIC_KEY=pk_live_...
PAYSTACK_SECRET_KEY=sk_live_...

NEXT_PUBLIC_APP_URL=https://yourdomain.com

5. Run dev server

npm run dev

First Admin User

After signing up, promote yourself to admin in Supabase SQL editor:

UPDATE public.profiles
SET role = 'admin'
WHERE email = 'your-email@example.com';

Key Pages

URL Description
/ Homepage
/raffles Browse active raffles
/raffles/[slug] Raffle detail + buy tickets
/winners Public draw transparency page
/how-it-works Platform explainer
/dashboard User dashboard (tickets, wins)
/vendor/apply Vendor application
/vendor/dashboard Vendor portal
/admin/dashboard Admin panel
/admin/vendors Approve vendors
/admin/raffles/[id] Approve + trigger draws

Payment Flow

User → Buy Ticket → POST /api/payments/initialize
     → Paystack authorization_url
     → User pays on Paystack
     → Paystack webhook → POST /api/webhooks/paystack
     → Ticket status = PAID
     → tickets_sold increments via DB trigger

Only the webhook confirms tickets. The redirect URL is for UX only.

Draw System (Verifiable)

  1. Admin clicks "Trigger Draw" on raffle page
  2. All paid ticket IDs collected and sorted
  3. 32-byte random seed generated via crypto.randomBytes
  4. draw_hash = SHA-256(seed + ticket_ids.join(','))
  5. winner_index = BigInt('0x' + SHA-256(seed)) % BigInt(totalTickets)
  6. Seed and hash published publicly on /winners

Anyone can independently verify the result.


Supabase Storage

Create two public buckets:

  • raffle-images (5MB limit)
  • avatars (2MB limit)

Deploy to Vercel

npx vercel --prod

Add all environment variables in Vercel Dashboard > Project > Settings > Environment Variables.

About

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors