Prood
Packages

@prood/platform

Built-in commerce engine — Neon Postgres, Drizzle ORM, row-level security, and Admin API.

@prood/platform is the default commerce engine. It provides a full CommerceAdapter and AdminAPI backed by Neon Postgres with Drizzle ORM and forced row-level security.

Installation

pnpm add @prood/platform

Requires DATABASE_URL environment variable pointing to a Neon Postgres instance.

Quick start

import { createPlatformAdapter } from '@prood/platform'

const { adapter, admin } = await createPlatformAdapter()

// Catalog (storefront scope)
const products = await adapter.getProducts({ page: 1, limit: 20 })
const product = await adapter.getProduct('prod_abc')
const categories = await adapter.getCategories()
const store = await adapter.getStoreInfo()

// Admin operations
const stats = await admin.getDashboardStats()
const newProduct = await admin.createProduct({ name: { en: 'T-Shirt' }, ... })

Tenant scoping

All operations must run inside a tenant scope:

import { withTenant } from '@prood/platform'

await withTenant('org_demo', async () => {
  const products = await adapter.getProducts({ page: 1, limit: 10 })
  // RLS filters to org_demo rows only
})

withTenant() sets app.current_org_id in a Postgres transaction. Forced RLS ensures no cross-tenant leakage.

Database setup

# From repo root
pnpm db:migrate

This runs:

  1. migrateDrizzle() — applies Drizzle schema migrations
  2. applyTenantIsolation() — adds organization_id columns + RLS policies
  3. seedDrizzle() — seeds demo catalog tagged with org_demo

Manual migration

import { migrateDrizzle, seedDrizzle, applyTenantIsolation } from '@prood/platform'

await migrateDrizzle()
await applyTenantIsolation()
await seedDrizzle()

Implemented domains

DomainAdapter methodsAdmin methods
CataloggetProducts, getProduct, getCategoriesCRUD products, categories
StoregetStoreInfoUpdate store settings
CartFull cart lifecycle
CheckoutplaceOrder
OrdersgetOrders, getOrderList, fulfill, refund
CustomersgetCustomerList, detail
InventoryUpdate stock levels
DashboardgetDashboardStats

Schema

Drizzle schema in packages/platform/src/database/drizzle/schema/:

TableTenant-scopedDescription
productsYesProduct catalog
product_variantsYesSKU variants
product_optionsYesConfigurable options
categoriesYesCategory tree
cartsYesShopping carts
cart_itemsYesCart line items
ordersYesPlaced orders
order_itemsYesOrder line items
customersYesCustomer profiles
store_infoYes (composite PK)Store settings per org
couponsYesDiscount codes

Exports

// Adapter factory
export { createPlatformAdapter } from '@prood/platform'

// Tenant scoping
export { withTenant, getDb, initDrizzle } from '@prood/platform'

// Admin API
export { createAdminAPI } from '@prood/platform'

// Migrations
export { migrateDrizzle, seedDrizzle, applyTenantIsolation } from '@prood/platform'

// Schema (for direct queries)
export * from '@prood/platform/database/drizzle'

Configuration

VariableDefaultDescription
DATABASE_URLNeon Postgres connection string
COMMERCE_CURRENCYEURDefault store currency
ADMIN_EMAILSeed admin email
ADMIN_PASSWORDSeed admin password

On this page