A TypeScript data layer where entities, DTOs, validation, serialization, OpenAPI and CRUD all derive from one schema — at compile time.
import {
defineRepository,
schemaOf,
type CreateDTO,
type Entity,
type HasDefault,
type PrimaryKey,
type Serial,
type Sql,
type Table,
} from '@zmdb/core';
// 1 — declare the table once, as a type
export interface User extends Table<'users'> {
id: number & Sql<'integer'> & Serial & PrimaryKey;
email: string & Sql<'text'>;
role: ('admin' | 'user') & HasDefault;
}
// 2 — every other shape is derived from that declaration
type Row = Entity<User>; // { id; email; role }
type NewUser = CreateDTO<User>; // { email; role? } — no id: the database makes it
// 3 — validated CRUD in one line
const users = defineRepository(schemaOf<User>(), driver);
await users.create({ email: 'a@b.com' }); // validated before any SQLThe whole framework is built around one guarantee: your schema is the single source of truth, and nothing can silently drift from it.
One schema drives entity / create / update / read DTOs, validators, serializers, OpenAPI and migrations. Change a column and anything that no longer fits fails to compile.
No proxies, no identity map, no change tracking. Reads return plain inert objects; writes are explicit. That is where the speed comes from.
is / assert / validate / stringify compile to straight-line JavaScript at build time — no runtime parser, no reflection.
Typed select / insert / update / delete with real joins, aggregations and full-text search — plus typed Get / List / Search DTOs on top.
Composable and ESM-only. Combine the cohesive data, app, and HTTP facade with a database vertical, or use provider-neutral AI tools, opt-in client/framework, gRPC, NATS, RabbitMQ, Redis, MCP, OpenTelemetry, or another implementation package on its own.
@zmdb/clientDependency-free HTTP transport, deterministic request planning, cancellation, authentication, and typed errors.
@zmdb/client/reactReact context, query, and mutation lifecycle bindings for generated HTTP clients.
@zmdb/client/react-nativeReact Native AppState, connectivity, credential-store, and offline lifecycle policy over the React client binding.
@zmdb/client/angularAngular dependency injection, signals, Observable cancellation, and request-local generated-client ownership.
@zmdb/client/vueVue plugin, reactive query and mutation composables, scope cancellation, and per-application SSR isolation.
@zmdb/client/svelteTyped Svelte context, subscription-aware stores, stale-result suppression, and lifecycle cancellation.
@zmdb/sveltekitRequest-local server/client loads, explicit credential forwarding, native errors, and navigation cancellation.
@zmdb/client/solidSolid context, native resources, owner cancellation, stale-result suppression, and native Suspense/error propagation.
@zmdb/nextRequest-scoped App Router server clients and browser bindings over @zmdb/client/react.
@zmdb/nuxtRequest-scoped Nitro transport, native hydration, and browser bindings over @zmdb/client/vue.
@zmdb/query-compilerSELECT / INSERT / UPDATE / DELETE + dialects, joins, aggregations, FTS, set-ops, and schema-object DDL.
@zmdb/migrationsSchema snapshots, deterministic diffs and DDL plans, ledger and embedded runners, catalog introspection, and declaration emission.
@zmdb/schema-coreSchema DSL + type derivation (Entity / Create / Update / read DTOs), relations, OpenAPI, seeding, custom types.
@zmdb/aiProvider-neutral tool documents, bounded chat orchestration, shared invocation, and OpenAPI-derived tools.
@zmdb/ai/anthropicOpt-in Anthropic Messages API driver over the provider-neutral chat contract.
@zmdb/ai/langchainOpt-in LangChain structured-tool fields, validation dispatch, and result serialization over @zmdb/ai.
@zmdb/ai/vercelOpt-in Vercel AI SDK tool fields with caller-owned schema branding over @zmdb/ai.
@zmdb/mcpTransport-neutral MCP client/server cores with authenticated identity, validation, and call budgets.
@zmdb/protobufDependency-free protobuf calls, descriptors, generated-code wire ABI, and typed gRPC artifacts.
@zmdb/aot-validatorCompiler-free is / assert / validate / equals / random, unions, transforms, JSON Ser/De, errors, and generated-code runtime helpers.
@zmdb/compilerThe single TypeScript front end for reflection, AOT emission, project compilation, unplugin and Metro adapters, lint rules, and project config.
@zmdb/repositoryAuto-validating CRUD, transactions, populate, read-replicas, lifecycle events, framework adapters.
@zmdb/mssqlComplete SQL Server compilation, migrations, structural execution, introspection, refusals, and packed live acceptance.
@zmdb/postgresComplete PostgreSQL dialect, migrations, catalog introspection, structural pg driver, cursors, and cancellation.
@zmdb/sqliteComplete SQLite dialect, migrations, introspection, embedded runner, and structural node:sqlite driver.
@zmdb/mysqlComplete MySQL dialect, migrations, introspection, structural mysql2 driver, and packed real-server acceptance.
@zmdb/appProtocol-neutral metadata, dependency injection, modules, lifecycle, commands, events, CQRS, state, and observability ports.
@zmdb/jobsTyped queues, workers, dead letters, scheduling, leases, and the built-in SQLite memory backend.
@zmdb/jobs-postgresPostgreSQL job storage over caller-owned pools and clients.
@zmdb/app/otelOpenTelemetry API adaptation over caller-owned tracers and meters, with no SDK, exporter, or ambient global context.
@zmdb/transport/grpcTyped grpc-js servers and clients over generated protobuf artifacts, with streaming, deadlines, metadata, and bounded shutdown.
@zmdb/transport/natsCore NATS wildcard and queue-group messaging over the public application transport strategy contract.
@zmdb/transport/rabbitmqRabbitMQ topic transport with positive prefetch, confirmed delayed retries, and owned dead-letter topology.
@zmdb/transport/redisLossy Redis Pub/Sub messaging with concrete-channel dispatch and correlated request/reply.
@zmdb/webHTTP controllers, routing, request pipelines, OpenAPI, gateways, testing, and runtime adapters over @zmdb/app.
@zmdb/coreThe cohesive application facade: a lazy root plus focused schema, SQL, validator, ORM, web, compiler, migrations, and testing entries. It contains no implementation logic and does not re-export opt-in integrations.
Four pages get you from nothing to a validated, typed, queried table.
The union of the MikroORM, Drizzle, Typia and NestJS doc surfaces. Every capability page is written in full; the ones that are anti-patterns for a zero-overhead, no-proxy, AOT layer are excluded and explained rather than quietly missing. Press ⌘K to search all of it.
Introduction · Why zmdb · Quick Start · Installation · AOT Setup (transformer) · +9 more
Configuration · Testing · Tooling: compiler, migrations and CLI · CLI Overview · Config File · +24 more
Schema Declaration · Column Types · Type Derivation · Tag Reference · Relations · +60 more
is() · assert() · validate() · Special Tags · Shallow Validation · +17 more
@zmdb/web — Overview · Controllers & Routing · Typed Request Context · Dependency Injection · Modules & Providers · +43 more
Generated HTTP Client · Client Applications · React Client · Angular Client · Vue Client · +11 more
PostgreSQL · MySQL · SQLite · CockroachDB · SQL Server · +27 more
Logging · Query Performance · Serverless Performance · Deployment · Connections and Shutdown · +17 more
LLM Function Calling · LLM Schemas · Structured Output · Provider Schema Strategies · Chat & Agents · +27 more
Runtime Foundation · Architecture · FAQ · Gotchas · Goodies · +6 more