Skip to content

Supabase Backend

PharmaNet uses Supabase as its backend platform, providing PostgreSQL database, authentication, real-time subscriptions, file storage, and edge functions.

Services

Service Usage Details
PostgreSQL Primary database 32 tables, 10+ views, 15+ RLS policies
Auth User authentication Email/password, OTP, Google OAuth, role-based access
Realtime Live updates Order status, chat messages, notifications
Storage File hosting Product images, pharmacy documents, banner images
Edge Functions Serverless Deno (Coming: push notifications, payment webhooks)

Database Configuration

Property Value
PostgreSQL Version 15.x
Schema public
Extension pgcrypto (UUID generation)
Publication supabase_realtime

Auth Schema

Auth is handled by Supabase Auth (GoTrue) with a profiles table linked via auth.users.id:

-- Triggers create a profile row on user signup
CREATE OR REPLACE FUNCTION public.handle_new_user()
RETURNS trigger AS $$
BEGIN
  INSERT INTO public.profiles (id, email, role)
  VALUES (new.id, new.email, 'customer');
  RETURN new;
END;
$$ LANGUAGE plpgsql SECURITY DEFINER;

Storage Buckets

Bucket Usage Access
products Product images Public read, authenticated write
pharmacy-docs License/ID documents Admin only
banners CMS banner images Public read, admin write
avatars Profile pictures Public read, owner write