{"id":17322118,"url":"https://github.com/jinagamvasubabu/ltreevisualizer","last_synced_at":"2025-10-30T17:37:51.983Z","repository":{"id":47061061,"uuid":"398462774","full_name":"jinagamvasubabu/ltreevisualizer","owner":"jinagamvasubabu","description":"A golang library to visualize postgres ltree type data using DOT language and Graphviz","archived":false,"fork":false,"pushed_at":"2021-10-08T06:52:04.000Z","size":300,"stargazers_count":16,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-21T16:41:15.562Z","etag":null,"topics":["display","golang","hacktoberfest","ltree","ltree-extension","postgresql","visualization"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jinagamvasubabu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-08-21T04:10:56.000Z","updated_at":"2023-12-05T13:44:50.000Z","dependencies_parsed_at":"2022-09-09T20:21:25.229Z","dependency_job_id":null,"html_url":"https://github.com/jinagamvasubabu/ltreevisualizer","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/jinagamvasubabu/ltreevisualizer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jinagamvasubabu%2Fltreevisualizer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jinagamvasubabu%2Fltreevisualizer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jinagamvasubabu%2Fltreevisualizer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jinagamvasubabu%2Fltreevisualizer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jinagamvasubabu","download_url":"https://codeload.github.com/jinagamvasubabu/ltreevisualizer/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jinagamvasubabu%2Fltreevisualizer/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265428746,"owners_count":23763630,"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":["display","golang","hacktoberfest","ltree","ltree-extension","postgresql","visualization"],"created_at":"2024-10-15T13:41:05.015Z","updated_at":"2025-10-30T17:37:46.964Z","avatar_url":"https://github.com/jinagamvasubabu.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Ltree Visualizer\n[![Build Status](https://circleci.com/gh/jinagamvasubabu/ltreevisualizer.svg?style=svg)](https://circleci.com/gh/jinagamvasubabu/ltreevisualizer)\n[![Go Report Card](https://goreportcard.com/badge/github.com/jinagamvasubabu/ltreevisualizer)](https://goreportcard.com/report/github.com/jinagamvasubabu/ltreevisualizer)\n[![GoDoc](https://godoc.org/github.com/jinagamvasubabu/ltreevisualizer?status.svg)](https://godoc.org/github.com/jinagamvasubabu/ltreevisualizer) \n[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)\n[![Visits Badge](https://badges.pufler.dev/visits/jinagamvasubabu/ltreevisualizer)](https://badges.pufler.dev)\n\nA golang library to visualize or display postgres ltree type data directly from Postgres DB using DOT language and Graphviz. \n\n![alt text](https://github.com/jinagamvasubabu/ltreevisualizer/blob/main/images/LtreeVisualizer.jpg?raw=true)\n\n# What is Ltree?\n\nLtree is a data type which is used to represent the hierarchical tree-like structures in flat rows and columns in\npostgres DB For more info-refer this https://www.postgresql.org/docs/9.1/ltree.html\n\nSample Hierarchy:\n![alt text](https://github.com/jinagamvasubabu/ltreevisualizer/blob/main/examples/graph.png?raw=true)\n\n# why do we need this library ?\n\nLtree Labels are separated using Dot `.` like `1.2.3.4` and it is not easy to visualize like a tree.\n\nThis Library can produce output into two different formats:\n* DOT Graph\n* Image\n\n# DOT Graph:\nDOT is a graph description language, using this language we can represent Directed, Undirected and FlowCharts. https://en.wikipedia.org/wiki/DOT_(graph_description_language)\n```go\ndigraph graphname {\n    a -\u003e b -\u003e c;\n    b -\u003e d;\n}\n```\n![alt text](https://github.com/jinagamvasubabu/ltreevisualizer/blob/main/images/DotLanguageDirected.png?raw=true)\n\n# Config:\n```go\n//Visualizer config\ntype Visualizer struct {\n    LogLevel    log.Level\n    RankDir     string\n    PostgresURI string //Example postgresql://postgres:postgres@localhost:5432/taxonomy?sslmode=disable\n    Query       string //select id, name, path from table1 //columns specified in this example should match or use resultset alias if your column names are different\n    FetchFromDB bool\n}\n```\nRankDir: Sets the direction of tree layout(https://www.graphviz.org/docs/attrs/rankdir/) and supported values are\n* TB (Top to Bottom)\n* RL (Right to Left)\n* LR (Left to Right)\n* BT (Bottom to Top)\n  Note: Default is TB\n\nFilePath: FilePath to save the image, this parameter is optional for `GenerateDotGraph`.\nNote: Default value of FilePath is `graph.png`\n\nYou can generate image of your ltree data using two ways:\n* Directly fetch the data from your Postgres DB\n* using Interim JSON file\n\n## DB Way (Directly fetch the data from your Postgres DB):\n```go\n//Visualizer config\ntype Visualizer struct {\n    LogLevel    log.Level\n    RankDir     string\n    PostgresURI string //Example postgresql://postgres:postgres@localhost:5432/taxonomy?sslmode=disable\n    Query       string //select id, name, path from table1 //columns specified in this example should match or use resultset alias if your column names are different\n    FetchFromDB bool\n}\n```\n1. Provide `PostgresURI` which your app can connect Eg: `postgresql://postgres:postgres@localhost:5432/taxonomy?sslmode=disable`\n2. Provide `Query` to fetch the data of your Ltree and your query result set should contain id, name, path\n3. Set `FetchFromDB` to true\n\n```go\n  import \"github.com/jinagamvasubabu/ltreevisualizer\"\n  import \"github.com/sirupsen/logrus\"\n \n  l := ltreevisualizer.Visualizer{\n        PostgresURI: \"postgresql://postgres:postgres@localhost:5432/taxonomy?sslmode=disable\",\n        Query: \"select id as id, name as name,path as path from table\"\n  }\n  resp, err := l.ConvertLtreeDataToImage(context.Background(), ltreevisualizer.VisualizerSchema{})\n  fmt.Println(resp)\n```\n\n## Using Interim Json File:\nIf you don't want to connect to DB and fetch the results then you can follow this way by using interim JSON file\n```go\n//VisualizerSchema Contract to send to ltreevisualizer\ntype VisualizerSchema struct {\n\tData []data `json:\"data\"`\n}\n\ntype data struct {\n\tID   int32  `json:\"id\"`\n\tName string `json:\"name\"`\n\tPath string `json:\"path\"`\n\tType string `json:\"type\"`\n}\n```\n\nRefer `data.json` file under examples directory for sample data\n\n\n* get `LtreeVisualizer`\n\n```\n  go get github.com/jinagamvasubabu/ltreevisualizer\n```\n\n* import and use it like below for to generate the output in DOT graph string:\n\n```\n  import \"github.com/jinagamvasubabu/ltreevisualizer\"\n  import \"github.com/sirupsen/logrus\"\n \n  l := ltreevisualizer.Visualizer{}\n  resp, err := l.GenerateDotGraph(context.Background(), //json data)\n  fmt.Println(resp)\n```\n\n* import and use it like below for to generate the output as an image:\n\n```\n  import \"github.com/jinagamvasubabu/ltreevisualizer\"\n  import \"github.com/sirupsen/logrus\"\n \n  l := ltreevisualizer.Visualizer{}\n  err := l.ConvertLtreeDataToImage(context.Background(), //json data)\n```\n\nNote: This will create a graph.png image if you don't specify Filepath\n\nYou can refer `examples` directory for more info\n\n# How to test?\nRefer `visualizer_test.go` for sample tests\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjinagamvasubabu%2Fltreevisualizer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjinagamvasubabu%2Fltreevisualizer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjinagamvasubabu%2Fltreevisualizer/lists"}