Database overview
Schema directory: pnxt-api-nestjs/prisma/schema. 135 models and 126 enums across 24 files. This page is an orientation map, not a column dictionary.
| Fact | Detail |
|---|---|
| Engine | PostgreSQL 16 with pgvector in Compose |
| Access | Prisma 7 through DatabaseService |
| Pooler | PgBouncer for the app. DIRECT_DATABASE_URL for migrations |
| IDs | UUID v7 default on operational models that were read |
| Tenant | tenantId and usually @@unique([id, tenantId]) |
| Soft delete | deletedAt on many aggregates. Filter deletedAt: null where the column exists |
Transition legality is application code. The money tables are the exception: triggers in the settlement migration keep PayoutLine, JournalLine and ImportRawRow insert-only, keep BankStatementLine insert-only except matchStatus, refuse journal lines dated in a locked FinancePeriod, and refuse an unbalanced voucher at commit. See Settlements.
File index
| File | Domain | Models |
|---|---|---|
00-config.prisma | Reference data, global | 2 |
10-tenant.prisma | Tenancy | 6 |
11-identity.prisma | Identity | 10 |
12-platform.prisma | Files, connections, outbox, audit | 11 |
20-catalog.prisma | Catalog | 5 |
21-channel.prisma | Channel | 6 |
22-partner.prisma | Vendor, courier | 2 |
30-warehouse.prisma | Warehouse | 3 |
31-inventory.prisma | Inventory | 9 |
32-procurement.prisma | Procurement | 7 |
40-customer.prisma | Customer | 4 |
41-order.prisma | Order | 4 |
42-fulfillment.prisma | Fulfillment | 6 |
43-shipment.prisma | Shipping | 6 |
44-return.prisma | Returns | 3 |
50-finance.prisma | Invoice | 13 |
51-settlement.prisma | Payouts and lines, every source | 8 |
52-wallet.prisma | Wallet | 4 |
53-receivable.prisma | Receivables, fee audit, cases, rate cards | 8 |
54-reconciliation-ops.prisma | Runs, periods, bank | 6 |
55-finance-accounts.prisma | Payment accounts, accounting systems | 2 |
56-journal.prisma | Ledger accounts, vouchers, ERP sync | 5 |
60-promotion.prisma | Promotion | 3 |
61-notification.prisma | Notifications | 3 |
70-conversation.prisma | 7 | |
71-ai.prisma | AI and voice | 7 |
Counts are model declarations and sum to 150.
Status fields that drive behavior
| Model | Enforced by |
|---|---|
Order.status | Two TypeScript maps |
FulfillmentOrder | fulfillment-state-machine.ts |
ReturnRequest | return-state-machine.ts |
PurchaseOrder | purchase-order-state-machine.ts |
GoodsReceipt | goods-receipt-state-machine.ts |
Channel status | User update versus circuit breaker |
Shipment | Shipment services and courier webhooks |
OutboxEvent | PENDING, PROCESSING, PROCESSED, DEAD |
Full maps: State machines.
Partitioning
PartitionMaintenanceService crons daily at 02:00 and weekly, on the worker. Which tables are partitioned, and the retention rules, were not line-read. Treat them as unknown.