DEV Community

N Akita
N Akita

Posted on

Hekireki — Generate Validation Schemas, ORM Models, and ER Diagrams from Prisma

Hekireki

I built Hekireki, a tool that generates validation schemas, ORM models, and ER diagrams from your Prisma schema.----u

img

Hekireki

Hekireki is a tool that generates validation schemas, ORM models, and ER diagrams from Prisma schemas — supporting TypeScript, Python, Go, Rust, Elixir, Ruby, and PHP.

Features

TypeScript Validation Libraries

  • 💎 Automatically generates Zod schemas from your Prisma schema
  • 🤖 Automatically generates Valibot schemas from your Prisma schema
  • 🏹 Automatically generates ArkType schemas from your Prisma schema
  • ⚡ Automatically generates Effect Schema from your Prisma schema
  • 📦 Automatically generates TypeBox schemas from your Prisma schema
  • 📋 Automatically generates AJV-compatible JSON Schema objects from your Prisma schema

ORM / Schema Generation (Multi-Language)

  • 🗄️ Automatically generates Drizzle ORM table schemas and relations from your Prisma schema
  • 🐍 Automatically generates SQLAlchemy models (Python) — with Mapped[T] type hints, relationships, enums, composite keys, and index support
  • 🐹 Automatically generates GORM models (Go) — with struct tags, JSON tags, relationships, enums, composite keys, and index support
  • 🦀 Automatically generates Sea-ORM entities (Rust) —…

What it generates

Everything comes from a single schema.prisma:

Why I built it

At work, our ER diagrams were maintained by hand. Every schema change meant updating the diagram manually, and the diagram slowly drifted away from reality.

I tried to automate it with existing ER diagram generators — but our database had no physical foreign keys. Existing generators read relations from foreign keys, so all I got was a diagram full of tables with zero lines between them.

So I wrote a generator at work that could draw relations without foreign keys. That experience made me want to build a proper, open-source version. And once you have the pipeline, you realize it doesn't stop at diagrams: tables, columns, and relations are all already in schema.prisma, so validation schemas, ORM models, and docs can be generated from the same single source of truth.

Usage

npm install -D hekireki
🔥 ข่าวด่วน: nakita/hekireki generate validation schemas orm models and er diagrams from prisma aaj - Kapook Update 2025 🔥 ข่าวด่วน: nakita/hekireki generate validation schemas orm models and er diagrams from prisma aaj - Kapook Update 2025

Add generator blocks to your schema.prisma — pick only what you need:

datasource db {
    provider = "sqlite"
}

generator Hekireki-Zod {
    provider = "hekireki-zod"
    type     = true
    comment  = true
    relation = true
}

generator Hekireki-Drizzle {
    provider = "hekireki-drizzle"
}

generator Hekireki-ER {
    provider = "hekireki-mermaid-er"
}
🔥 ข่าวด่วน: nakita/hekireki generate validation schemas orm models and er diagrams from prisma aaj - Kapook Update 2025 🔥 ข่าวด่วน: nakita/hekireki generate validation schemas orm models and er diagrams from prisma aaj - Kapook Update 2025

Then run:

npx prisma generate
🔥 ข่าวด่วน: nakita/hekireki generate validation schemas orm models and er diagrams from prisma aaj - Kapook Update 2025 🔥 ข่าวด่วน: nakita/hekireki generate validation schemas orm models and er diagrams from prisma aaj - Kapook Update 2025

That's it. Zod schemas, Drizzle tables, and ER diagrams are all regenerated in one shot.

Validation rules live in doc comments

Prisma types can say String, but not "1 to 50 characters" or "UUID format". Hekireki reads validation rules from Prisma doc comments (///):

model User {
    /// Primary key
    /// @z.uuid()
    /// @v.pipe(v.string(), v.uuid())
    id    String @id @default(uuid())
    /// Display name
    /// @z.string().min(1).max(50)
    /// @v.pipe(v.string(), v.minLength(1), v.maxLength(50))
    name  String
    /// One-to-many relation to Post
    posts Post[]
}
🔥 ข่าวด่วน: nakita/hekireki generate validation schemas orm models and er diagrams from prisma aaj - Kapook Update 2025 🔥 ข่าวด่วน: nakita/hekireki generate validation schemas orm models and er diagrams from prisma aaj - Kapook Update 2025

@z. is Zod, @v. is Valibot — there are also @a. (ArkType), @e. (Effect Schema), @t. (TypeBox), and @j. (JSON Schema). You write each library's own syntax, so the only thing to learn is the prefix.

The generated Zod output:

import * as z from 'zod'

export const UserSchema = z.object({
  /**
   * Primary key
   */
  id: z.uuid(),
  /**
   * Display name
   */
  name: z.string().min(1).max(50),
})

export type User = z.infer<typeof UserSchema>
🔥 ข่าวด่วน: nakita/hekireki generate validation schemas orm models and er diagrams from prisma aaj - Kapook Update 2025 🔥 ข่าวด่วน: nakita/hekireki generate validation schemas orm models and er diagrams from prisma aaj - Kapook Update 2025

Drizzle from the same schema

import { sqliteTable, text } from 'drizzle-orm/sqlite-core'
import { relations } from 'drizzle-orm'

export const user = sqliteTable('user', {
  id: text('id')
    .primaryKey()
    .$defaultFn(() => crypto.randomUUID()),
  name: text('name').notNull(),
})

export const userRelations = relations(user, ({ many }) => ({ posts: many(post) }))
🔥 ข่าวด่วน: nakita/hekireki generate validation schemas orm models and er diagrams from prisma aaj - Kapook Update 2025 🔥 ข่าวด่วน: nakita/hekireki generate validation schemas orm models and er diagrams from prisma aaj - Kapook Update 2025

Handy if you manage your schema with Prisma but want to use Drizzle — or if you are migrating.

ER diagrams without foreign keys

This is the feature that started it all. If your tables have no physical foreign keys, add a /// @relation doc comment:

model User {
  id   String @id @default(uuid())
  name String
}

/// @relation User.id Post.userId one-to-many
model Post {
  id     String @id @default(uuid())
  userId String
}
🔥 ข่าวด่วน: nakita/hekireki generate validation schemas orm models and er diagrams from prisma aaj - Kapook Update 2025 🔥 ข่าวด่วน: nakita/hekireki generate validation schemas orm models and er diagrams from prisma aaj - Kapook Update 2025

The relation is drawn in both the Mermaid and DBML output, even though Post.userId has no @relation(...) foreign key.

You can also output the ER diagram directly as a PNG — just point the output at a .png file. PNG rendering is powered by dbml-renderer.

generator Hekireki-PNG {
    provider = "hekireki-dbml"
    output   = "docs/er-diagram.png"
}
🔥 ข่าวด่วน: nakita/hekireki generate validation schemas orm models and er diagrams from prisma aaj - Kapook Update 2025 🔥 ข่าวด่วน: nakita/hekireki generate validation schemas orm models and er diagrams from prisma aaj - Kapook Update 2025

Docs server

Generate an HTML documentation page and preview it locally:

hekireki docs serve
🔥 ข่าวด่วน: nakita/hekireki generate validation schemas orm models and er diagrams from prisma aaj - Kapook Update 2025 🔥 ข่าวด่วน: nakita/hekireki generate validation schemas orm models and er diagrams from prisma aaj - Kapook Update 2025

It runs on Hono at http://localhost:5858 by default.

Closing

Hekireki grows based on developer requests. If there's a language or library you'd like a generator for, let me know in an Issue. Feedback and contributions are welcome!

Top comments (0)