# Turn on Daymark cloud sync

Cloud sync stores a copy of your Daymark data in your Supabase project and protects each account's row with Postgres Row Level Security (RLS).

## 1. Create the database table

Create a Supabase project, open its SQL Editor, and run the contents of [`supabase-setup.sql`](supabase-setup.sql). The script creates the `daymark_sync` table and restricts access to the signed-in owner of each row. If your project has a Data API exposure list, make sure the `public` schema is exposed; RLS and the table grants still limit access to the signed-in user's own row.

## 2. Set the allowed app URL

In Supabase Authentication URL settings, set the Site URL to:

`https://daymark-organizer-shashank.pages.dev`

Add that same address as an allowed redirect URL. Email confirmation can be enabled; if it is, confirm the signup email before signing in to Daymark.

## 3. Connect Daymark

In Daymark, open **Settings → Cloud sync**. Enter the Supabase Project URL and its **publishable key** (or legacy `anon` key), then choose **Save connection**. Create an account with your email and password, check your email if confirmation is required, and sign in.

Use the same Supabase project and account on your phone and computer. Daymark syncs after changes, when you return to the page, and periodically while open. If a device was offline, its entries merge when it reconnects. Deletions are synced too.

## Data and keys

After you sign in, Daymark sends your records, syllabus topics, study sessions, daily log, course name, and reminder state to this Supabase project. Each account is restricted to its own row by RLS. The publishable/anon key is designed for browser use; **never put a `service_role` or secret key into Daymark**.

The current version keeps a local copy on each browser as well. When you first sign in, existing local entries merge into that account. Signing out leaves the account's local copy on that device, and you can sign back in later to sync it again.
