NAMEPLATE NESTJS · PRISMA · POSTGRESQL 16 · SUPABASE
Backend architecture · repository status · updated 2026-09-05

Design the truth.
Then build it.

The single source of truth for Nameplate backend architecture and implementation status. Statuses distinguish the 28-model NestJS/Prisma foundation, usable API workflows, and planned work so a modeled table is never mistaken for a production-ready feature.

34Catalog tables
28DB models + migrations
2Built-out API slices
14Partial API surfaces
6Deferred tables
00

What is real today.

This page is grounded in the checked-in repository, not the target architecture. The production direction is NestJS + Prisma + Supabase Postgres; the currently connected local demo path is FastAPI + SQLAlchemy + SQLite.

NestJS / Prisma

Foundation and guarded slices

28 Prisma models, three forward migrations, tenant transaction/RLS support, Supabase JWT verification, membership/RBAC/property-scope guards, user invitations, and a clean build.

  • 22 tests passing across 9 Jest suites
  • Assets: CRUD, lookup, retire, and atomic custody move
  • Service events: CRUD and atomic part-usage creation
  • Sync: pull/push/block allocation; receipts are still in-memory
FastAPI / SQLite bridge

Active local integration path

HQ, Portal, and Field default to http://localhost:8080/api. The bridge has 14 SQLAlchemy models/tables, seeded demo data, QR routes, CRUD workflows, Supabase upsert helpers, and is the path used for the local interactive demo.

  • 24 Python tests passing
  • Runs with python3 -m backend_py.run
  • SQLite is a development/demo bridge, not the canonical cloud schema
Evidence: backend/README.md · backend/prisma/schema.prisma · backend_py/main.py · hq/src/api/client.ts · tests run 2026-09-05.
01

From scan to portfolio truth.

The backend has one job: turn field facts into a permanent, explainable asset record without blocking technicians when connectivity or data quality is imperfect.

01

Field action

A scan, move, inspection, repair, part swap, or turn finding happens offline or online.

Flutter + Drift
02

Idempotent API

NestJS validates identity, role, property scope, payload, and operation identity.

REST / OpenAPI 3.1
03

Atomic write

Prisma opens a transaction; facts, state mirrors, ledger entries, and audit rows commit together.

PostgreSQL 16
04

Derived truth

Workers reconcile rollups, shrinkage signals, SLA state, exports, and daily metrics.

Jobs + read replica
05

HQ decision

Every tile drills back to source rows. No number exists without lineage and a definition.

React HQ Console
Facts are append-only

Service, location, part usage, scans, turns, and audits are corrected by adding evidence—not deleting history.

State is a projection

Current asset location, status, cost, and service counts are fast mirrors derived from ledgers.

Tenant scope is structural

Every customer-owned row carries org_id; application guards and RLS both enforce it.

Offline is normal

UUIDv7 IDs, operation idempotency, dual timestamps, and monotonic change cursors are schema requirements.

02

The data domains.

The model stays relational because the valuable questions cross properties, assets, events, parts, people, and time. Domain boundaries organize ownership without breaking referential integrity.

Primary business spine · organization → property → building → unit → asset → asset_location / service_event → part_usage → part · with work_order and turn coordinating the work around those facts.
03

The shelves.

Each card states ownership, essential columns, integrity rules, and current repository maturity. API built means the principal guarded workflow exists; API partial means a wired endpoint or transaction exists but domain rules remain; DB foundation means the table is modeled, migrated, secured, and seeded without a complete API; Deferred means it is not modeled in the current 28-table V0 schema.

No tables match that filter.
04

What writes what.

The fastest architecture test is to trace a real field action through its transaction and verify the resulting rows can answer the future reporting question.

Service transaction

A repair must never exist without its costs, part lineage, asset state, work-order outcome, and audit evidence.

service_event + part_usage[] + part state + asset projection + work_order + audit_log

Move transaction

Close the previous custody interval, append the new interval, update current location, and record who confirmed it.

asset_location close + asset_location insert + asset current_* + audit_log

Turn completion

Freeze findings, generate work, update occupancy and missing state, start grace windows, and queue reconciliation work.

turn + turn_item[] + work_order[] + asset status + reconciliation_flag + audit_log
05

Supabase is infrastructure.

Supabase is the intended PostgreSQL/Auth/Storage infrastructure for the NestJS API. The repository also contains a working FastAPI + SQLite development bridge currently used by HQ, Portal, and Field defaults; it is not the long-term system-of-record architecture.

Local development

Fast, disposable, reproducible.

Use local PostgreSQL for the backend loop. Prisma migrations and the seed script remain the schema authority.

  • Prisma Studio for quick record inspection
  • Supabase local stack when testing Auth or Storage
  • Synthetic demo portfolio only—never production data
DATABASE_URL=postgresql://…@localhost:5432/nameplate_dev
PORT=3000
Hosted environments

Managed Postgres, same model.

Use separate Supabase projects for staging and production. Apply reviewed migrations through CI; do not hand-edit production tables in the dashboard.

  • Runtime uses the appropriate pooled/session connection
  • Migrations and admin tooling use a direct connection
  • Auth identities map 1:1 into user_account
DATABASE_URL=postgresql://…pooler…/postgres
DIRECT_URL=postgresql://…db.project…/postgres
SUPABASE_URL=https://project.supabase.co
Application boundary

Clients call Nameplate API.

HQ and Field do not directly mutate core tables. The API owns custody, cost rollups, corrections, approvals, and cross-row transactions.

  • JWT identity comes from Supabase Auth
  • NestJS resolves active org, role, and property scope
  • RLS is defense-in-depth, not the only authorization layer
Managed schemas

Keep ownership explicit.

Supabase owns auth and storage. Nameplate owns public application tables and never duplicates passwords or file blobs.

  • auth.usersuser_account.id
  • storage.objectsmedia.storage_key
  • Signed upload URLs keep files off the API process
06

Build it in verified loops.

Repository badges show what exists in this checkout as of 2026-09-05; they are maintained from code, migrations, and tests. Checkboxes are a separate, browser-local verification record and do not change implementation status. Each phase ends with an evidence gate.

0%0 of 0 manually verified