Capacitor
Universal Data Modeling Language
Define your data model once and generate schemas, migrations, and SDKs for any database. Switch from PostgreSQL to MongoDB without rewriting your data layer. Support multiple databases simultaneously. Keep frontend and backend teams synchronized with a single source of truth. Built to work seamlessly with AI coding agents.
Database Flexibility Without the Cost
Define your data model once and generate schemas, migrations, and SDKs for PostgreSQL, MongoDB, DynamoDB, Cassandra, and more. Switch databases or support multiple data stores without rewriting your data access layer. Perfect for multi-cloud or migration scenarios.
Safe Migrations, Every Time
Generate database migrations automatically from schema changes. Capacitor analyzes your changes and produces safe, backward-compatible migrations. No more hand-crafted ALTER TABLE scripts. No more production migration disasters. Version control your data model, not your SQL.
Shared Data Models Across Teams
Define entities once, use them everywhere. Frontend teams get TypeScript SDKs. Backend teams get repositories and migrations. Data teams get documentation and lineage tracking. Everyone works from the same source of truth. No more schema drift between services or "I didn't know that field existed" surprises.
Supported Databases
Why Capacitor?
Stop rewriting schemas for every database. Define your data model once and let Capacitor handle the rest.
AI-First Design
Optimized for LLM code generation with clear, unambiguous syntax that both humans and AI can easily understand and write.
Universal Schema
Write one schema that works across SQL and NoSQL databases. No more maintaining separate schemas for each database.
Smart Code Generation
Generate type-safe SDKs, ORMs, migration scripts, and infrastructure code for your target database.
Native + Shim Architecture
Use native database features when available. Capacitor automatically generates application-level shims for missing features.
Built-in Validation
Built-in linter catches issues before deployment. Get warnings about shimmed features and errors for impossible operations.
Easy Migration
Switching databases? Capacitor analyzes your schema and generates migration plans showing what works and what needs adjustment.
Enterprise Ready
Built-in support for multi-tenancy, audit trails, soft deletes, schema versioning, and other enterprise patterns.
Repository Pattern
Define type-safe repositories, DTOs, and queries as part of your schema. Generate complete data access layers with proper separation of concerns.
How It Works
Capacitor uses a generator philosophy similar to Protocol Buffers and Smithy. Define your schema once, generate everything you need.
Define Your Schema
Write your data model in Capacitor's simple, expressive syntax. Define models, relationships, constraints, and validations.
model Product {
id String
name String
price Decimal
}Generate Code
Run the Capacitor CLI to generate database schemas, migrations, type-safe SDKs, and infrastructure code.
$ capacitor generate \
--target postgresql \
--output ./generated
✓ Generated schema.sql
✓ Generated SDKUse in Your App
Import the generated SDK and enjoy full type safety, autocompletion, and validation.
const product = await
db.product.create({
name: "Widget",
price: 19.99
});The Generator Philosophy
Capacitor follows the same philosophy as successful tools like Protocol Buffers and Smithy: define your contract in a generative domain language, then use generators to produce target-specific implementations. This approach ensures consistency, reduces errors, and makes multi-database support practical.
Native Implementation
When a database supports a feature natively (like PostgreSQL enums), Capacitor generates native code.
Automatic Shims
When a feature isn't native (like enums in MongoDB), Capacitor generates application-level shims automatically.
Getting Started
Get up and running with Capacitor in minutes.
1. Install Capacitor CLI
$ npm install -g @capacitordata/cli
# or
$ brew install capacitor2. Create Your First Schema
model User {
id String @id @default(uuid)
email String @unique
name String
createdAt DateTime @default(now)
}3. Generate for Your Database
# PostgreSQL
$ capacitor generate --target postgresql --output ./generated
# MongoDB
$ capacitor generate --target mongodb --output ./generated
# DynamoDB
$ capacitor generate --target dynamodb --output ./generated4. Use the Generated SDK
import { db } from './generated';
const user = await db.user.create({
email: 'alice@example.com',
name: 'Alice'
});
const users = await db.user.findMany({
where: { email: { contains: '@example.com' } }
});Next Steps
- Read the full documentation
Complete guide to Capacitor's features and syntax
- Explore generator implementations
See how each database implements Capacitor features
- Check out example projects
Real-world examples and best practices