Deepkit
modular high-performance TypeScript framework
Install / Use
/learn @marcj/DeepkitREADME
<a href="https://www.npmjs.com/package/@deepkit/type"><img alt="npm" src="https://img.shields.io/npm/v/@deepkit/type.svg" /></a> <a href="https://discord.gg/U24mryk7Wq"><img alt="Discord" src="https://img.shields.io/discord/759513055117180999?label=Discord" /></a> <a href="https://github.com/deepkit/deepkit-framework/actions/workflows/main.yml"><img alt="CI" src="https://github.com/deepkit/deepkit-framework/actions/workflows/main.yml/badge.svg" /></a> <a href="https://opensource.org/licenses/MIT"><img alt="License" src="https://img.shields.io/badge/License-MIT-blue.svg" /></a>
</div>TypeScript types disappear at runtime. Deepkit changes that.
Define your types once and use them everywhere—validation, serialization, database, HTTP, RPC, and dependency injection. No schema duplication. No code generation. Just TypeScript.
The Problem
In traditional TypeScript development, you define your types, then redefine them for runtime use:
// 1. TypeScript interface
interface User {
id: number;
email: string;
createdAt: Date;
}
// 2. Zod schema for validation
const UserSchema = z.object({
id: z.number(),
email: z.string().email(),
createdAt: z.date(),
});
// 3. TypeORM entity for database
@Entity()
class UserEntity {
@PrimaryColumn()
id!: number;
@Column()
email!: string;
@Column()
createdAt!: Date;
}
// Three definitions for the same thing.
The Solution
With Deepkit, one definition works everywhere:
import { PrimaryKey, AutoIncrement, Email, MinLength } from '@deepkit/type';
class User {
id: number & PrimaryKey & AutoIncrement = 0;
email: string & Email = '';
createdAt: Date = new Date();
constructor(public username: string & MinLength<3>) {}
}
// Validation, serialization, database, HTTP, DI — all from the same type.
Features
- Runtime Types — TypeScript types preserved at runtime via a compiler plugin
- Type Annotations — Validation constraints via intersection types (
string & MinLength<3>) - Zero-Decorator DI — Dependency injection works on pure TypeScript, no
@Injectable()needed - End-to-End Types — Same types for frontend, API, transport, and database
- Type-First ORM — Database schema inferred directly from TypeScript types
- Binary RPC — Type-safe WebSocket/TCP communication with automatic serialization
- High Performance — JIT-compiled validation, serialization, and dependency injection
- Modular — Use only what you need from 40+ independent packages
Quick Start
npm init @deepkit/app@latest my-app
cd my-app
npm start
Runtime Types
The core innovation. TypeScript types become available at runtime:
import { cast, validate, serialize, typeOf } from '@deepkit/type';
interface User {
id: number;
registered: Date;
username: string;
}
// Deserialize JSON to typed objects (strings become Dates, etc.)
const user = cast<User>({
id: 1,
registered: '2024-01-15T10:30:00Z',
username: 'peter'
});
user.registered instanceof Date; // true
// Validate data against type
validate<User>({ id: 'not a number' });
// [{ path: 'id', message: 'Not a number' }]
// Serialize to JSON-safe output
serialize<User>(user);
// { id: 1, registered: '2024-01-15T10:30:00.000Z', username: 'peter' }
// Full runtime type reflection
const type = typeOf<User>();
Type-Safe HTTP
Types flow through to your HTTP layer with automatic validation and serialization:
import { App } from '@deepkit/app';
import { FrameworkModule } from '@deepkit/framework';
import { http, HttpBody } from '@deepkit/http';
import { MinLength, Positive, Email, PrimaryKey, AutoIncrement } from '@deepkit/type';
class User {
id: number & PrimaryKey & AutoIncrement = 0;
createdAt: Date = new Date();
constructor(
public username: string & MinLength<3>,
public email: string & Email
) {}
}
class UserController {
@http.GET('/user/:id')
get(id: number & Positive): User {
// id is guaranteed to be a positive number
return new User('peter', 'peter@example.com');
}
@http.POST('/user')
create(body: HttpBody<Pick<User, 'username' | 'email'>>): User {
// body is validated and deserialized
return new User(body.username, body.email);
}
}
new App({
controllers: [UserController],
imports: [new FrameworkModule({ debug: true })]
}).run();
More Features
Dependency Injection — Types are injection tokens. No decorators required.
class UserService {
constructor(private db: Database, private logger: Logger) {}
}
ORM — Database schema from TypeScript types. Supports PostgreSQL, MySQL, SQLite, MongoDB.
const db = new Database(new SQLiteDatabaseAdapter('app.db'), [User]);
await db.persist(new User('peter', 'peter@example.com'));
RPC — Type-safe remote procedure calls over WebSocket/TCP with automatic serialization. Learn more →
Packages
Core
@deepkit/type— Runtime type system, validation, serialization@deepkit/type-compiler— TypeScript transformer@deepkit/injector— Dependency injection@deepkit/app— Application container and CLI
Web
@deepkit/http— HTTP router with automatic serialization@deepkit/rpc— Binary RPC protocol@deepkit/framework— Full framework integrating all components
Database
@deepkit/orm— Database-agnostic ORM@deepkit/sql— SQL query builder@deepkit/postgres,@deepkit/mysql,@deepkit/sqlite,@deepkit/mongo
Infrastructure
@deepkit/broker— Message broker and cache@deepkit/filesystem— Virtual filesystem (local, S3, GCS, FTP)@deepkit/logger— Structured logging@deepkit/event— Event system
Documentation
Community Packages
- OpenAPI — Automatic OpenAPI doc and Swagger UI generation
- Serverless Adapter — Run on AWS Lambda, Azure, Digital Ocean
- REST — Declarative REST API development
- Stripe — Stripe API and webhook integration
- GraphQL — GraphQL server support
- Apollo Server — Apollo integration
- Remix — Remix framework integration
- Remix Validated Form — Form validation for Remix
- Nx Webpack Plugin — Nx build tool integration
Examples
- Full Application — HTTP, RPC, CLI, and ORM
- Minimal HTTP Server — HTTP router without full framework
- Bookstore — REST CRUD API with API Console
- Webpack — Type compiler with Webpack
- GraphQL + ORM — GraphQL server with ORM
- Remix — Remix with Deepkit backend
- Angular SSR — Angular SSR with RPC
Contributing
See DEVELOPMENT.md for setup instructions.
git clone https://github.com/deepkit/deepkit-framework.git
cd deepkit-framework
npm install
npm run postinstall # Required: builds the type compiler
npm run build
License
MIT
Related Skills
node-connect
345.4kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
104.6kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
Writing Hookify Rules
104.6kThis skill should be used when the user asks to "create a hookify rule", "write a hook rule", "configure hookify", "add a hookify rule", or needs guidance on hookify rule syntax and patterns.
review-duplication
100.0kUse this skill during code reviews to proactively investigate the codebase for duplicated functionality, reinvented wheels, or failure to reuse existing project best practices and shared utilities.
