{"id":22166523,"url":"https://github.com/alextanhongpin/go-erd","last_synced_at":"2025-03-24T16:27:14.591Z","repository":{"id":79114916,"uuid":"254563495","full_name":"alextanhongpin/go-erd","owner":"alextanhongpin","description":"Entity Relationship Diagram, rendered with Graphviz using go","archived":false,"fork":false,"pushed_at":"2020-04-13T18:39:13.000Z","size":2516,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-29T21:54:20.073Z","etag":null,"topics":["erd","go","graphviz"],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/alextanhongpin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-04-10T06:43:28.000Z","updated_at":"2021-10-04T12:23:13.000Z","dependencies_parsed_at":null,"dependency_job_id":"a580123a-940b-45e3-9457-fd46b61f2cd9","html_url":"https://github.com/alextanhongpin/go-erd","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alextanhongpin%2Fgo-erd","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alextanhongpin%2Fgo-erd/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alextanhongpin%2Fgo-erd/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alextanhongpin%2Fgo-erd/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alextanhongpin","download_url":"https://codeload.github.com/alextanhongpin/go-erd/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245307301,"owners_count":20594038,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["erd","go","graphviz"],"created_at":"2024-12-02T05:19:48.055Z","updated_at":"2025-03-24T16:27:14.563Z","avatar_url":"https://github.com/alextanhongpin.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# go-erd\n\n## Usage\n\n```bash\n$ go install github.com/alextanhongpin/go-erd\n$ ./go-erd -in in.txt -out out.png\n```\n## MOTIVATION :muscle:\n\nCreate ER (Entity-Relationship) diagrams can be a pain, especially when you need to update them. I find writing the schema as text to be the easiest to maintain, at the same time I would like to see a visual representation of the schema. The endgoal is to create something similar like Markdown, where one can just edit and preview the changes on the go.\n\nThis will converts the text below into an Entity Relationship Diagram:\n\n```\n# Comments will be skipped :)\n# Optionally, we can add titles.\nTitle: User Schema Design\n\n# Entities.\n[Person] {\"color\": \"#fcefce\" }\n*name\nheight\nweight\nbirth_date\n+birth_place_id\nemail (uid)\n\n[Birth Place] {\"color\": \"#cefcef\" }\n*id\nbirth_city\nbirth_state\nbirth_country\n\n[Roles] {\"color\": \"#eeeeee\"}\n*id\nname\ndescription\n+person_id\n\n# Relationships.\nPerson +--1 Birth Place\nPerson *--? Roles\n```\n\nOutput:\n\n![out.png](./assets/out.png)\n\n\n# Specification\n\n### ENTITY\n\nEntity represents your table. Below is a sample of the `Roles` table:\n\n```\n[Roles] {\"color\": \"#eeeeee\"}\n*id\nname\ndescription\n*+person_id\n```\n\nThe name of the Entity must be wrapped in `[]` square brackets, and it may follow an option to configure the table color (NOTE: Only valid CSS color names, e.g. red, green or six character hex code is valid, so `#333` will not be rendered correctly). Any rows after the table name will be attributes (or columns of the table).\n\nAside from that, there are other operators that we can use to assign to our diagram:\n```\n* - represents a primary key\n+ - represents a foreign key\n+* - represents both a foreign and primary key\n```\n\nTo represent other constraints, such as unique key or types, we can just add it as follow:\n\n```\n[Person]\nemail, text (UID)\n```\n\nSimple is best :smile:\n\n### RELATIONSHIP\n\nEach relationship must be between exactly two entities, which need not\nbe distinct. Each entity in the relationship has exactly one of four\npossible cardinalities:\n\n```\nCardinality  Syntax\n0 or 1         ?\nexactly 1      1\n0 or more      *\n1 or more      +\n```\n\nAnd we represent them in the format:\n\n```\n# A Person has exactly one birth place, but one or more Birth Place may belong to many people.\nPerson +--1 Birth Place\n\n# A person can have 0 or 1 role, and a role may belong to 0 or many people.\nPerson *--? Roles\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falextanhongpin%2Fgo-erd","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falextanhongpin%2Fgo-erd","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falextanhongpin%2Fgo-erd/lists"}