# Run or self-host Real Estate CRM ## Start with the local demo You need Node 24, npm, and a running Docker daemon. The app and database run on your computer with synthetic data. Supabase Docker images and npm dependencies download during setup. ```sh npm ci npm run demo:setup npm run dev -- --hostname 127.0.0.1 --port 4374 ``` Open [http://127.0.0.1:4374](http://127.0.0.1:4374). Select **Sign in as demo owner** to enter the workspace. The staff demo is `staff@cedar.example` with password `Cedar-demo-only-2026`. The local Supabase API is on port 55721 and Postgres is on 55722. Keep the app origin the same when opening it and testing forms. Set `REAL_ESTATE_CRM_PORT` before setup and change the dev port together if 4374 is taken. The setup script creates a restricted Postgres login and a local `.env.local`. Running it again applies pending local migrations and preserves existing demo records. `npm run demo:setup -- --reset` explicitly replaces **this CRM’s local demo data**. Use it when you want a fresh fixture. `npx supabase stop` stops this project’s local stack. Choose **Campaigns → Run email simulator** to process due mail and see its result in Delivery. The demo uses local Auth and the same database queue, journey logic, and reply matching as live mode. Provider calls are simulated. If you opt in on the public inquiry form, the simulator exposes the confirmation link under Delivery. ```sh npm run check npm run test:db npx playwright install chromium npm run test:e2e ``` The database and browser suites create synthetic records in this local project. Set `PLAYWRIGHT_CHROME=1` to use installed Google Chrome or set `PLAYWRIGHT_EXECUTABLE_PATH` to a compatible Chromium executable. Browser tests save screenshots in `artifacts/`. After `npm run check`, set `PLAYWRIGHT_PRODUCTION=1` to run them against the optimized build used by CI. ## Accounts to set up Set up Supabase and Vercel first. The CRM owner and staff sign in with Supabase email and password. You can use contacts, pipelines and tasks with `EMAIL_MODE=disabled` and no Resend account. Configure Resend to send live email from the CRM, including campaigns and opt-in confirmations, and to receive replies. | Account | When you need it | What to prepare | | --- | --- | --- | | [Supabase](https://supabase.com/) | **Required** for data and sign-in | A new project for this CRM, a database password, a publishable key, and a Supabase Auth owner account. | | [Vercel](https://vercel.com/) | **Required** for hosting with this guide | A team with access to your GitHub repo. Use Pro or Enterprise for the configured five-minute Cron Job. | | [Resend](https://resend.com/) | **Optional for core setup. Required** for live CRM email and replies | A verified sending domain, a receiving domain or assigned Resend inbound domain, an API key for sending, credentials that can retrieve received email, and a webhook signing secret. | | Domain DNS provider | **Required when configuring Resend** | Access to add Resend’s verification records. An assigned Resend inbound domain can receive replies without changing existing mailboxes. | | Google Cloud | **Optional** for Google sign-in | An OAuth app and credentials if you enable Google sign-in. | Each installation hosts one business. Use a separate Supabase project and deployment for each business. If you enable live email, set up a separate sending identity and receiving configuration as well. Keep passwords and API keys in environment settings. If instructions are being followed by an agent, enter secrets directly in the provider dashboard or `.env.local`. Share only variable names and status with the agent. ## Set up Supabase and the owner 1. Create the new Supabase project and wait until it is healthy. Sign in with `npx supabase login`, link it with `npx supabase link --project-ref `, verify the linked project, then run `npx supabase db push`. Use the DB password prompt if required. Keep the GitHub fork private while setting up. 2. Open Supabase’s SQL editor as the project database administrator. Create a dedicated runtime login using the group installed by the migration. ```sql create role sales_crm_runtime login inherit in role sales_crm_access password ''; ``` Set `DATABASE_URL` to the project’s **shared transaction pooler** string from Connect. Use port 6543 and username `sales_crm_runtime.` in place of `postgres.`. URL-encode the password and use `sslmode=require`. For an IPv6-capable direct connection, the username is `sales_crm_runtime` without the project suffix. The app disables prepared statements for transaction pooling. Leave the private `crm` schema out of the Supabase Data API and keep the runtime login separate from the administrator login. [Supabase connection guidance](https://supabase.com/docs/guides/database/connecting-to-postgres) 3. Set Supabase Authentication’s Site URL to your final app origin and add that origin’s exact `/auth/callback` URL to the redirect allowlist if using Google. Disable public sign-ups in Authentication. Create the owner user in **Authentication → Users**. Set a unique password and confirm the user there as appropriate. Copy the user UUID. From a clean checkout with the **intended** database’s `DATABASE_URL` configured, run: ```sh npm run owner:setup -- "Owner name" ``` Use the same database URL in the Vercel project. Create teammates in Supabase Auth first, then add their UUID and role in **Settings → Team access**. Supabase Auth users without active workspace membership cannot enter the CRM. 4. For Google single sign-on, use Supabase’s [Google provider setup](https://supabase.com/docs/guides/auth/social-login/auth-google). Enable it with `GOOGLE_SIGN_IN_ENABLED=true`. The Google account must resolve to an active Supabase member UUID. Verify account sign-in and membership before sharing access with staff. ## Deploy with email disabled 1. Import the repo into the intended Vercel team and use the pinned Node 24 runtime. Set `APP_URL` to the exact HTTPS deployment origin, with no path. Set `NEXT_PUBLIC_SUPABASE_URL`, `NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY`, and `DATABASE_URL`. Generate two separate secrets of 32 characters or longer for `APP_LINK_SECRET` and `CRON_SECRET`. You can use `openssl rand -hex 32` in a private terminal. Enable **Automatically expose System Environment Variables** on Vercel and scope live email credentials to Production. Vercel uses `CRON_SECRET` to authorize `GET /api/cron/email`. [Vercel system environment variables](https://vercel.com/docs/environment-variables/system-environment-variables) · [Vercel Cron Jobs](https://vercel.com/docs/cron-jobs/usage-and-pricing) 2. Leave `EMAIL_MODE=disabled` while verifying sign-in, the public inquiry from an incognito window, member permissions, and the company mailing address and sending window in Settings. Use an isolated Supabase project for any remote preview that needs data. A preview deployment always disables provider email. 3. Run the migrations before making the deployment the app’s active URL. Project owners can confirm that authorized cron calls report the current email mode and that unauthorized calls return 401. The five-minute schedule may start soon after a production deployment, so keep live secrets scoped to the intended environment. ## Set up Resend Complete this section when you are ready to enable live CRM email and replies. Leave `EMAIL_MODE=disabled` until you approve a live email test. - Verify the sending domain and enter a single sender like `Business Name ` in `EMAIL_FROM`. Store a server-only Resend sending key as `RESEND_API_KEY`. Prefer a key with sending access scoped to that domain. - Set `RESEND_INBOUND_DOMAIN` to the assigned Resend receiving domain or your dedicated receiving subdomain, with no leading `@`. If separate credentials are needed, set `RESEND_RECEIVING_API_KEY` to a server-only key able to call the received-email retrieval API. The app uses this key, or falls back to `RESEND_API_KEY` when it has sufficient access. Each outgoing message uses an opaque address at the configured domain. [Resend receiving](https://resend.com/docs/dashboard/receiving/introduction) · [Retrieve received email](https://resend.com/docs/api-reference/emails/retrieve-received-email) - Create a webhook for `/api/webhooks/resend` and store its signing secret as `RESEND_WEBHOOK_SECRET`. Subscribe to `email.received`, `email.sent`, `email.delivered`, `email.failed`, `email.bounced`, `email.complained`, and `email.suppressed`. If you opt into engagement tracking, enable it in Resend, add `email.opened` and `email.clicked`, and set `EMAIL_TRACKING_ENABLED=true` in the app. Tracking reflects events received after it is enabled. Click waits use the click events Resend reports for that enrollment. Reported opens and clicks can include automated activity. [Resend event types](https://resend.com/docs/webhooks/event-types) - Set `EMAIL_TEST_RECIPIENTS` to the comma-separated addresses approved for controlled template tests. Use the separate live-email check below before activating customer campaigns. - Record explicit marketing permission before starting journeys or broadcasts. Confirm that the sender identity, business mailing address, and unsubscribe links are correct. Staff can edit drafts and reply. An owner or manager must approve sending, enrollment, or activation. [Resend Acceptable Use Policy](https://resend.com/legal/acceptable-use) ## Run the live-email check 1. Obtain approval for the exact deployment, sender and recipient addresses. Use an isolated test deployment and database if the main installation has customer records or queued email. Verify the sending window and business mailing address. Set `EMAIL_MODE=live` on the approved deployment. Vercel previews continue to disable sending. 2. Use **Templates → Queue test email** to check content, sender, Resend acceptance and confirmed delivery. Template tests are only for delivery and content. Use an approved campaign contact to exercise replies and unsubscribe. 3. Create opted-in records for the approved test mailboxes. For reply and unsubscribe, use a small manually enrolled journey with an initial email, a delay and a second message. Confirm that only the approved mailboxes are enrolled. Reply from one mailbox and use the unsubscribe link from the other. Verify the signed webhook events, the stopped runs, an in-thread response from the workspace, the opted-out record and the campaign results. 4. Pause the test journey and return email to disabled if you are still setting up. Review the sender, consent evidence and the first customer audience before approving any live campaign. ## Operate the queue The app uses a fixed 100-message quota per UTC day across broadcasts, journeys, confirmations, receipts, personal emails, replies, and tests. The preview subtracts queued work, existing reservations, and provider usage the app has observed. Free Resend accounts also count inbound mail and reset at midnight UTC. Keep this installation on its own sender and account where practical, and review provider usage before promising a time-sensitive broadcast. [Resend usage limits](https://resend.com/docs/api-reference/rate-limit) A same-day broadcast reserves the reviewed audience within both the local sending hours and a single UTC quota day. At cutoff, unattempted messages are marked missed and attempted messages with unsettled outcomes go to review. Recheck the audience before approving any later attempt. Review **Campaigns → Delivery** for queued, accepted, and delivered messages. The worker can move sends to later days when the configured window or the daily allowance is full. A message marked **Needs review** requires a check in Resend before you record an accepted provider ID or close the message as failed. Review the existing message before taking further action. Provider acceptance and delivery are reported independently. Pause a journey or stop future sends for a broadcast from the CRM. If you need to stop all dispatch, set `EMAIL_MODE=disabled` and redeploy. Already accepted or in-flight mail may still arrive. Keep queued history and provider receipts for reconciliation. Rotating `APP_LINK_SECRET` invalidates existing confirmation and unsubscribe links. Plan that rotation around active messages. For upgrade, backup and live-email checks, see [Release verification](release-readiness.md).