{"id":13703163,"url":"https://github.com/datnguye/dbterd","last_synced_at":"2026-04-01T21:16:22.150Z","repository":{"id":82245115,"uuid":"506920410","full_name":"datnguye/dbterd","owner":"datnguye","description":"Generate the ERD as a code from dbt artifacts","archived":false,"fork":false,"pushed_at":"2026-03-21T06:12:10.000Z","size":6507,"stargazers_count":305,"open_issues_count":0,"forks_count":36,"subscribers_count":7,"default_branch":"main","last_synced_at":"2026-03-21T19:12:38.754Z","etag":null,"topics":["cli","d2","dbml","dbt-cloud","dbt-core","drawdb","erd","graphviz","mermaid","plantuml","python-api"],"latest_commit_sha":null,"homepage":"https://dbterd.datnguyen.de/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/datnguye.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":["datnguye"]}},"created_at":"2022-06-24T07:35:31.000Z","updated_at":"2026-03-21T18:49:38.000Z","dependencies_parsed_at":null,"dependency_job_id":"e9fce8d3-7ce0-41d9-ab94-5f1fcc7278a4","html_url":"https://github.com/datnguye/dbterd","commit_stats":{"total_commits":51,"total_committers":3,"mean_commits":17.0,"dds":0.3921568627450981,"last_synced_commit":"bc30855f9c1c8c3ceab563786e9e7d51f9ad6a13"},"previous_names":[],"tags_count":69,"template":false,"template_full_name":null,"purl":"pkg:github/datnguye/dbterd","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/datnguye%2Fdbterd","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/datnguye%2Fdbterd/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/datnguye%2Fdbterd/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/datnguye%2Fdbterd/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/datnguye","download_url":"https://codeload.github.com/datnguye/dbterd/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/datnguye%2Fdbterd/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31292105,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-01T21:15:39.731Z","status":"ssl_error","status_checked_at":"2026-04-01T21:15:34.046Z","response_time":53,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","d2","dbml","dbt-cloud","dbt-core","drawdb","erd","graphviz","mermaid","plantuml","python-api"],"created_at":"2024-08-02T21:00:51.201Z","updated_at":"2026-04-01T21:16:22.142Z","avatar_url":"https://github.com/datnguye.png","language":"Python","readme":"\u003cdiv style=\"display: flex; align-items: center; justify-content: space-between;\"\u003e\n  \u003cdiv\u003e\n    \u003ch1 style=\"margin: 0;\"\u003edbterd\u003c/h1\u003e\n    \u003cp style=\"margin: 0; font-weight: bold;\"\u003eGenerate ERD-as-a-code from your dbt projects\u003c/p\u003e\n  \u003c/div\u003e\n  \u003cimg src=\"docs/assets/logo.svg\" alt=\"dbterd logo\" width=\"200\" height=\"80\"\u003e\n\u003c/div\u003e\n\nTransform your dbt artifact files or metadata into stunning Entity Relationship Diagrams using multiple formats: DBML, Mermaid, PlantUML, GraphViz, D2, and DrawDB\n\n[![docs](https://img.shields.io/badge/docs-visit%20site-blue?style=flat\u0026logo=gitbook\u0026logoColor=white)](https://dbterd.datnguyen.de/)\n[![PyPI version](https://badge.fury.io/py/dbterd.svg)](https://pypi.org/project/dbterd/)\n![python-cli](https://img.shields.io/badge/CLI-Python-FFCE3E?labelColor=14354C\u0026logo=python\u0026logoColor=white)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![python](https://img.shields.io/badge/Python-3.9|3.10|3.11|3.12|3.13-3776AB.svg?style=flat\u0026logo=python\u0026logoColor=white)](https://www.python.org)\n[![codecov](https://codecov.io/gh/datnguye/dbterd/graph/badge.svg?token=N7DMQBLH4P)](https://codecov.io/gh/datnguye/dbterd)\n\n[![dbterd stars](https://img.shields.io/github/stars/datnguye/dbterd.svg?logo=github\u0026style=for-the-badge\u0026label=Star%20this%20repo)](https://github.com/datnguye/dbterd)\n\n## 🎯 Entity Relationship Detection\n\ndbterd intelligently detects entity relationships through three algorithms — pick the one that matches how your dbt project expresses its data contracts:\n\n- **🧪 [Test Relationships](https://docs.getdbt.com/reference/resource-properties/data-tests#relationships)** *(default)* — infers relationships from dbt `relationships` data tests\n- **🏛️ [Semantic Entities](https://docs.getdbt.com/docs/build/entities)** (`-a entity_relationship`) — detects relationships via dbt Semantic Layer entity definitions\n- **📜 [Model Contract Constraints](https://docs.getdbt.com/docs/collaborate/govern/model-contracts)** (`-a model_contract`) — detects relationships via dbt model contract's `foreign_key` constraints (dbt 1.9+ / manifest v12+)\n\nFor detailed configuration options, see our [CLI References](https://dbterd.datnguyen.de/latest/nav/guide/cli-references.html#dbterd-run-algo-a).\n\n## 🎨 Supported Output Formats\n\nNo need to pick just one — dbterd has a format for every occasion, from quick GitHub previews to full-blown interactive database designers.\n\n| Format | Description | Use Case |\n|--------|-------------|----------|\n| **[DBML](https://dbdiagram.io/d)** | Database Markup Language | Interactive web diagrams |\n| **[Mermaid](https://mermaid-js.github.io/mermaid-live-editor/)** | Markdown-friendly diagrams | Documentation, GitHub |\n| **[PlantUML](https://plantuml.com/ie-diagram)** | Text-based UML | Technical documentation |\n| **[GraphViz](https://graphviz.org/)** | DOT graph description | Complex relationship visualization |\n| **[D2](https://d2lang.com/)** | Modern diagram scripting | Beautiful, customizable diagrams |\n| **[DrawDB](https://drawdb.vercel.app/)** | Web-based database designer | Interactive database design |\n\n🎯 **[Try the Quick Demo](https://dbterd.datnguyen.de/latest/nav/guide/targets/generate-dbml.html)** with DBML format!\n\n## 🚀 Installation\n\n```bash\npip install dbterd --upgrade\n```\n\nVerify Installation:\n\n```bash\ndbterd --version\n```\n\n\u003e [!TIP]\n\u003e **For dbt-core users**: It's highly recommended to keep [`dbt-artifacts-parser`](https://github.com/yu-iskw/dbt-artifacts-parser) updated to the latest version to support newer `dbt-core` versions and their [manifest/catalog json schemas](https://schemas.getdbt.com/):\n\u003e ```bash\n\u003e pip install dbt-artifacts-parser --upgrade\n\u003e ```\n\u003e\n\u003e **Note**: `dbterd` now automatically bypasses Pydantic validation errors by default, which helps with compatibility when using newer dbt artifact schemas.\n\n## ⚙️ Configuration Files\n\nTired of typing the same CLI arguments repeatedly? Your fingers deserve better. `dbterd` supports configuration files to streamline your workflow!\n\n```bash\n# Initialize a configuration file\ndbterd init\n\n# Now just run with your saved settings\ndbterd run\n```\n\n**Supported formats:**\n- `.dbterd.yml` - YAML configuration (recommended)\n- `pyproject.toml` - Add `[tool.dbterd]` section to your existing Python project config\n\nLearn more in the [Configuration Files Guide](https://dbterd.datnguyen.de/latest/nav/guide/configuration-file.html).\n\n## 💡 Examples\n\n### CLI Examples\n\n\u003cdetails\u003e\n\u003csummary\u003e🖱️ \u003cstrong\u003eClick to explore CLI examples\u003c/strong\u003e\u003c/summary\u003e\n\n```bash\n# 📊 Select all models in dbt_resto\ndbterd run -ad samples/dbtresto\n\n# 🎯 Select multiple dbt resources (models + sources)\ndbterd run -ad samples/dbtresto -rt model -rt source\n\n# 🔍 Select models excluding staging\ndbterd run -ad samples/dbtresto -s model.dbt_resto -ns model.dbt_resto.staging\n\n# 📋 Select by schema name\ndbterd run -ad samples/dbtresto -s schema:mart -ns model.dbt_resto.staging\n\n# 🏷️ Select by full schema name\ndbterd run -ad samples/dbtresto -s schema:dbt.mart -ns model.dbt_resto.staging\n\n# 🌟 Other sample projects\ndbterd run -ad samples/fivetranlog -rt model -rt source\ndbterd run -ad samples/facebookad -rt model -rt source\ndbterd run -ad samples/shopify -s wildcard:*shopify.shopify__*\n\n# 🔗 Custom relationship detection\ndbterd run -ad samples/dbt-constraints -a \"test_relationship:(name:foreign_key|c_from:fk_column_name|c_to:pk_column_name)\"\n\n# 💻 Your local project\ndbterd run -ad samples/local -rt model -rt source\n```\n\n\u003c/details\u003e\n\n### Python API Examples\n\n**Generate Complete ERD**\n\n```python\nfrom dbterd.api import DbtErd\n\n# Generate DBML format\nerd = DbtErd().get_erd()\nprint(\"ERD (DBML):\", erd)\n\n# Generate Mermaid format\nerd = DbtErd(target=\"mermaid\").get_erd()\nprint(\"ERD (Mermaid):\", erd)\n```\n\n**Generate Single Model ERD**\n\n```python\nfrom dbterd.api import DbtErd\n\n# Get ERD for specific model\ndim_prize_erd = DbtErd(target=\"mermaid\").get_model_erd(\n    node_unique_id=\"model.dbt_resto.dim_prize\"\n)\nprint(\"ERD of dim_prize (Mermaid):\", dim_prize_erd)\n```\n\n**Sample Output:**\n\n```mermaid\nerDiagram\n  \"MODEL.DBT_RESTO.DIM_PRIZE\" {\n    varchar prize_key\n    nvarchar prize_name\n    int prize_order\n  }\n  \"MODEL.DBT_RESTO.FACT_RESULT\" {\n    varchar fact_result_key\n    varchar box_key\n    varchar prize_key\n    date date_key\n    int no_of_won\n    float prize_value\n    float prize_paid\n    int is_prize_taken\n  }\n  \"MODEL.DBT_RESTO.FACT_RESULT\" }|--|| \"MODEL.DBT_RESTO.DIM_PRIZE\": prize_key\n```\n\n---\n\n## 🤝 Contributing\n\nWe welcome contributions! Whether you've found a bug, dreamed up a feature, or just want to fix a typo — you're very welcome here.\n\n**Ways to contribute:** 🐛 Report bugs | 💡 Suggest features | 📝 Improve documentation | 🔧 Submit pull requests\n\nSee our **[Contributing Guide](https://dbterd.datnguyen.de/latest/nav/development/contributing-guide.html)** for detailed information.\n\n**Show your support:**\n- ⭐ Star this repository\n- 📢 Share on social media\n- ✍️ Write a blog post\n- ☕ [Buy me a coffee](https://www.buymeacoffee.com/datnguye)\n\n[![buy me a coffee](https://img.shields.io/badge/buy%20me%20a%20coffee-donate-yellow.svg?logo=buy-me-a-coffee\u0026logoColor=white\u0026labelColor=ff813f\u0026style=for-the-badge)](https://www.buymeacoffee.com/datnguye)\n\n## 👥 Contributors\n\nA huge thanks to our amazing contributors — the people who turned \"wouldn't it be nice if...\" into actual working code. 🙏\n\n\u003ca href=\"https://github.com/datnguye/dbterd/graphs/contributors\"\u003e\n  \u003cimg src=\"https://contrib.rocks/image?repo=datnguye/dbterd\" /\u003e\n\u003c/a\u003e\n\n## 📧 Support\n\n**Need help?** We're here for you! Check 📖 [Documentation](https://dbterd.datnguyen.de/), 🐛 [Report Issues](https://github.com/datnguye/dbterd/issues) and 💬 [Discussions](https://github.com/datnguye/dbterd/discussions)\n\n\n\u003ca href=\"https://www.star-history.com/?repos=datnguye%2Fdbterd\u0026type=date\u0026legend=top-left\"\u003e\n \u003cpicture\u003e\n   \u003csource media=\"(prefers-color-scheme: dark)\" srcset=\"https://api.star-history.com/image?repos=datnguye/dbterd\u0026type=date\u0026theme=dark\u0026legend=top-left\" /\u003e\n   \u003csource media=\"(prefers-color-scheme: light)\" srcset=\"https://api.star-history.com/image?repos=datnguye/dbterd\u0026type=date\u0026legend=top-left\" /\u003e\n   \u003cimg alt=\"Star History Chart\" src=\"https://api.star-history.com/image?repos=datnguye/dbterd\u0026type=date\u0026legend=top-left\" /\u003e\n \u003c/picture\u003e\n\u003c/a\u003e\n\n---\n\n\u003cdiv align=\"center\"\u003e\n\n**Made with ❤️ by the dbterd community**\n\n---\n\n### Sponsored by GitAds\n[![Sponsored by GitAds](https://gitads.dev/v1/ad-serve?source=datnguye/dbterd@github)](https://gitads.dev/v1/ad-track?source=datnguye/dbterd@github)\n\n\u003c!-- GitAds-Verify: KHY1BVKH7W6UIGSKX7AOWMA6LBQH9FVS --\u003e\n\n\u003c/div\u003e\n","funding_links":["https://github.com/sponsors/datnguye","https://www.buymeacoffee.com/datnguye"],"categories":["Utilities","Python"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdatnguye%2Fdbterd","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdatnguye%2Fdbterd","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdatnguye%2Fdbterd/lists"}