Archetype
TL;DR: Define your data model once. Get database, validation, API, and hooks generated automatically.
// You write this
const User = defineEntity('User', {
fields: {
email: text().required().email(),
name: text().required(),
},
protected: 'write',
})
// You get this
generated/
├── db/schema.ts → Drizzle tables
├── schemas/user.ts → Zod validation
├── trpc/routers/user.ts → CRUD API
├── hooks/useUser.ts → React hooks
├── tests/user.test.ts → Comprehensive tests
├── docs/openapi.json → API documentation
├── seeds/user.ts → Sample data
└── i18n/en/user.json → Translation keys
What It Generates
| You Define | You Get |
|---|---|
text().email() | Email column + Zod .email() validation |
hasMany('Post') | Foreign keys + joined queries |
protected: 'write' | Public reads, auth-protected mutations |
behaviors: { timestamps: true } | createdAt + updatedAt columns |
30-Second Start
npx create-next-app my-app && cd my-app
npm install archetype-engine
npx archetype init --yes
npx archetype generate
npx drizzle-kit push && npm run dev
Why Use This?
Without Archetype:
- Write Drizzle schema
- Write Zod schema (duplicate field definitions)
- Write tRPC router (duplicate again)
- Write React hooks
- Keep all 4 in sync manually
With Archetype:
- Define entity once
- Run
npx archetype generate - Done