Model driven application framework: TypeScript models -> Postgres schema, codegen, and composable pipelines.
Ratchet turns a directory of TypeScript model files into a Postgres schema, a REST API, a console, and auth — with composable pipelines wherever you need custom logic.
bun add @egig/ratchet- Bun 1.3+
- A Postgres database, reachable via a
DATABASE_URLconnection string
bunx @egig/ratchet initThis writes package.json, tsconfig.json, ratchet.config.ts, models/example.model.ts, migrations, and a .gitignore into the current directory. It never overwrites a file that's already there, so it's safe to re-run in a partially set-up directory.
import { defineModel, field } from '@egig/ratchet/core';
export const Example = defineModel('examples', {
fields: {
name: field.string({ required: true, maxLength: 255 }),
},
});bun run generate # regenerate .ratchet/*, then drizzle-kit generate -> SQL migration files
bun run migrate # drizzle-kit migrate — apply the pending SQL migration files
bun run serve # boot the API + consoleratchet serve reads ratchet.config.ts and the generated registry and boots a listening server. It mounts, in order:
/api/auth/*— register/login/logout/me/api/:model— the generic REST router, one route family for every model (filtering, sorting, cursor and offset pagination,?include=relations)/console— the generated console SPA
Full guides (models & fields, pipelines, the REST API, CLI reference) are in docs/.
MIT