Skip to main content

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.

FactDetail
EnginePostgreSQL 16 with pgvector in Compose
AccessPrisma 7 through DatabaseService
PoolerPgBouncer for the app. DIRECT_DATABASE_URL for migrations
IDsUUID v7 default on operational models that were read
TenanttenantId and usually @@unique([id, tenantId])
Soft deletedeletedAt 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​

FileDomainModels
00-config.prismaReference data, global2
10-tenant.prismaTenancy6
11-identity.prismaIdentity10
12-platform.prismaFiles, connections, outbox, audit11
20-catalog.prismaCatalog5
21-channel.prismaChannel6
22-partner.prismaVendor, courier2
30-warehouse.prismaWarehouse3
31-inventory.prismaInventory9
32-procurement.prismaProcurement7
40-customer.prismaCustomer4
41-order.prismaOrder4
42-fulfillment.prismaFulfillment6
43-shipment.prismaShipping6
44-return.prismaReturns3
50-finance.prismaInvoice13
51-settlement.prismaPayouts and lines, every source8
52-wallet.prismaWallet4
53-receivable.prismaReceivables, fee audit, cases, rate cards8
54-reconciliation-ops.prismaRuns, periods, bank6
55-finance-accounts.prismaPayment accounts, accounting systems2
56-journal.prismaLedger accounts, vouchers, ERP sync5
60-promotion.prismaPromotion3
61-notification.prismaNotifications3
70-conversation.prismaWhatsApp7
71-ai.prismaAI and voice7

Counts are model declarations and sum to 150.

Status fields that drive behavior​

ModelEnforced by
Order.statusTwo TypeScript maps
FulfillmentOrderfulfillment-state-machine.ts
ReturnRequestreturn-state-machine.ts
PurchaseOrderpurchase-order-state-machine.ts
GoodsReceiptgoods-receipt-state-machine.ts
Channel statusUser update versus circuit breaker
ShipmentShipment services and courier webhooks
OutboxEventPENDING, 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.

Next​

Entity map, Relationships, Transactions, Migrations.