Skip to content

Database & Schema

The Nexical Ecosystem uses a unique Additive Schema approach. Instead of a single monolithic schema.prisma file, each module defines its own models.yaml.

The platform provides a singleton db client that is automatically generated to include all models from all modules.

Location: src/lib/core/db.ts

import { db } from '@/lib/core/db';
const users = await db.user.findMany();

Modules extend the database by placing a models.yaml file in their root.

modules/crm/models.yaml
models:
Contact:
fields:
id: { type: String, attributes: ['@id', '@default(cuid())'] }
email: { type: String, attributes: ['@unique'] }
# Extending a Core Model
User:
fields:
vipStatus: { type: Boolean, attributes: ['@default(false)'] }

The build system (Arc) compiles these fragments into the final Prisma schema.