Code Monkey home page Code Monkey logo

tala's Introduction

TALA logo

TALA

TALA is a diagram layout engine designed specifically for software architecture diagrams, though it works well in other domains too.

TALA is closed-source. This repository is primarily for installation instructions. You can also use this repository to report issues, ask questions, and request features.

To learn more about TALA, please visit https://terrastruct.com/tala. Note that this is a paid layout engine, which requires a license for any commercial use. The license is purchasable in that same link. TALA is free to evaluate, but without a license, will render with a watermark.

To compare TALA with other layout engines, please visit https://text-to-diagram.com.

User Manual (PDF)

Rendering samples

You can see the .d2 text for these in ./docs/d2. Samples are generated through the CLI.

Installation

Install script

The most convenient way to install is through the install script.

# With --dry-run the install script will print the commands it will use
# to install without actually installing so you know what it's going to do.
curl -fsSL https://d2lang.com/install.sh | sh -s -- --tala --dry-run
# If things look good, install for real.
curl -fsSL https://d2lang.com/install.sh | sh -s -- --tala

You can also find binaries Releases page for Linux, MacOS and Windows, for both AMD and ARM. Download the appropriate one for your OS to a directory in your path.

macOS (Homebrew)

If you're on macOS, you can alternatively install with brew. (the install script above does this automatically if you have brew installed).

brew install terrastruct/tap/tala

Post-install

Check that it was installed properly:

d2 layout tala

It should print out information about TALA. If not, please see troubleshooting steps.

Use TALA

You are now ready to use TALA to layout your diagrams! Specify that D2 should use TALA by setting the environment variable D2_LAYOUT.

D2_LAYOUT=tala d2 in.d2 out.svg

Seeds

Optimal placements of nodes that minimizes distance and crossings is an NP-hard problem. TALA searches with heuristics to get an approximation. This search space has some randomness at each step. Choosing a different seed for this randomness can have signficant impact on the overall layout, as it may converge on an entirely different one.

For advanced usage of TALA, you may specify the seed to get a different layout:

d2 --layout tala --tala-seeds 44 input.d2

Add API token (optional)

You may skip this step if you are just evaluating.

As environment variable

If you have an API token, copy and paste it into your environment variables. E.g.

export TSTRUCT_TOKEN = "tstruct_..."

As config file

You can also use a JSON file as config. The benefit to this is that when the TALA license expires and has to renew, it will swap out the key for you automatically in the background with the updated one.

By default, TALA finds the configuration file at the following path:

$HOME/.config/tstruct/auth.json:

{
  "api_token": "tstruct_xxx"
}

You can change where this path is by configuring it with the following environment variable:

export TSTRUCT_AUTHFILE = /var/local/...

License keys

TALA is freely installable and locally runnable for evaluation. You'll need an API token from your Terrastruct account to run it out of evaluation mode. Alternatively, if you don't want to create an account, you can purchase a personal license key for TALA that allows you to run TALA forever with access to updates for 12 months here. If you'd like to get the benefits of a paid Terrastruct account at any time after, your license key will allow that.

Troubleshooting

TALA not found

which d2plugin-tala

If this does not return a directory, then d2plugin-tala is not in your path.

echo $PATH

Please move the downloaded binary to one of those locations.

License warning prints even with API token

In the same terminal that you're running d2 on, run

echo $TSTRUCT_TOKEN

If it is not found, then your environment variable has not been set in your shell. Make sure you add it to the appropriate shell config file and source it in the running terminal.

Other

Please open an Issue describing what you're running into and we're happy to help. If you'd like to remain anonymous/private, feel free to email us at [email protected]

FAQ

Does TALA use the internet?

The TALA plugin do not collect telemetry or use the internet in any way except to ping to check the status of a license. This is only done when necessary, e.g. if you purchased a month subscription, TALA will ping at the start of the next month and renew automatically if the subscription is ongoing. If you purchased a year, it won't ping for a year. The only data that's sent in these pings is the API token itself. No diagrams or anything else leaves your computer.

Others

Full FAQ at https://terrastruct.com/tala.

tala's People

Contributors

alixander avatar nhooyr avatar nuno99costa avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

tala's Issues

TALA seed in the source file

Hi! I just thought it would be nice to have the option of specifying the TALA seed in the source file. This would make diagrams created with TALA more reproducible. Now, if somebody makes a diagram and finds a seed that yields a particularly nice result, the diagram cannot be readily reproduced even in the same version of TALA (unless the author notes the seed in a comment).

err: Timed out: EdgeRouting

On routing a somewhat complex process flow diagram with order 100 nodes (but less than 200) the edge routing times out with:

err: Timed out: EdgeRouting

Unfortunately I am not able to share the failing example and wasn't able to quickly generate a minimal reproducible example.

Both ELK and dagre fare fine with this case, but do generate quite wide diagrams.

Feature Request: Prioritize width/16:9 aspect ratio - Ideal for Powerpoints

d2 in most diagrams I have tried favors scaling vertically, especially when using containers. However, in the common scenario of using a diagram for a Powerpoint, it would be ideal to instead expand wide while filling most of the space of a 16x9 aspect ratio. TALA seeds are the best bet to get it to expand wide, but it can do some funky stuff when connecting containers - 1 container up top, 4 containers at bottom, etc.

A simple way to consistently create something like the below where the containers & connections fill the space well would be a value addition to TALA
image

0.3.2 breaks

err: failed to compile: exit status 1
err: stderr:
err: err: SVG missing viewbox

specify direction per connection

          Here a variation on this problem. There is probably no way to decide algorythmically whether the photosynthesis box should be on top or on the side of the nitrogen fixation box (except that this solution would use less space).  When I was thinking of a layout grammar (for another project), I though of having syntax along the following lines:

Ocean.Surface.Nitrogen Fixation -> Ocean.Surface.Photosynthesis: NH4: right

i.e. each connection would have an optional direction keyword. Is that a feature that could be considered in the future?

direction: up

# Atmosphere -> Ocean.Surface.Nitrogen Fixation: N2
Ocean.Surface.Nitrogen Fixation -> Ocean.Surface.Photosynthesis: NH4

Ocean.Surface.Photosynthesis -> Ocean.Deep.Nitrification: Org. N
Ocean.Deep.Nitrification -> Ocean.Deep.Denitrification/Anammox: NH3
# Ocean.Deep.Denitrification/Anammox -> Atmosphere: N2
Ocean.Deep.Nitrification -> Ocean.Surface.Photosynthesis: NH3

Originally posted by @uliw in #32 (comment)

routing for grid edges

TALA has a pathfinding algorithm. We can replace the naive straight lines of grids with better routing

vertical ordering of containers

Is it possible to get the surface ocean container on top of the deep ocean container? The following code results in a good layout, but since the top and bottom are reversed, it could be more physical. Is there a way to get in the 'correct' order?

Atmosphere -> Surface Ocean.Nitrogen Fixation: N2
Surface Ocean.Nitrogen Fixation -> Surface Ocean.Photosynthesis: NH4
Surface Ocean.Photosynthesis -> Deep Ocean.Nitrification: Org. N
Deep Ocean.Nitrification -> Deep Ocean.Denitrification/Anammox: NH3
Deep Ocean.Denitrification/Anammox -> Atmosphere: N2
Deep Ocean.Nitrification -> Surface Ocean.Photosynthesis: NH3

this layout solution seems unecessarily complex

The code below produces a rather tangled layout (i.e., connectors cross, are lengthy and boxes are scattered). Can this be improved? And if this cannot be done automatically, would layout hints be an option to find a better solution?

S: Surface: {
A
I
P
}

I :Intermediate:{
A
I
P
}

D: Deep :{
A
I
P}

S.A <-> I.A
S.I <-> I.I
S.P <-> I.P

I.A <- D.A
I.I <- D.I
I.P <- D.P

Evaluation error

Trying to evaluate tala on Windows. d2 version 0.5.0, tala version 0.3.8. Get this error. Elk works fine.

C:>d2 -l tala -s test.d2.txt


WARNING: THIS COPY OF TALA IS UNLICENSED AND IS FOR EVALUATION PURPOSES ONLY

missing api token: could not find $TSTRUCT_TOKEN or api_token in auth file ~.config\tstruct\auth.json

Run d2plugin-tala.exe --help for more info.



WARNING: THIS COPY OF TALA IS UNLICENSED AND IS FOR EVALUATION PURPOSES ONLY

missing api token: could not find $TSTRUCT_TOKEN or api_token in auth file ~.config\tstruct\auth.json

Run d2plugin-tala.exe --help for more info.


err: failed to compile: failed to unmarshal json: json: cannot unmarshal object into Go struct field Attributes.attributes.constraint of type []string

I can fake a token and then it says

failed to verify $TSTRUCT_TOKEN: illegal base64 data at input byte 4

but the final error is the same.

I made d2/tala panic with a very short schema

Tala panics when I try to generate a svg from this content:

# generated at 2023-04-14T09:36:16.817Z

____header: |||md
Index
||| { near: top-center }
____body: |||md
[HLD](hld/index.svg) | [LLD](lld/index.svg)
|||

Example

% cat perdu.d2
# generated at 2023-04-14T09:36:16.817Z

____header: |||md
Index
||| { near: top-center }
____body: |||md
[HLD](hld/index.svg) | [LLD](lld/index.svg)
|||
% d2 --layout=tala perdu.d2
err: failed to compile: exit status 2
err: stderr:
err: panic: runtime error: invalid memory address or nil pointer dereference
err: [signal SIGSEGV: segmentation violation code=0x2 addr=0x40 pc=0x10592a6f0]
err:
err: goroutine 67 [running]:
err: github.com/terrastruct/src/backend/tala/transpilers/d2transpiler.PopulateNodes.func3(0x14000e09450, 0x18?)
err:    github.com/terrastruct/src/backend/tala/transpilers/d2transpiler/d2transpiler.go:87 +0xd0
err: github.com/terrastruct/src/backend/tala/transpilers/d2transpiler.PopulateNodes.func1(0x14000e09450, 0x0?, 0x14000c94f30)
err:    github.com/terrastruct/src/backend/tala/transpilers/d2transpiler/d2transpiler.go:37 +0x38
err: github.com/terrastruct/src/backend/tala/transpilers/d2transpiler.PopulateNodes.func1(0x14000e08000, 0x57199f883bccd?, 0x14000c94f30)
err:    github.com/terrastruct/src/backend/tala/transpilers/d2transpiler/d2transpiler.go:40 +0x7c
err: github.com/terrastruct/src/backend/tala/transpilers/d2transpiler.PopulateNodes({0x14000d2ba98?, 0x104c53df4?}, 0x140008fd970, 0x14000caafc0)
err:    github.com/terrastruct/src/backend/tala/transpilers/d2transpiler/d2transpiler.go:82 +0x204
err: github.com/terrastruct/src/backend/tala/transpilers/d2transpiler.RaceSeeds({0x106a76418, 0x14000a3c780}, 0x106a76418?, 0x14000caafc0, {0x14000580760, 0x3, 0x140001e6e40?}, 0x0, 0x0)
err:    github.com/terrastruct/src/backend/tala/transpilers/d2transpiler/d2transpiler.go:155 +0xa8
err: github.com/terrastruct/src/backend/tala/transpilers/d2transpiler.Layout({0x106a76418, 0x14000a3c780}, 0x0?, 0x0?)
err:    github.com/terrastruct/src/backend/tala/transpilers/d2transpiler/d2transpiler.go:317 +0x244
err: main.talaPlugin.Layout({0x14000c84540?, 0x14000c33d40?}, {0x106a76418?, 0x14000a3c780?}, 0x0?)
err:    github.com/terrastruct/src/backend/tala/cmd/d2plugin-tala/plugin_tala.go:161 +0x100
err: oss.terrastruct.com/d2/d2plugin.layout({0x106a76418, 0x14000a3c780}, {0x106a79660, 0x1400093ed60}, 0x140003c8d90)
err:    oss.terrastruct.com/[email protected]/d2plugin/serve.go:106 +0x94
err: oss.terrastruct.com/d2/d2plugin.Serve.func1({0x106a76418, 0x14000a3c780}, 0x140003c8d90)
err:    oss.terrastruct.com/[email protected]/d2plugin/serve.go:56 +0x2b8
err: oss.terrastruct.com/util-go/xmain.(*State).Main.func1()
err:    oss.terrastruct.com/[email protected]/xmain/xmain.go:105 +0x68
err: created by oss.terrastruct.com/util-go/xmain.(*State).Main
err:    oss.terrastruct.com/[email protected]/xmain/xmain.go:103 +0x110
% 

Other info

  • Same problem when using stdio instead of a file
  • No problem when using elk instead of tala
  • I'm using up-to-date versions, as far as brew upgrade is concerned
% d2 --version
0.4.0
% d2plugin-tala --version
v0.3.5

rearrange edges to prefer sorting by appearance

Screenshot 2024-04-28 at 5 35 50 PM

I've defined the edges in one order, but when rendered, we tend to read top-bottom (if the two nodes are horizontal arrange), and left-right (if vertical arrange), so the edges should arrange themselves in that order

direction on edges

Screen Shot 2023-11-19 at 8 54 00 PM

TALA should be able to handle individual direction on edges.

a -> b: { direction: left }

We can ensure this.

Tala improvement suggestion: grow containers

Hi,
I previously worked on a pet project similar to d2 - but not nearly as good! :) - based on graphviz, for producing technology architecture pictures. I found that a lot of diagrams would look much closer to one that a person would draw by introducing a 'grow-clusters?' parameter.

It would take a picture from this:

image

to this:

image

Graphviz doesn't have that setting and didn't have the man-power to introduce it so I had to hack the svg and run an optimisation over it. It was ugly!

Can work wonders though for some diagrams. Any thoughts for tala?

This setting might not work as tala; In graphviz (dot) you can force clusters into a row/ rank in the dot algorithm for introducing a bunch of between cluster invisible edges and from my experiments with tala, it works quite differently to dot.

Why do multiple incedent edges get coalesced?

Maybe some people want to model the effect of routers or something? I don't know. I'd suggest making coalescing a non-default config option. This behavior doesn't correctly represent semantics at the higher layers of the software stack.

Feature request: cross-cutting containers

It is useful to group shapes into more than one container. For example, one container can represent where something is physically deployed, while a cross-cutting container could show how it is logically deployed.

image

Open-source TALA

Maybe you should open-source TALA, and try to earn money on the IDE -- which looks great!

We're deciding between D2 and the Mermaid ecosystem, and I like the output of yours (much nicer graphs etc). But I'm also hesitant to build all our docs on a semi-closed ecosystem where the primary engine isn't free, and Mermaid is natively supported by Github and many others.

Any business based on open-source is always going to be in this pinch, give too much away, and you don't earn anything, give too little away, and you won't have any adoption.

I'm not saying it's an easy choice, but from my (very limited) vantage point, D2 looks great but has much lower traction than open-source Mermaid. Maybe selling the canonical IDE for D2 will still be a great business, even if you properly open-source TALA?

(I know D2-lang is open-source, but it's success is still coupled with your firm + TALA not being open-source is still a downside)

Not writing this to be annoying, just want to provide some feedback.

edges labels should prefer intersecting nodes than other edges

Screenshot 2024-03-11 at 2 26 52 PM
Records: Records of Activities {
  Training -> _.Person Role: is a
  Trainee -> _.Person Role: is a
  Remediator -> _.Person Role: is a
  Quality Reviewer -> _.Person Role: is a
}

Person -> Records.Training: can perform
Person -> Records.Trainee: can be a
Person -> Records.Remediator: can be a
Person -> Records.Quality Reviewer: can review

failed to verify $TSTRUCT_TOKEN: illegal base64 data at input byte 5

Hi,

We've just purchased TALA license and trying to integrate it into our CI. We provided TSTRUCT_TOKEN environment variable with one of the tokens we received. However, d2plugin-tala --help fails with:

[2024-02-12T22:03:41.916Z] WARNING: THIS COPY OF TALA IS UNLICENSED AND IS FOR EVALUATION PURPOSES ONLY

[2024-02-12T22:03:41.916Z] 

[2024-02-12T22:03:41.916Z] failed to verify $TSTRUCT_TOKEN: illegal base64 data at input byte 5

And our diagrams are generated with the watermark.

Occasional Errors When Generating Large Diagrams

On top of the err: Timed out: EdgeRouting error specified in #20, experimenting with different seeds to generate a fairly large diagram would also sometimes produce either of the following errors:

  1. failed to compile: exit status 2
    stderr:
    ...
    panic: runtime error: invalid memory address or nil pointer dereference
    [signal 0xc0000005 code=0x0 addr=0x70 pc=0x11116ba]
    
  2. failed to compile: exit status 1
    stderr:
    ...
    err: Reached a bad state: Dimensions w:13458, h:20121 reached after stage GapNormalization
    

The larger the diagram, the higher the chances of these errors occurring (and the lower the chances of successfully generating a diagram).

The diagram does not have to contain $&gt;= 100$ nodes for these errors to start cropping up. I encountered the above issues on a moderately-sized diagram of around 50-60 nodes/shapes (with a maximum of 2 hierarchy levels), 90-100 connections, and a decent amount of text (around 13000 characters including shape labels) sprinkled across the entire diagram.

another test case that results in long connectors

Note, this may be well outside the scope of what tala tries to achieve since it describes geometric relationships, but I post here it here in case it is useful.

The code below results in some unnecessarily long connectors.

D: D:{
A
I
P}

M :M:{
A
I
P
}

S: L: {
A
I
P
H
}


# Surface Intermediate Mixing
S.A <-> M.A
S.I <-> M.I
S.P <-> M.P

# THC downwelling
S.H -> D.A

# THC advection
D.A -> D.I
D.I -> D.P
M.P -> M.I
M.I -> M.A

# THC Upwelling
M.A <- D.A
M.I <- D.I
M.P <- D.P
M.A -> S.H

reorder edges with label obstructions

in this diagram, the long label on a connection placed there has nowhere good to go. it should be ordered with shorter connections, making more space for the long connection

client1

client2

server

redis

client1 -> server: updateBoard
server -> redis: broadcast request
server -> client1: undoData
redis -> server: request
server -> client2: request

Screen Shot 2023-08-09 at 10 28 26 AM

Unexpected behavior when using `grid-column`

The clusters functionality in TALA works great, but i have found that it breaks if the parent has columns, if this is intended it should be mentioned somewhere because comming across this after it working great on nodes without grid-column does seem like a bug.

Here is a playground link with a small reproduction of this issue.

Tala error with connection between two sequence diagrams

Hi,
Found an error with Tala (causes Tala to crash) for this d2:

seq1: Process One {
  shape: sequence_diagram
  style: {
    stroke: '#a6a6a6'
    stroke-width: 3
    border-radius: 8
    fill: '#e3eefa'
    shadow: true
  }
  # Remember that semicolons allow multiple objects to be defined in one line
  # Actors will appear from left-to-right as a, b, c, d...
  a
  b
  c
  d
  # ... even if the connections are in a different order
  c -> d
  d -> a: close the loop
  b -> d
}
seq2: Process Two {
  shape: sequence_diagram
  style: {
    stroke: '#366631'
    stroke-width: 3
    border-radius: 8
    fill: honeydew
    shadow: true
  }
  x: step 1
  y: step 1
  z: step 3
  x -> y
  y -> z
  z -> x: close the loop
}
seq1.d -> seq2.x: Mgr approval

This works in dagre and elk.
It's just the very last line:

seq1.d -> seq2.x: Mgr approval

that causes the issue when introduced.

feature request: Render Tables

We love Terrastruct. We mainly use the GUI version. We would like an option to allow displaying HTML or Markdown tables in a friendly, customizable way.

Things like:

  • Header being bold
  • Cell shadowing each 2nd row.
  • Cell outline

Markdown tables need to be more robust, and the SQL Tables option is not meant for general data.
Thanks!

tala layout could be more symmetrical in comparison to elk for this scenario

I encountered a scenario where I preferred the elk layout to the tala layout because the tala layout wasn't symmetrical. Given that a tala design is considered to have a preference for symmetry, I thought it was worth submitting as an issue. See below.

elk

image

tala

image

d2

Records: Records of Activities {
    Training -> _.Person Role: is a
    Trainee -> _.Person Role: is a
    Remediator -> _.Person Role: is a
    Quality Reviewer -> _.Person Role: is a
}

Person -> Records.Training: can perform
Person -> Records.Trainee: can be a
Person -> Records.Remediator: can be a
Person -> Records.Quality Reviewer: can review

Person -> Person Role: performs many\nroles

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.