Overview
The Registration API handles event attendee registration for the Shree Ghanshyam Maharaj Rajat Pratishtha Mahotsav (July 27 - August 2, 2026). Registrations are submitted directly to Supabase from the client side with upsert logic based on unique identifiers.Client-Side Registration
Registrations are handled client-side using the Supabase JavaScript client. The application performs an upsert operation to update existing records or insert new ones.Registration Schema
First name (letters only)
Middle name (letters only, optional)
Last name (letters only)
Age between 1 and 99
Ghaam name (letters only)
Country of residence
Mandal/region name
Valid email address
International phone country code (e.g., “+1”)
National phone number (digits only, no country code)
Arrival date in ISO format (YYYY-MM-DD), between 2026-07-23 and 2026-08-08
Departure date in ISO format (YYYY-MM-DD), must be >= arrival_date
Registration Logic
The registration form implements upsert logic based on a unique combination of fields: Unique Identifier:first_name + age + email + mobile_number
Country and Mandal Mapping
Certain countries have fixed mandals, while others require user selection:Fixed Mandal Countries
- India: Maninagar
- Australia: Perth
- Canada: Toronto
- Kenya: Nairobi
Selectable Mandals
England:- Bolton
- London
- Alabama
- California
- Chicago
- Delaware
- Georgia
- Horseheads
- Kentucky
- New Jersey
- Ocala
- Ohio
- Seattle
- Tennessee
- Virginia
Phone Number Handling
Phone numbers are processed usingreact-phone-number-input library:
- Full international number is validated on client
- Country code is extracted and stored in
phone_country_code - National number (without country code) is stored in
mobile_number
Validation Rules
Name Fields
- Must contain only letters (A-Z, a-z)
- First and last names are required
- Middle name is optional
Age
- Must be between 1 and 99
- Stored as integer
- Must be valid email format
- Validated using custom email schema from
@/lib/email-validation
Phone Number
- Must be valid international phone number
- Validated using
isValidPhoneNumber()from react-phone-number-input
Dates
- Both arrival and departure dates are required
- Must be within range: 2026-07-23 to 2026-08-08
- Departure date must be on or after arrival date
Export CSV (Admin Only)
Endpoint
Description
Streams all registration data as a CSV file using keyset pagination to avoid memory issues. The CSV includes a UTF-8 BOM for proper encoding in Excel.Response
Content-Type:text/csv; charset=utf-8
File Name: registrations-{timestamp}.csv
Columns:
- id
- first_name
- middle_name
- last_name
- mobile_number
- phone_country_code
- country
- ghaam
- mandal
- arrival_date
- departure_date
- age
Implementation Details
CSV Field Escaping
Fields are escaped per RFC 4180:- Wrap in quotes if contains comma, newline, or double quote
- Escape quotes by doubling them
Error Responses
Error type identifier
Human-readable error message
Technical error details (optional)
Best Practices
For Administrators
- Export frequently - Use the CSV export for backups and analysis
- Monitor unique constraints - Watch for duplicate registrations based on the 4-field unique key
- Date range validation - Ensure dates fall within event window
For Integration
- Use Supabase client - Direct database operations for optimal performance
- Implement retry logic - Handle network failures gracefully
- Validate on client - Use Zod schemas for form validation before submission
- Parse phone numbers - Always extract country code and national number separately
Registration submissions do not use a traditional REST API endpoint. Instead, they leverage Supabase’s Row Level Security (RLS) policies for direct database access from the client.
