Production Recipes
Use @tantainnovative/ndpr-recipes as a versioned npm source package for backend persistence, routes, adapters, and compliance workflow templates.
@tantainnovative/ndpr-toolkit gives you the runtime components, hooks, validators, scoring, and server utilities. @tantainnovative/ndpr-recipes gives you versioned backend source templates: database schema, route handlers, middleware, and storage adapters that you copy into your application and own.
Treat the recipes package like a maintained implementation workbook. Install it to pin the source version, copy the pieces you need, then adapt naming, authentication, tenancy, logging, and deployment details to your stack.
pnpm add @tantainnovative/ndpr-toolkit
pnpm add -D @tantainnovative/ndpr-recipes
# Prisma projects
cp node_modules/@tantainnovative/ndpr-recipes/prisma/schema.prisma prisma/schema.prisma
# Copy complete integration seams before adapting paths and auth
cp -r node_modules/@tantainnovative/ndpr-recipes/src/nextjs/app-router src/ndpr/nextjs
cp -r node_modules/@tantainnovative/ndpr-recipes/src/express src/ndpr/express
cp -r node_modules/@tantainnovative/ndpr-recipes/src/adapters src/ndpr/adaptersThe recipes are intentionally not hidden behind a runtime abstraction. Compliance persistence needs to fit your authentication, data retention, audit logging, tenant isolation, and incident-response process.
Existing 0.1.x or 0.2.0 databases require the reviewed 0.3.0 migration artifacts and guide. Standalone psql or Prisma use the wrapped migrations/0.3.0/postgresql.sql; a Drizzle-managed migration uses the transaction-control-free migrations/0.3.0/drizzle.sqlinside Drizzle's outer transaction. Do not use a blind Prisma or Drizzle schema push: tenant ownership, DSR subject IDs, consent deduplication, and ROPA evidence require reviewed backfills.
Security Contract Before Deployment
Set the server-only NDPR_TENANT_ID and replace the fail-closed resolveVerifiedNDPRActor implementation with your verified session lookup. Map privacy operators to ndpr:staff or ndpr:admin.
- Tenant identity comes only from server configuration.
- Account subject, actor, role, reporter, and assessor identity comes only from verified server auth.
- Anonymous consent and DSR use a scoped
anon_<UUID>capability inX-NDPR-Subject-Id. - Every database lookup and write stays tenant-scoped, and mutation/audit writes remain atomic.
Which Package Should I Use?
| Need | Use | Why |
|---|---|---|
| Drop-in UI | @tantainnovative/ndpr-toolkit/presets | Fastest way to ship consent, DSR, DPIA, breach, and policy screens. |
| Custom UI with toolkit logic | @tantainnovative/ndpr-toolkit/hooks | Use hooks and bring your own design system. |
| Server validation and scoring | @tantainnovative/ndpr-toolkit/server | RSC-safe utilities with no React import graph. |
| Production persistence examples | @tantainnovative/ndpr-recipes | Versioned source templates for database schemas, adapters, and route handlers. |
Recipe Inventory
| Area | Path | When to use it |
|---|---|---|
| Prisma schema | prisma/schema.prisma | Use when your app already runs Prisma migrations. |
| Drizzle schema | src/drizzle/schema.ts | Use when your app owns schema changes through Drizzle Kit. |
| Next.js routes | src/nextjs/app-router/api/** | Copy into App Router projects that need server-side persistence. |
| Express routes | src/express/** | Mount in existing Node/Express APIs. |
| Storage adapters | src/adapters/** | Run tenant-scoped persistence behind your server API. |
| Consent middleware | src/nextjs/app-router/middleware.ts | Gate routes by consent state. |
Module Coverage
| Module | Backend surface | Production purpose |
|---|---|---|
| Consent | Consent records, revocation, audit trail | Persist active and historical consent snapshots. |
| DSR | Request intake, reference IDs, target dates | Track 30-day response workflows. |
| Breach | Incident intake, lifecycle updates, NDPC readiness | Keep 72-hour notification evidence visible. |
| DPIA | Assessment metadata, risk score, approval status | Store Section 28 assessment evidence. |
| ROPA | Processing records and completeness checks | Maintain records of processing activities. |
| Compliance | Operational indicators API route | Expose tenant-scoped record counts, evidence rates, and not-observed states to internal dashboards. |
| DCPMI / CAR utilities | Designation tier and audit return schedule | Support GAID 2025 classification and filing planning. |
Production Checklist
- Pin both package versions in your lockfile before copying recipe source.
- Configure a server-only tenant ID and test cross-tenant isolation.
- Connect verified actor resolution; test anonymous subject, account subject, staff, and forbidden paths.
- Keep actor, subject, tenant, reporter, assessor, and role authority out of request bodies and query strings.
- Verify that business mutations and accountability events roll back together.
- Review retention periods, audit-log fields, and breach escalation routing with counsel or your DPO.
- Run migrations in staging and test consent revocation, DSR intake, breach and DPIA updates, and ROPA completeness.
- Keep copied recipe files in your own source control so future changes are reviewed as normal app code.