Custom dual-market real estate CRM with pipeline, contacts, tasks, calendar, automated follow-up, and commission tracking
COMPLETEProject Overview
Next.js 16 App Router/Turbopack CRM in progress with routes: Command Center dashboard, Contacts directory, Contact master profile, Pipeline, Tasks, Calendar, Settings. Dark-mode Tailwind theme. Uses Supabase Postgres with SSR auth and strict RLS; mutations via secure createClient from @/lib/supabase-server. Calendar page merges calendar_events, tasks, and transaction milestones. Pipeline needs validation/audit re: Kanban/List view matching RLS.
Features
- Google People API OAuth scopes + consent
Add required scopes for reading Google Contacts (People API); update OAuth consent and token storage.
- Label selection + mapping rules UI
UI to select which Google contact labels to sync and how to map labels to CRM tags (default: label name → tag).
- Import/sync job
Implement one-way sync job to fetch contacts, upsert into CRM contacts, and attach tags derived from labels; handle pagination and incremental sync using sync tokens if available.
- De-dupe and matching strategy
Define match rules (primary email/phone, Google resourceName) to avoid duplicates; log conflicts for review.
- Audit log + manual re-sync
Show last sync time/status; allow manual 'Sync now' and basic error reporting.
- Define pipeline data model
Create/confirm DB tables/columns for deal type (buyer/seller/outgoing referral), current stage, market (Pasadena/DMV), assigned agent, key dates, and links to contact record; ensure indexes for stage queries.
- Implement Kanban board UI
Kanban columns per stage based on deal type; drag-and-drop to move cards; card shows key info (name, stage, due milestone/close date, assigned agent).
- Stage transitions + validations
Enforce allowed stage transitions per deal type; update stage via server actions using Supabase server client; handle optimistic UI + error states.
- RLS audit for pipeline queries
Validate that Kanban/list fetching and mutations follow strict RLS; ensure users only see/update permitted records.
- Filters and segmentation
Filters by market (Pasadena/DMV), deal type, assigned agent, and search.
- Contacts directory table
Implement contacts table view with pagination, filtering (market, assigned agent, tags, source, stage), and search; ensure RLS-compliant queries.
- Core profile fields
Implement core profile form fields: name, emails, phones, source, tags, assigned agent, market, referral yes/no, notes, pipeline status; validation and server-side mutations via Supabase server client.
- Buyer requirements section
Implement buyer requirements fields: beds/baths, price, cities/zips, timeframe, lender, pre-approval; link to action plan tasks.
- Seller details section
Implement seller details fields: property address, timeline; link to action plan tasks.
- Referral details section
Implement referral details fields: receiving agent/brokerage; link to outgoing referral pipeline where applicable.
- Interaction timeline (notes)
Create interaction timeline UI to add/view notes, calls logged, etc.; ensure RLS and ordering by created_at.
- Commission calculator (market-based)
Implement live commission calculator shown when under contract: inputs for price, gross commission %, referral fee %, credits/fees; uses market math (DMV vs Pasadena) and settings to calculate net income.
- Task data model + RLS
Create/confirm tasks table with fields: title, description, due_at, priority, status, assigned_user_id, related_contact_id/deal_id (nullable), created_by, completed_at; implement strict RLS policies.
- Task Manager UI
Implement tasks page grouping: Overdue (red), Today (blue), Upcoming, Completed; filters by assigned user, market, related contact/deal; quick complete/edit.
- Contact action plan tasks
Embed task list in contact profile; allow creating/editing tasks scoped to that contact; show completion controls.
- Auto-generate tasks on stage entry
Define stage-based task templates (per buyer/seller/referral pipelines); on stage transition, generate tasks with computed due dates; ensure idempotency to avoid duplicates.
- Notifications hooks (optional)
Provide hooks for future reminders (email/SMS) for overdue/due tasks; no full notification system unless requested.
- Google OAuth + calendar connection UI
Implement connect/disconnect Google account flow; store tokens securely; show connection status in Calendar page.
- Dedicated CRM calendar provisioning
On connect, create or select a dedicated Google Calendar (e.g., 'CRMPro'); store calendarId per user; allow admin rules in Settings.
- Calendar events CRUD in CRM
Create/edit/delete CRM calendar events; link events optionally to contact/deal; server-side mutations with Supabase server client and RLS.
- Two-way sync engine
Implement initial sync + incremental sync (polling/webhook) for events between Google Calendar and CRM dedicated calendar; handle conflict resolution and deleted events; map Google event IDs to internal records.
- Unified calendar UI timeline
Calendar page merges calendar_events with transaction milestones into a unified agenda/timeline view; supports day/week/month or agenda view as needed.
- Sync rules in Settings
Settings page to manage Google sync rules (e.g., which calendars, sync window, and behavior); store per-user or global settings.
- Settings data model + RLS
Create per-user settings table keyed by user_id with fields for market math (gross commission %, split %, TC fee, etc. per market) and sync preferences; enforce RLS.
- Settings UI
Build Settings page UI for DMV and Pasadena calculators and Google sync rules; validate inputs; show success/error states.
- Wire commission calculator to per-user settings
Update commission calculator to source defaults from the authenticated user settings and selected market; allow per-deal overrides as needed.
- Admin vs member permissions (optional)
If needed, add an admin flag/role and allow admin to view/manage team settings; otherwise keep strictly per-user.
- Campaign data model
Create tables for campaigns, steps, enrollment, step executions/logs, and contact communication preferences; support wait delays and channel (email/SMS).
- Template editor + campaign builder UI
UI to create/edit campaigns and ordered steps; basic variables (contact name, etc.); enable/disable campaigns.
- Enrollment + triggers
Implement manual enrollment from contact profile and automatic trigger rules (new lead, pipeline stage change); avoid double-enrollment; allow unenroll/pause.
- Email sending via Gmail OAuth
Send campaign emails through connected Gmail account; store message IDs; log sent status and failures.
- SMS sending via Twilio
Send campaign texts via Twilio; manage from-number configuration; log delivery status and failures.
- Scheduler/worker for step execution
Implement background processing for queued steps (cron on Vercel or Supabase scheduled functions); handle retries and rate limiting.
- Compliance + opt-out handling
Support SMS opt-out keywords and contact-level do-not-text/do-not-email flags; ensure campaign respects these settings.
- Campaign analytics (basic)
Basic reporting: enrolled count, sent count, failures; per-contact campaign history.
- Define client portal access model
Decide auth approach: magic link per transaction, email-based login, or shared token; define expiration and revocation; enforce RLS/policies accordingly.
- Client portal UI
Build minimal client portal pages (dark/light TBD) showing transaction timeline: current stage, milestones, upcoming dates, and possibly documents/notes (if included).
- Expose read-only transaction timeline API
Create server routes/actions to fetch transaction timeline data for a client with strict access control; no write access for MVP unless requested.
- Admin controls for sharing
In CRM, add controls to generate/share portal link and to disable/regenerate links.
- Security review
Ensure portal cannot leak other contacts/deals; add logging and rate limiting as appropriate.
- Define dashboard metrics
Confirm and implement metric queries: total contacts, active transactions, tasks due today, upcoming closings; optionally by market and assigned agent.
- Build Command Center UI
Create dashboard page UI per dark-mode theme; cards/widgets for each metric and relevant lists (e.g., today's tasks, upcoming closings).
- RLS-compliant aggregation queries
Implement server-side aggregation using Supabase server client; ensure data is scoped per user/team via RLS and assignment rules.
Milestones
Milestone 1
Assigned Features
- Google Contacts One-Way Sync (Labels → Tags)
- Pipeline (Kanban)
- Contacts Directory + Contact Profile
- Command Center (Dashboard)
Milestone 2
Assigned Features
- Task Manager + Action Plan Tasks
Milestone 3
Assigned Features
- Calendar + Google Calendar Two-Way Sync
- Settings (Per-User Market Math + Sync Rules)
Milestone 4
Assigned Features
- Automated Email + SMS Campaigns
- Client Portal (Transaction Timeline)