This directory contains the Supabase configuration for the CircadiuaLux project.
CircadiuaLux uses Supabase as its backend service, providing:
- User authentication and authorization
- Database for storing device, patient, and lighting data
- Real-time updates for device statuses and lighting predictions
The Supabase database includes the following tables:
- profiles: User profile information with roles (admin, caretaker)
- devices: IoT device information including location details
- patients: Patient information with health and sleep preferences
- diseases: Disease information affecting sleep parameters
- lighting_predictions: Time-based lighting configurations for patients
- password_reset_requests: Tracks user password reset requests
- issues: For tracking reported issues in the system
- Supabase CLI
- Docker (for local development)
- Start a local Supabase instance:
supabase start- Apply the database schema:
supabase db resetThis will apply all migrations in the supabase/migrations directory.
-
Create a new project on Supabase.com
-
Link your local configuration to the remote project:
supabase link --project-ref your-project-ref- Push your local database schema to the remote project:
supabase db pushCreate or update your environment variables in your application:
VITE_SUPABASE_URL=your_supabase_url
VITE_SUPABASE_ANON_KEY=your_supabase_anon_key
For local development, you can get these values by running:
supabase statusThe migrations directory contains SQL scripts that define the database schema.
- The schema includes tables for users, devices, patients, and lighting predictions
- Row Level Security (RLS) policies are defined to secure data access
- Database triggers automate processes like:
- Calculating full names from first and last names
- Sending patient data to ML prediction service when updated
- Role-based access control with admin and caretaker roles
- Row Level Security (RLS) policies to restrict data access
- Secure authentication via Supabase Auth
For testing or initial setup, you can create a seed file in supabase/seed.sql and apply it with:
# Create seed.sql with initial data (admin user, test devices, etc.)
supabase db seedFor more information on the CircadiuaLux project architecture and components, see the main README.