Skip to main content

A zero-dependency ERD generator for your Python models โ€” pure AST, no database required.

Project description

๐Ÿ—ƒ๏ธ erdify

PyPI version Python versions License: MIT Tests Linting Ruff Checked with mypy

๐Ÿš€ Generate beautiful PlantUML Entity Relationship Diagrams from your SQLModel, SQLAlchemy, Django, Pydantic and dataclass models automatically!

erdify parses your model files using AST (Abstract Syntax Tree) and generates comprehensive ERD diagrams in PlantUML format. It supports SQLModel, SQLAlchemy 2.0, Django ORM, Pydantic and standard-library dataclasses. No database connection required!

โœจ Features

  • ๐Ÿ“Š Automatic ERD Generation - Parse your models and generate PlantUML diagrams
  • ๐Ÿงฌ 5 Frameworks - SQLModel, SQLAlchemy 2.0, Django ORM, Pydantic and dataclasses
  • ๐Ÿ” AST-Based Parsing - No imports needed, works with any valid Python code
  • ๐ŸŽฏ Zero Runtime Dependencies - Uses only Python standard library
  • ๐Ÿ”— Relationship Detection - Automatically detects foreign keys and relationships
  • ๐Ÿ”‘ Key Inference - --infer-keys derives PK/FK from field names for keyless models
  • ๐Ÿšซ Exclude Patterns - Filter out entities by class or table name with glob patterns
  • ๐ŸŽš๏ธ Source Filtering - Restrict the diagram to specific model kinds with --sources
  • โš™๏ธ Config File - Commit options under [tool.erdify] in pyproject.toml
  • โœ… Drift Check - --check fails CI/pre-commit when the committed diagram is stale
  • ๐Ÿ“ฆ Inheritance Support - Resolves fields from base classes and mixins
  • ๐Ÿท๏ธ Enum Support - Includes enum definitions in the diagram
  • ๐Ÿ”„ Link Table Detection - Identifies many-to-many association tables structurally
  • ๐Ÿงœ 4 Output Formats - --format emits PlantUML, Mermaid (renders natively on GitHub), JSON, or a self-contained HTML preview
  • ๐ŸŽจ Beautiful Output - Clean, readable diagrams with proper styling

๐Ÿš€ Quick Start

# Run without installing (or `pip install erdify`)
uvx erdify ./src/database -o erd.puml
# Output to stdout, with a custom title
erdify ./src/models --title "My Database Schema"

See the documentation for installation options, the full CLI, the Python API and more.

๐Ÿงฌ One Schema, Five Frameworks

The same User / Order schema in SQLModel, SQLAlchemy 2.0, Django, Pydantic and dataclasses โ€” only the syntax differs. Each one produces the identical diagram:

Framework comparison ERD

๐Ÿ‘‰ See the full side-by-side comparison and the detection/parsing table in the Frameworks Overview (with a worked example and Django specifics). The runnable sources live in docs/examples/.

๐Ÿ“š Documentation

๐Ÿ“‹ Supported Features

Feature Status Notes
Primary Keys โœ… Field(primary_key=True)
Foreign Keys โœ… Field(foreign_key="table.column")
Nullable Fields โœ… str | None or Optional[str]
Default Values โœ… Field(default=value)
Indexes โœ… Field(index=True)
Enums โœ… Python Enum classes
Relationships โœ… Relationship()
Inheritance โœ… Mixin classes supported
Link Tables โœ… Many-to-many detection
Custom Table Names โœ… __tablename__ attribute
Exclude Patterns โœ… --exclude glob on class/table name
Key Inference โœ… --infer-keys for Pydantic/dataclass (id, <x>_id)
SQLModel โœ… Field() / Relationship()
SQLAlchemy 2.0 โœ… Mapped[...] / mapped_column()
Pydantic โœ… BaseModel subclasses, nested refs as relationships
Dataclass โœ… @dataclass, nested refs as relationships

๐Ÿ’ฌ Community

Questions, ideas, or want to show off an ERD erdify generated? Join the Discussions. For open-ended topics and feature direction, Discussions are the place; concrete bugs and proposals go to Issues.

๐Ÿค Contributing

Contributions are welcome! Have a bug or a concrete feature request? Please open an issue, and see CONTRIBUTING.md for guidelines. Shipped changes are tracked in the changelog.

๐Ÿ”’ Security

For security concerns, please see SECURITY.md.

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿ™ Acknowledgments

erdify stands on the shoulders of great open-source projects:

Supported model frameworks

  • SQLModel - The awesome SQL database library
  • SQLAlchemy - The Python SQL toolkit and ORM
  • Django - The web framework whose ORM models erdify parses
  • Pydantic - Data validation using Python type hints
  • dataclasses - Python standard-library data classes

Rendering & output

  • PlantUML - For the diagram rendering
  • Graphviz - Layout engine behind PlantUML's ER diagrams
  • Mermaid - Renders the --format mermaid / html output

Tooling & infrastructure

  • uv - Packaging, builds and dependency management
  • Ruff - Linting and formatting
  • mypy - Static type checking
  • pytest - Testing framework
  • pre-commit - Git hook management

Community


Created & maintained with โค๏ธ by devsuit GmbH

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

erdify-0.10.0.tar.gz (26.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

erdify-0.10.0-py3-none-any.whl (29.8 kB view details)

Uploaded Python 3

File details

Details for the file erdify-0.10.0.tar.gz.

File metadata

  • Download URL: erdify-0.10.0.tar.gz
  • Upload date:
  • Size: 26.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for erdify-0.10.0.tar.gz
Algorithm Hash digest
SHA256 83eb81eb928c86350f2a97a761af9e083cb7316a9e618184d0666a044b64b878
MD5 ddfc07a9169b3dd6bfc5a92b2735cc5f
BLAKE2b-256 da5d0da2d2aa49ab18c6ab5587e8d592f12b159a357cc3c83afcfa75d6adc032

See more details on using hashes here.

File details

Details for the file erdify-0.10.0-py3-none-any.whl.

File metadata

  • Download URL: erdify-0.10.0-py3-none-any.whl
  • Upload date:
  • Size: 29.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for erdify-0.10.0-py3-none-any.whl
Algorithm Hash digest
SHA256 18daab797a7da4b192965e01043db382bca945a1505707c7845745c0cfd2c33d
MD5 ca3f35fe42f01127db3f13c6e48d91a6
BLAKE2b-256 462b0a1ec201273d216ea1aeb5107efa82696e945c844193930bc86751f632f5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page