
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
archetype-engine
Advanced tools
Type-safe backend generator for Next.js. Define entities once, get Drizzle schemas, tRPC APIs, Zod validation, and React hooks instantly.
The missing backend layer for AI-generated frontends.
Define entities in TypeScript. Get production-ready backends instantly.
const Product = defineEntity('Product', {
fields: {
name: text().required().min(1).max(200),
price: number().required().positive(),
stock: number().integer().min(0).default(0),
}
})
Run npx archetype generate → get:
| Tool | What it does | What you still write |
|---|---|---|
| Prisma | Database schema → Types | API, validation, hooks |
| tRPC | Type-safe API | Schema, validation, CRUD |
| Zod | Validation schemas | Database, API, hooks |
| Archetype | Schema → Everything | Business logic only |
You're not replacing tools—you're generating the boilerplate.
# 1. Create a new Next.js project
npx create-next-app@latest my-app && cd my-app
# 2. Install Archetype
npm install archetype-engine
# 3. Initialize with a template
npx archetype init
# Choose from:
# - SaaS Multi-Tenant (Workspace, Team, Member)
# - E-commerce (Product, Order, Customer)
# - Blog/CMS (Post, Author, Comment)
# - Task Management (Project, Task, Label)
# 4. Generate code
npx archetype generate
# 5. Push to database and run
npx drizzle-kit push
npm run dev
🎉 Done! You now have a fully functional backend with type-safe APIs.
From a single entity definition, Archetype generates:
generated/
├── db/
│ └── schema.ts # Drizzle ORM tables (type-safe SQL)
├── schemas/
│ └── product.ts # Zod validation schemas
├── trpc/routers/
│ ├── product.ts # Full CRUD API:
│ │ # - list (with pagination, filters, search)
│ │ # - get (by ID)
│ │ # - create, createMany
│ │ # - update, updateMany
│ │ # - remove, removeMany
│ └── index.ts # Router aggregation
├── hooks/
│ └── useProduct.ts # React Query hooks:
│ # - useProducts(), useProduct(id)
│ # - useCreateProduct(), useUpdateProduct()
│ # - useRemoveProduct(), etc.
├── tests/ # 🆕 Auto-generated tests
│ ├── product.test.ts # - CRUD operation tests
│ └── setup.ts # - Validation & auth tests
├── docs/ # 🆕 Auto-generated API docs
│ ├── openapi.json # - OpenAPI 3.0 specification
│ ├── swagger.html # - Interactive Swagger UI
│ └── API.md # - Markdown documentation
└── seeds/ # 🆕 Auto-generated seed data
├── product.ts # - Realistic sample data
├── index.ts # - Dependency management
└── run.ts # - CLI seed script
15 lines of entity code → 1,400+ lines of production-ready backend.
Define once:
const Order = defineEntity('Order', {
fields: {
orderNumber: text().required().unique(),
status: enumField('pending', 'paid', 'shipped'),
total: number().required().positive(),
},
relations: {
customer: hasOne('Customer'),
items: hasMany('OrderItem'),
},
behaviors: {
timestamps: true,
},
protected: 'all', // Requires authentication
})
Use immediately:
// In your React component
const { data: orders } = useOrders({
where: { status: 'pending' },
orderBy: { field: 'createdAt', direction: 'desc' }
})
const { mutate: createOrder } = useCreateOrder()
createOrder({
orderNumber: 'ORD-001',
status: 'pending',
total: 99.99
})
No API boilerplate. No manual validation. No CRUD repetition. Just works.
npx archetype view| Template | Perfect For | Entities Included |
|---|---|---|
| SaaS Multi-Tenant | Team collaboration apps | Workspace, Team, Member + roles |
| E-commerce | Online stores, marketplaces | Product, Customer, Order, OrderItem |
| Blog/CMS | Content platforms, news sites | Post, Author, Comment |
| Task Management | Todo apps, kanban boards | Project, Task, Label |
📚 Full docs: archetype-engine.vercel.app
Popular guides:
Tools like v0.dev, Bolt.new, and Cursor generate beautiful UIs but:
You get a gorgeous frontend that doesn't connect to anything real.
Archetype generates the missing backend layer:
Use case: Generate UI with v0 → Add backend with Archetype → Deploy to production.
Archetype provides a suite of commands organized by namespace to avoid conflicts with your Next.js project:
npx archetype init # Interactive setup with entity templates
npx archetype generate # Generate all code from entities
npx archetype view # View ERD diagram in browser (port 3333)
npx archetype docs # View OpenAPI/Swagger UI (port 3334)
npx archetype validate # Validate manifest without generating
npx archetype init)New projects automatically get these npm scripts:
{
"scripts": {
// Archetype - Generation & Docs
"archetype:generate": "archetype generate",
"archetype:view": "archetype view",
"archetype:docs": "archetype docs",
"archetype:check": "archetype validate",
// Database - Schema & Data
"db:push": "drizzle-kit push",
"db:studio": "drizzle-kit studio",
"db:seed": "tsx generated/seeds/run.ts",
"db:seed:reset": "tsx generated/seeds/run.ts --reset",
// Testing
"test:api": "vitest run generated/tests"
}
}
Initial setup:
npm run archetype:generate # Generate code
npm run db:push # Create database schema
npm run db:seed # Add sample data
npm run dev # Start dev server
Development loop:
# Edit archetype/entities/product.ts
npm run archetype:generate # Regenerate code
npm run db:push # Update schema
npm run dev # Test changes
Documentation & validation:
npm run archetype:view # View entity relationships
npm run archetype:docs # Browse API endpoints
npm run archetype:check # Validate entity definitions
We welcome contributions! See CONTRIBUTING.md for:
MIT - Use freely in commercial and open-source projects.
Built with ❤️ for developers tired of writing boilerplate.
FAQs
Type-safe backend generator for Next.js. Define entities once, get Drizzle schemas, tRPC APIs, Zod validation, and React hooks instantly.
We found that archetype-engine demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.