The problem
value to confirm
By 2026 the team was doing its client work inside the property platform, which had started as a research tool with basic contact tracking. I audited it against what a brokerage CRM needs. Four gaps stood out:
- One shared team password, so no record showed who created or owned it.
- One contact per deal: no buyer and seller sides, no agent splits, no gross commission income (GCI) and no lease pipeline.
- Every email logged by hand, and no tasks, reminders or follow-up sequences.
- Finished reports in one folder on one laptop.
Buying was the obvious fix. I priced HubSpot Sales Hub Pro as the benchmark: about $22–23k a year at 20 seats, the size of the firm’s growth plan. The team today is about five people, so that figure measures scale, never savings. The bigger problem was lock-in: contacts leave HubSpot easily, but email history and automation rules don’t. The firm already owned a database of every parcel in the state, so I recommended building around it, with one scope guard: no custom-objects engine.
What I built
Seven modules, C0 to C6, in about four weeks:
- Sign-in and roles (C0). Everyone signs in with their own Google account. Deals are private to the people on them unless shared.
- Deals with real parties (C1). Sale and lease pipelines, several parties per deal, stage gates that enforce required fields, and a commission waterfall down to each agent’s GCI.
- The deal desk (C2). Forecast, GCI per agent and stale deals on one screen.
- Gmail sync (C3). Every five minutes, storing only messages that involve a known contact.
- Tasks and automations (C4). Five rules, such as a nudge when a deal goes stale.
- A Google Drive folder per deal (C5), with access following the people on the deal, and signatures through Google Workspace’s own eSignature rather than a custom tool.
- Bulk import (C6) through a review queue that a person approves.
Campaigns and drip sequences followed, sent from each agent’s own Gmail. Every contact and property picker searches the CRM first, then about 2.2 million parcels and 2 million owners statewide, so a deal can start from any property in Massachusetts.
Each module’s written design was committed before its code, and the repository holds 49 design specs and 48 plans. About 73.5% of commits are co-authored with Claude, an AI coding agent working under my direction, and a hook stops the AI from deploying to production.
In one walkthrough, an agent described about 95% of their CRM use: “somebody calls me on a listing, I capture their name/number/email, attach them to my listing, and mark them interested.” Each call needed a full deal. The next day I wrote a spec separating leads from deals, and six pull requests merged that same day.
Diagram: the deal record at the center, the seven modules around it, and the pickers reaching out to 2.2M parcels and 2M owners.
The hard parts
Retiring the shared password while the team kept working.
I didn’t want the team to stop for a migration weekend, so the switch happened underneath them. For about three weeks both sign-in methods worked side by side, with the new security rules applied but held inactive. Then I retired the team password in one planned change, following a written runbook with a rollback script ready.
Under the hood
- One flag, read by the middleware and by
requireApiAuth()in every API route, kept the password path alive during the overlap. - Postgres grants EXECUTE on new functions to PUBLIC by default. The cutover revoked that grant on all 54 SECURITY DEFINER CRM functions (migrations 176 and 177), so only signed-in roles can call them.
Email that behaves like a person.
The first campaigns went out through a bulk email service, so they never showed in the agent’s Sent folder or threaded with replies. I moved sending to each agent’s own Gmail. Messages still landed in Promotions, so I removed the bulk-mail markers, keeping the unsubscribe link and the postal address the law requires. The database now refuses to let anyone send a campaign from another person’s mailbox.
Under the hood
- PR #41 replaced Resend with Gmail
users.messages.send. Lists run to 300 or fewer, far below the volume where Google requires a List-Unsubscribe header, so PR #43 dropped it, the strongest Promotions signal. - A trigger (migration 247) raises an exception unless a signed-in user moving a campaign out of draft sets
from_userto themselves. The service role is exempt, so scheduled sends still run. - Inbound sync recovers from an expired Gmail history cursor with a 24-hour overlap.
Follow-up emails that can’t double-send when timers overlap.
A drip sequence is a series of emails spaced days apart, sent by a timer. The usual failure is two timer runs picking up the same step, so a client gets the same email twice. Each step now reserves itself before sending, can be recorded only once, and goes out only on weekdays, 8am to 6pm Eastern. The limit: if the server dies mid-send, the step is retried after 15 minutes, so a crash at exactly the wrong moment could still repeat one email.
Under the hood
- The claim uses
FOR UPDATE SKIP LOCKED, but that lock ends when the claim returns, so it also writes a 15-minute lease ontonext_run_at.UNIQUE(enrollment_id, step_id)withON CONFLICT DO NOTHINGkeeps the bookkeeping idempotent. Delivery is at-least-once by design. - The timer was its own problem: the OpenNext Worker can’t export a scheduled handler, and a direct Worker-to-Worker call on the same
workers.devzone fails with error 1042. A separate small Worker owns six schedules and calls the app over a service binding.
Results
- Off the shared password. Everyone signs in as themselves. How measured: the cutover commit and its migrations.
- Seven modules in about four weeks, then email campaigns and drip sequences within the next three weeks. How measured: design-document and merge dates.
- Import duplicate check: 8,842 ms down to 83 ms. The old check timed out at about 6,000 contacts and broke a 3,089-contact Google Contacts import. How measured: the same 200-row worst-case batch, before and after.
- value to confirm
- value to confirm
What’s next
- Text messaging and call logging per agent, once the team’s volume justifies the carrier registration.
- Reply reporting for campaigns. Open and click tracking was left out on purpose when campaigns moved to Gmail. The Gmail sync already sees replies, which are the better signal.
- Browser tests in the deploy pipeline. Type checks and about 870 unit tests already gate every deploy; the end-to-end suite joins them next.
Stack
Next.js 16 · React 19 · TypeScript · Supabase (Postgres, row-level security) · Cloudflare Workers · Gmail and Google Drive APIs · Vitest · Playwright
If your team shares one login and logs email by hand, I can build a CRM around how you actually sell.
Have a similar problem? Book a call.