# BillMinder

Desktop BillMinder app for tracking bills, due dates, payment status, and local macOS reminders.

For launch preparation, use `PUBLISHING_CHECKLIST.md`.

## Supabase Auth setup

BillMinder uses Supabase Auth for real email/password accounts.

1. Open your Supabase project dashboard.
2. Go to `Project Settings > API`.
3. Copy the Project URL.
4. Copy the `anon public` API key.
5. Open `supabase-config.js`.
6. Paste those values:

```js
window.BILLMINDER_SUPABASE = {
  url: "https://YOUR_PROJECT_REF.supabase.co",
  anonKey: "YOUR_ANON_PUBLIC_KEY",
};
```

In Supabase, go to `Authentication > Providers > Email` and make sure Email is enabled. If Confirm email is enabled, users must confirm their email before signing in.

To sync BillMinder data across computers, open Supabase `SQL Editor`, paste `supabase-schema.sql`, and run it. This creates the account-owned workspace table with row-level security.

## Stripe Billing setup

BillMinder uses Stripe Checkout for paid Plus and Premium subscriptions. Plus is $5/month with a $2 first-month coupon. Premium is $12/month with a $5 first-month coupon. Paid access is unlocked only after Stripe sends a verified webhook to Supabase.

Required Supabase secrets:

```bash
npx supabase@1.187.10 secrets set STRIPE_SECRET_KEY="sk_test_REPLACE_ME" --project-ref cmpmnjgpugmkfrgearkx
npx supabase@1.187.10 secrets set STRIPE_PLUS_PRICE_ID="price_REPLACE_WITH_PLUS_MONTHLY" --project-ref cmpmnjgpugmkfrgearkx
npx supabase@1.187.10 secrets set STRIPE_PREMIUM_PRICE_ID="price_REPLACE_WITH_PREMIUM_MONTHLY" --project-ref cmpmnjgpugmkfrgearkx
npx supabase@1.187.10 secrets set STRIPE_PLUS_COUPON_ID="REPLACE_WITH_PLUS_COUPON" --project-ref cmpmnjgpugmkfrgearkx
npx supabase@1.187.10 secrets set STRIPE_PREMIUM_COUPON_ID="REPLACE_WITH_PREMIUM_COUPON" --project-ref cmpmnjgpugmkfrgearkx
npx supabase@1.187.10 secrets set BILLMINDER_CHECKOUT_SUCCESS_URL="https://cmpmnjgpugmkfrgearkx.supabase.co/functions/v1/checkout-return?status=success&session_id={CHECKOUT_SESSION_ID}" --project-ref cmpmnjgpugmkfrgearkx
npx supabase@1.187.10 secrets set BILLMINDER_CHECKOUT_CANCEL_URL="https://cmpmnjgpugmkfrgearkx.supabase.co/functions/v1/checkout-return?status=cancelled" --project-ref cmpmnjgpugmkfrgearkx
npx supabase@1.187.10 secrets set BILLMINDER_PORTAL_RETURN_URL="https://cmpmnjgpugmkfrgearkx.supabase.co/functions/v1/checkout-return?status=success" --project-ref cmpmnjgpugmkfrgearkx
```

Deploy the checkout and webhook functions:

```bash
npx supabase@1.187.10 functions deploy create-checkout-session --project-ref cmpmnjgpugmkfrgearkx
npx supabase@1.187.10 functions deploy stripe-webhook --project-ref cmpmnjgpugmkfrgearkx --no-verify-jwt
npx supabase@1.187.10 functions deploy checkout-return --project-ref cmpmnjgpugmkfrgearkx --no-verify-jwt
npx supabase@1.187.10 functions deploy create-billing-portal-session --project-ref cmpmnjgpugmkfrgearkx
```

After deploying `stripe-webhook`, add this endpoint in Stripe Dashboard `Developers > Webhooks`:

```text
https://cmpmnjgpugmkfrgearkx.supabase.co/functions/v1/stripe-webhook
```

Subscribe it to these events:

```text
checkout.session.completed
customer.subscription.created
customer.subscription.updated
customer.subscription.deleted
invoice.payment_failed
```

Copy the Stripe webhook signing secret and save it:

```bash
npx supabase@1.187.10 secrets set STRIPE_WEBHOOK_SECRET="whsec_REPLACE_ME" --project-ref cmpmnjgpugmkfrgearkx
```

## Google Calendar setup

BillMinder can create all-day Google Calendar events for unpaid bill due dates, update matching events when bill details change, and delete the matching event when the bill is marked Paid. After the first successful Google Calendar connection, future valid unpaid bills are scheduled automatically.

One-time Google setup for the app owner:

1. Open Google Cloud Console.
2. Select the existing BillMinder project.
3. Enable the Google Calendar API.
4. Configure the OAuth consent screen.
5. Create or reuse an OAuth Client ID with application type `Desktop app`.
6. Put that Client ID in the BillMinder app configuration.

User flow in BillMinder:

1. Go to Reminders.
2. Click `Schedule Google Calendar Events`.
3. Enter your Google account email.
4. Sign in with Google when your browser opens.
5. Approve BillMinder Calendar access.

BillMinder creates all-day events on your primary Google Calendar. Email notifications are controlled by Google Calendar settings, so Google only sends emails if those notifications are enabled there.
