CogniPrep Assess runs against a real production database, and I still need a demonstration organisation with roles, two dozen candidates and results in it, so I can build screens against something that looks alive. That is a dangerous combination: made-up people living next to real ones, with a mail system that works. This post is about the layers that stop the made-up ones from ever touching the real world. I wrote about the main email gate in an earlier post, so here the focus is on what sits around it.

The data goes through the real code

pnpm seed:demo builds the organisation by calling the same services the product uses. It does not insert rows by hand. Candidates are simulated, their results are stored the way a real sitting is stored, and the results, fit scores and reports are produced by the real code. The reason is boring and strong: a seed script that writes rows directly stays correct only until the schema changes, and a seed that uses the services breaks the moment a service changes, which is when you want to know.

pnpm seed:demo --reset deletes the organisation and builds it again, so it is safe to run until it looks right. If you want to see what comes out, the demo page is the front door to the real product, and how it works shows the screens.

A plan that means "not real"

The organisation is on a demo plan. That one value is checked in several places, each of which would otherwise be a way for fake data to leak:

  • results from demo organisations are left out when the norms are rebuilt, so simulated candidates never move a real percentile
  • webhooks are not sent for them, so a customer's system never receives a made-up candidate
  • allowance and usage notices are not sent for them, because nobody should be emailed about a made-up organisation's allowance

The alternative was a flag on every candidate, and a flag per row is a flag somebody forgets on the next insert. The plan lives on the organisation, which every row already hangs from.

Addresses that cannot receive mail

Every address in the demo ends in .test. That is not a style choice. The top level domain .test, along with .example, .invalid, .localhost and the second level example.com, .net and .org, is reserved by RFC 2606 and RFC 6761 so that it can never be registered and can never receive mail.

The email policy knows this and refuses before anything else about the mode:

const RESERVED_DOMAIN = /(\.(test|example|invalid|localhost)|[@.]example\.(com|net|org))$/i; // Reserved names can never receive mail. The demo organisation uses them, // so they are never handed to the provider. if (RESERVED_DOMAIN.test(to)) return { action: 'suppress', reason: '...' }; if (input.mode === 'live') return { action: 'send' }; 

The ordering is the point. Reserved domains are suppressed even in live mode, even if somebody adds one to a list. The test says so in plain terms: for six reserved addresses, with the mode set to live and the address on an allow-list, the decision is still to suppress. A seventh case checks the regex does not overreach, so owner@myexample.com is a normal address and is sent.

The reason for this layer is that a reserved address can never be real, so there is never a case where sending to one is right.

Live needs three things

The gate that turns mail on is deliberately hard to enable by accident. It needs all of these:

  1. EMAIL_MODE is exactly live
  2. the code is a production build, not next dev, not a script, not a test run
  3. on Vercel, the deployment is the production one and not a preview

So a live left in a local env file does nothing on a laptop, and a variable set for every Vercel environment still sends nothing from a preview. A message that is not sent is written to the email log as suppressed and printed to the server log, which is where I read a sign-in link while building.

The seed refuses on its own

The seed script does not rely on the gate. It checks the mode itself and throws if it is live: "Demo data must never send real email." Two independent checks that fail the same way are worth more than one good one, because the day one is edited out the other still holds.

Signing in to fake people

I need to be the demo owner, admin or viewer without creating real accounts in the shared sign-in system. A development sign-in does that, and it is allowed only when two things are true: NODE_ENV is development and ASSESS_DEV_LOGIN is 1. A production build ignores it however the variable is set. Alongside it are database-free preview pages for the signed-in frame and the candidate screens, which use made-up data and need no connection at all, so most layout work never touches the database.

A checklist for your own seed

  1. Build it with your services, not your tables.
  2. Mark the organisation, not the rows.
  3. Use reserved domains for every address, and refuse them in the mailer too.
  4. Make the script refuse to run where mail is live.
  5. Make the sign-in shortcut impossible in a production build.

If you would rather see the real thing than a made-up one, the pricing page explains how an account starts, and the demo page is where that begins.