Skip to content

Property and investment CRM: four investment routes, access decided by the database

A CRM in development for a property and investment business: website enquiries triaged into contacts, four investment routes with their own stage sequences, and every read and write decided by the database.

Client
Client name withheld
Industry
property and lettings
Duration
In development (2026)

The problem

A property business can run four commercially different investment routes at once. Each has its own approved stage sequence, paperwork, money flow and point at which identity checks must clear. A website enquiry does not say which route it belongs to, and the answer often changes after the first conversation. The access problem is sharper. Sales must know whether a person has cleared identity checks without seeing the passport scan. Finance prepares payments but must not approve them. A project manager sees their own projects only. These are rules that must hold even if someone guesses a URL. And the public website has to write into a system nobody outside the company may read.

The approach

We are building the CRM on row-level database security rather than application checks alone. The signed-in member of staff is carried into the database connection, and the database decides which rows they may read and write, through 92 policies across 38 tables. The application holds the session and a catalogue of 49 permissions across 6 roles. The four investment routes are modelled as separate pipelines rather than one pipeline with branches: 10 pipelines and 61 stages, seeded once and read from the database at runtime. Public enquiries reach the database through a single function that can touch exactly one table.

The outcome

In active development. Contacts, opportunities, enquiry intake and triage, administration and the audit trail are built and covered by tests. Delivery, compliance, agreements and finance exist in the schema but are not yet built. No usage figures exist: the environment holds no live records yet. What the tests hold in place: an opportunity cannot move backwards without a reason and a permission, a stage gate cannot be bypassed by editing the record, an audit event cannot be altered after it is written, and an anonymous submission can reach exactly one table. Repository audit, September 2026: 38 database tables, 92 row-level policies, 49 permissions, 6 roles, 10 pipelines and 61 pipeline stages.

Challenges

Letting the public write to a private database: a single elevated-rights function can touch exactly one table, rate limits are counted in the database because serverless instances cannot share a counter, and visitor IP addresses are stored only as a truncated hash. PostgreSQL grants execute on a new function to PUBLIC by default. A follow-up migration revoked it, and the rule is now explicit: revoke execute from PUBLIC in the same migration that creates the function. Conversion creates a contact only, because an opportunity must belong to one of the four routes and none described some enquirers. We wrote the gap down for a business decision rather than inventing a fifth route. Stage sequences live in the database, so reordering them is an audited administration change, not a release.

What was built

  • — Public enquiry intake through one controlled path
  • — with consent and database-counted rate limiting
  • — Enquiry triage queue with new
  • — reviewing
  • — converted
  • — closed and spam states
  • — and conversion into a contact
  • — Contact records for individuals and companies
  • — with normalised phone numbers
  • — lead source and an activity timeline
  • — Marketing consent recorded with its source and timestamp
  • — and never overwritten in place
  • — Duplicate detection on email and phone so one person does not become two records
  • — Four investment routes
  • — each with its own approved stage sequence read from the database
  • — Stage moves forward one at a time; moving back needs a recorded reason
  • — a permission and a full stage history
  • — Six roles and 49 permissions
  • — email invitations and suspension
  • — and an audit log that refuses edits

Technology

Next.jsReactTypeScriptTailwind CSSPostgreSQLSupabaseVitestVercel

Have a similar operational problem?

Start with a 30-minute conversation about the operation and the useful next step.

  • Free 30-minute call
  • No obligation
  • Reply within 24 hours
Book a free 30-min call