Dev.to Security 🔐 Cybersecurity 👁 0 📖 5 min read

What building an Australian tradie marketplace taught me about consent, RLS and static rendering

QuotePulse is a two-sided marketplace for local projects in Australia: a homeowner posts a job once, nearby tradies send quotes, both sides message, and the customer accepts one quote. Accepting a quote awards the job, r

QuotePulse is a two-sided marketplace for local projects in Australia: a homeowner posts a job once, nearby tradies send quotes, both sides message, and the customer accepts one quote. Accepting a quote awards the job, rejects the other quotes and opens the conversation in one transaction.

It is an MVP. It runs against local Supabase, the AI defaults to a self-hosted model, and several features are specified rather than built. I want to write down the constraints that were not obvious, because most of them cost me a rewrite.

The shape of it

Three roles, three surfaces:

  • Homeowner — posts a job (category, urgency, photos, budget), compares quotes, accepts one, picks an appointment time.
  • Tradie — browses a lead feed, quotes on jobs, messages, and can switch on a follow-up agent for the quotes nobody answers.
  • Admin — reviews licence documents and flagged reviews.

Posting jobs, quoting and messaging are free. The paid plan is the follow-up agent for tradies, at AUD 49/month.

The stack is Next.js 15 (App Router), React 18, TypeScript in strict mode, Supabase for Postgres, Auth and Row Level Security, Tailwind for the UI, Zod on every API boundary, Vitest for units and Playwright for the one journey worth automating.

Lesson 1: removing 'unsafe-inline' means giving up static pages

The CSP is nonce-based: every request mints a nonce and serves script-src 'self' 'nonce-…' 'strict-dynamic'. That is a genuinely good header, and it has a consequence people do not mention in the tutorials.

A page that is prerendered at build time cannot carry a per-request nonce. Serve one anyway and 'strict-dynamic' blocks every script on it: the HTML arrives, nothing hydrates, and the page looks fine in curl and dead in a browser. So the root layout calls headers(), and every route under it becomes dynamic. Marketing pages stop coming from a CDN cache.

I could win that back by allowing 'unsafe-inline' on the marketing pages. I did not, because this is a marketplace that holds home addresses, phone numbers and photos of people's houses. The rule is written into the project's AGENTS.md so a future optimisation pass does not quietly reintroduce it.

Lesson 2: RLS is a backstop, not the boundary

Supabase RLS is excellent and I would not build this without it, but "the database enforces it" is how you end up with a handler that trusts a body-supplied id.

Every route handler here authenticates with auth.getUser(), then checks role and ownership against the row it actually loaded. RLS is the second line of defence for the paths I did not think of.

The subtle one was the service-role client. The obvious implementation reuses the cookie-aware server client with a service key — and then every privileged write runs as the signed-in user, hits RLS, and fails in a way that looks like a permissions bug rather than an architecture bug. The service client now never reads request cookies.

Two PostgREST traps also belong here. A bare embed of users from a table with two foreign keys to users is a 400, not a guess — you name the constraint (users!review_flags_user_id_fkey). And .or('conversation_id=not.null') is not the filter you think it is; .not('conversation_id', 'is', null) is.

Lesson 3: consent plumbing comes before AI features

There are five AI features. Before any of them call a model, each request goes through the same pipeline:

  1. authenticate;
  2. check per-feature consent, failing closed — a missing preferences row means no consent;
  3. consume a per-user, per-feature rate limit through an RPC;
  4. redact the job description — emails, Australian phone numbers and street addresses never leave the app;
  5. call the provider;
  6. write an audit row.

The default provider is a self-hosted Ollama model. Hosted inference is opt-in, disclosed in the settings screen, and the fallback wrapper returns which provider actually answered, so the audit row records the processor that ran rather than the one I configured.

Consent that can be flipped in a settings screen is a feature. Consent that is checked once, at signup, and never again is a liability.

Lesson 4: an autonomous agent should not write its own copy

The follow-up agent emails a customer when their quote has gone quiet. The tempting version generates a friendly nudge with a model. The shipped version uses deterministic templates carrying the price, the job title and a link.

If a system sends email on a tradie's behalf without a human reading it, it must not be able to invent a price, a discount or a promise. Deterministic copy makes that impossible rather than unlikely.

The rest of the agent is boring on purpose, too: it sends only between 08:00 and 19:00 in the tradie's timezone, waits a configured interval between attempts, stops at a maximum, stops the moment the job is awarded or the quote withdrawn, and every message carries a signed one-click opt-out that permanently excludes the customer.

Lesson 5: Australian rules set the defaults, not the docs

Two constraints shaped the defaults more than any product decision.

The Spam Act means no marketing without recorded consent and a working opt-out, so new accounts are opted out of marketing and the setting is a real subscribe/unsubscribe control rather than a one-way "opt out" button.

The Australian Privacy Principles mean the privacy and terms acceptance is stored with its version on the user row, consent is recorded per channel with a timestamp and IP, and a rejected sign-up is rejected in the database trigger, not only in the form. A checkbox that is validated in the browser is decoration.

What is deliberately not built

The honest list matters more than the roadmap: no calendar sync, so booking reads the tradie's in-app availability only; no inbound email parsing, so replying to a follow-up does nothing and the customer accepts through the link; no data export before account deletion. Those are gaps, not design choices, and listing them here is cheaper than a support email later.

The point

Most of the work was not features. It was deciding, once, where each boundary lives: the CSP owns script injection, the handler owns authorisation, the database owns the last line, the consent table owns whether a model may see anything, and the template owns what an autonomous email is allowed to say.

If you are building anything that touches someone's home, their phone number, or their inbox, those boundaries are the product.

QuotePulse is live at quotepulse.com.au.

Disclosure: I build QuotePulse, so this is a first-hand write-up of choices I made and mistakes I paid for, not an independent review.

📰 Read the original article on Dev.to Security

Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.