npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

erd-schema-gen

v1.0.3

Published

A TypeScript CLI starter for SchemaGen.

Readme

SchemaGen

SchemaGen is a TypeScript CLI that turns schema source files into a diagram using OpenAI and PlantUML.

It is aimed at database-schema-heavy codebases. The CLI scans a target directory, finds the files that actually define the schema, generates valid PlantUML, and then either:

  • saves a rendered svg or png
  • opens the generated diagram in the PlantUML web editor

Example ERD

Installation

Install the package via npm:

npm install erd-schema-gen

Run the generator using:

node node_modules/.bin/schemagen

Features

  • Automatically discovers schema-defining files instead of requiring a manual file list
  • Works well with the Prisma and Drizzle examples included in this repo
  • Generates PlantUML using the local docs in docs/ as a syntax reference
  • Supports svg and png output
  • Can open either the rendered file or the PlantUML editor automatically

Requirements

  • Node.js 18 or newer
  • An OpenAI API key
  • Internet access to OpenAI
  • Internet access to www.plantuml.com for rendered image output
  • A desktop environment if you want the CLI to auto-open the result

Configuration

SchemaGen reads the API key from either:

  • --open-ai-key <string>
  • OPEN_AI_KEY in a local .env file

Example:

OPEN_AI_KEY=sk-...

Options

| Option | Description | | --- | --- | | --open-ai-key <string> | OpenAI API key. If omitted, SchemaGen reads OPEN_AI_KEY from .env. | | --dir <string> | Directory to scan. Defaults to the current working directory. | | --output <string> | Output directory or exact file path. Defaults to the current working directory. | | --type <string> | Output format: svg or png. Defaults to svg. | | --editor | Open the generated PlantUML in the PlantUML web editor instead of saving a local file. |

Output behavior

  • If --output points to a directory, SchemaGen writes ERD_diagram.<type> into that directory.
  • If --output ends with .svg or .png, SchemaGen writes to that exact file path.
  • Use relative paths for --dir and --output. The current implementation resolves both relative to the current working directory.

Examples

Generate an SVG from the Prisma example:

node node_modules/.bin/schemagen --dir examples/prisma

Generate a PNG into a custom directory:

node node_modules/.bin/schemagen --dir examples/drizzle-orm --output diagrams --type png

Write to an explicit file path:

node node_modules/.bin/schemagen --dir examples/drizzle-orm --output diagrams/schema.svg

Open the PlantUML editor instead of downloading a file:

node node_modules/.bin/schemagen --dir examples/drizzle-orm --editor

How It Works

  1. Builds a simplified tree of the target directory and skips noisy folders such as node_modules, .git, .idea, .vscode, dist, build, out, and logs.
  2. Uses gpt-5.4-nano to identify which files directly define the schema.
  3. Reads those files and asks gpt-5.4-nano to produce valid PlantUML.
  4. Uses the markdown docs in docs/ to verify PlantUML syntax before generating the diagram.
  5. Either opens the PlantUML editor or renders the final diagram through PlantUML and saves it locally.

What It Works Well With

  • Prisma schema files such as schema.prisma
  • Drizzle table definitions and relation files
  • Other ORM or entity files that directly declare persisted models and relationships

Limitations

  • File discovery is AI-assisted, so accuracy depends on how clearly the schema is expressed in the codebase.
  • Rendering a local image requires network access to PlantUML.
  • The CLI opens the editor or the generated file automatically.
  • The primary use case is schema and ERD generation. The PlantUML generation step can choose a class diagram when the input fits better, but the tool is optimized around database structure.

Development

Useful commands:

pnpm dev
pnpm build
pnpm start -- --dir examples/prisma

Notes:

  • pnpm dev compiles the project and runs the CLI against examples/drizzle-orm with --editor.
  • The PlantUML reference material used by the generator lives in docs/.

Publish to npm

npm login
npm publish --access public

License

MIT