37 comments

  • tonnydourado58 minutes ago
    That&#x27;s an interesting idea, and an unexplored design space. Graphviz&#x27;s dot has rank and head&#x2F;tail ports, and Plantuml&#x27;s class diagram has some support for relative position, but both are more hints for the layout engine, not deterministic declarations. If I had a nickel for every hour I spent fiddling with a Plantuml diagram to get the relation directions to force the layout into at least an approximation of what I wanted, I&#x27;ll be a lot closer to retirement.<p>I like that you&#x27;re going for one generic syntax instead of many specific ones, like mermaid and Plantuml, but it&#x27;s as much as a pro as it is a con, it&#x27;s one reason why these languages evolved in the first place, instead of everyone just using DOT. One possible mitigation would be some sort of reuse mechanism? Some way that generic nodes could be defined once and instantiated many times, so if I wanted to draw something like a sequence diagram, I could define&#x2F;change my participant lanes just once.<p>Another issue the &quot;No multi-line statements, no line continuations, no blocks.&quot; philosophy. I get *why* you chose it, and has its advantages, but it&#x27;s a pretty annoying constraint, specially if one wants to have longer node names, or have more detailed description of the node in its label, like listing the responsibilities of a class, for instance. &quot;No blocks&quot; is something that can probably won&#x27;t make much difference, but line continuations (i.e., some distinction between physical and logical lines) can make or break the user experience, IMHO<p>The syntax for line breaks is another thing I urge you to reconsider, &#x27;&#x2F;&#x27; is waaay to common of a character, and being forced to write long strings in a single line can get *really* annoying. Some sort of multiline string support would really make your existing syntax shine.<p>The last two suggestions&#x2F;complaints would complicate your parser a lot, specially since you&#x27;re writing it manually, so, they are trade offs, but as a user who&#x27;d love to have something like this on my toolbelt, not having these features would make me hesitate a lot on investing time in this tool.<p>That said, it&#x27;s a nice idea, I&#x27;ll keep an eye on it =)
    • noisy_boy17 minutes ago
      Frankly for all it&#x27;s issues, plantUML has been the most customizable and flexible for me. Mermaid is fine for diagrams where you don&#x27;t need to customize the look and feel much; it starts to become a pain once you need to. I just wish Obsidian had as a good a support for plantUML as it does for Mermaid.
  • apinstein12 hours ago
    This is very needed in the AI coding age! I find diagramming is one of the best ways for high bandwidth alignment between my mental model and the agent’s. I have been working on this problem a bit as I see good visuals as a key bottleneck in faster development while maintaining a real architecture.<p>Will def be adding this to my list of diagramming tools the agent can use!
    • jpwalsh23411 hours ago
      It&#x27;s funny, you articulated it very similar to how I feel! Seems like we need ways to maintain mental models at a high enough level of abstraction when working with agents.<p>There&#x27;s a skill in the repo that you can install using `npx skills` to get started with. I&#x27;m sure the integration of Reladraw with agents can be made way better, though. It&#x27;s just a bit... basic&#x2F;rudimentary right now!
      • Towaway695 hours ago
        Won’t it be a good idea to stay at the visual level?<p>Instead of generating visuals from text and then back to text, just communicate visually with your agents.<p>Something like UML provides a certain granularity to be able to code something usefully in pure visual language. Of course there are other visual programming languages that provide more depth and would probably be better suited.<p>Point remains that a solution based on constantly mapping better two different representations of the same thing won’t be a long term efficient solution.
    • tamimio7 hours ago
      I tried most of the diagrams out there, the best thing is installing drawio skill and make it generate one for you based on your description.
  • fallingmeat38 minutes ago
    great work. but at this point prompting a frontier model to make a svg diagram works so well..
  • recroad14 hours ago
    Seems a little buggy, I added this line:<p>edge parser -&gt; renderer &quot;test edge&quot; from: left to: right<p>and it wasn&#x27;t smart enough to make a curved arrow
    • jpwalsh23411 hours ago
      Bug is fixed in the playground. Thanks again for catching it!<p>It gave me some ideas to make routing better, too. For example, maybe you don&#x27;t want the edge to curve above, but rather below. Or, in more complex examples, maybe you want the edge to curve above one thing and to the right of another.<p>(will update npm shortly too)
    • jpwalsh23414 hours ago
      Genuine bug! Good find. I&#x27;ll look into a fix.
  • 0x4a501 hour ago
    Awesome! Exactly the problem I was having with drawio and mermaid. Nice work on addressing these problems and sharing it!
  • HeavyStorm14 hours ago
    Mermaid works great for fixed layouts like sequence diagrams and Gantts. For flowcharts, where position is king, it&#x27;s bad.<p>I&#x27;ve tried using svg in my MD files but they get unwieldy quite fast. This is a great idea. My first reaction was - but what&#x27;s if I need something more exact. But reflecting on it, I&#x27;ve realized that this relative positioning is probably enough.
    • jpwalsh23414 hours ago
      Yea, it&#x27;s hard to beat absolute positioning if you want something ultra-custom, but I&#x27;m hoping for most flowcharts, mind maps, etc. the relative positioning is enough to get what you want without fiddling too much!
    • y-curious12 hours ago
      Agreed. Next diagram I make I’m taking a photo of a whiteboard and letting AI figure out relative positioning
  • boblehest7 hours ago
    The README looks LLM generated. Sorry, but that&#x27;s where my interaction stops
    • jpwalsh2346 hours ago
      Appreciate the feedback. I gave the README a rewrite.
      • Kwpolska3 hours ago
        Now do the rest of the codebase.
        • faeyanpiraat2 hours ago
          Why put so much effort (checked your blog as well) into hating the new reality ?
        • oa3351 hour ago
          why?
  • rramon4 hours ago
    Cool, I think there&#x27;s a bug when switching themes in the web ui in Safari, the artifacts example with the dark red background isn&#x27;t readable in light themes. Vesper would be a nice theme to add.
  • shellerik6 hours ago
    This is a wonderful idea that fills a gap that has caused me much pain! When it&#x27;s more stable I&#x27;ll be looking for (or creating) an Obsidian plugin, a VS Code extension, etc.<p>Opening reladraw&#x2F;docs&#x2F;index.html to make a diagram then copy-pasting to save it is a little cumbersome.
    • jpwalsh2346 hours ago
      Thanks very much. And, I totally agree. The workflow at present without these quality of life features is a bit rough around the edges :)
      • shellerik5 hours ago
        I&#x27;ll use it next week for a diagram I&#x27;ve been trying to create for work and I&#x27;ll let you know if I run into anything it can&#x27;t handle.
  • threecheese14 hours ago
    Does this need to be shipped with a renderer? A better question is, are the node layout instructions ultimately being translated into absolute positions?<p>If so, you could target any number of render backends, keeping the same simple interface for your agent, avoiding the bazillion problems rendering engines face to work well across the ecosystem.
    • jpwalsh23413 hours ago
      Great idea! Yep, the layout instructions are translated into absolute positions. The one gap right now is just that the CLI doesn&#x27;t give you a way to say &quot;just calculate the positions, stop there, and give me JSON&quot;. The logic basically exists to do that, with a minor tweak to the CLI to allow that.<p>I&#x27;ll add that to my Reladraw todo list!
  • squidlib8 hours ago
    OP, is this something I could use when someone is explaining their architecture and this simply can interpret their words into a diagram?
    • jpwalsh2347 hours ago
      Not by itself, but an agent using Reladraw could. The real smarts would be the agent, and Reladraw just gives it a language and tool to express itself clearly and efficiently.<p>You could take someone&#x27;s explanation of their architecture, give it to an agent, and ask it to render it as a diagram using Graphviz, Mermaid, Draw.io, etc. The problem is that some of those don&#x27;t give the agent control over what the diagram looks like (Graphviz, Mermaid) and others are inefficient and fiddly for an agent to manipulate (Draw.io). Reladraw aims to be easy for an agent (or human) to edit (like Mermaid) but have the expressiveness and positioning like you&#x27;d be able to achieve with a carefully crafted Draw.io diagram.
  • zikohh14 hours ago
    <a href="https:&#x2F;&#x2F;d2lang.com&#x2F;" rel="nofollow">https:&#x2F;&#x2F;d2lang.com&#x2F;</a> works well?
    • Footprint052114 hours ago
      That’s what I have been using, but from glancing through this repository, it looks like the win here is that you can define where you want things and yet still have diagram as code
      • jpwalsh23414 hours ago
        Yep, exactly! D2 is in the same family as Mermaid, i.e., automatic layout, with some escape hatches like grid placement or absolute positioning. Reladraw sits in a gap between automatic layout and absolute positioning.
      • 2muchcoffeeman11 hours ago
        D2 has some support for this. You can fix the position of certain elements and then it will redraw things around it.<p>I’ve been thinking about something similar to this but D2 wasn’t totally open source until now.
    • the__alchemist10 hours ago
      I suspect the subject line to this &quot;Where you decide where to place things&quot; is a step away from D2; I find that fussy in D2!
  • _kidlike6 hours ago
    this looks awesome! A very naive question, because I never bothered to learn how it works, but can I embed this in markdown files with ```reladraw, as I can do with ```mermaid? Mermaid gets rendered inside markdown files, in both IntelliJ and Github. I assume both added support for it at some point. But I don&#x27;t know the mechanics of how this works. I wouldn&#x27;t be able to use this until then, unfortunately.
    • jpwalsh2345 hours ago
      Thanks :) A great question. So, I believe Github simply built in support for Mermaid as just something they natively support. That means getting reladraw to &quot;just work&quot; in Github markdown files is sorta not possible. The workaround is rendering to SVG and linking to the SVG (obviously not nearly as convenient).<p>For tools like IntelliJ, VSCode, Obsidian, they would be easier to get working I think, as they all support plugins&#x2F;extensions. That way, they&#x27;d know what to do when they encounter a fenced-in area starting with ```reladraw.
  • Garlef11 hours ago
    1. awesome ~ this seems to be in a sweet spot! (yes, mermaid is fine; but often looks bad - esp when visualizing large diagrams)<p>2. it would be great to have this as a layouting layer for C4<p>3. which brings me to a suggestion: i think it would make sense to allow for decoupling the topological parts of the language (arrows, groupings, etc) from the layouting concerns (left of, right of, etc)
    • jpwalsh23410 hours ago
      Super interesting. So, you&#x27;d have something like &quot;use architecture.dsl&quot; (to &quot;load&quot; the C4 model definitions), and then begin to specify layout?
      • Garlef5 hours ago
        Yes this would be one way. But maybe a suite of plungins that allows other renerers to consume .rel files might make for a better ecosystem.<p>To explain the use case: One advantage would be: maintain model (and views) in C4, provide layout on top.<p>We recently generated a big C4 model of the whole company. Good and informative since you can click through it! But it doesn&#x27;t look nice and doesn&#x27;t tell a coherent picture visually.
  • aktenlage15 hours ago
    That is damn interesting. When I made copilot write a script that creates a .dot diagram, I found it funny that it had the same problems with placement that I have when doing it manually.
    • jpwalsh23415 hours ago
      Thanks very much! Yea, with .dot, the layout engine decides where things go. So, the agent doesn&#x27;t know what the result looks like, leading to render, look, fiddle loops. And, depending on how much you care about layout, .dot might not give you enough knobs to turn to make it look like what you want.<p>The idea with Reladraw is that a human or agent could just state &quot;I want this node to the right of this other one&quot;, rather than have a layout engine decide. Hopefully less fiddling for agents!
  • tombert8 hours ago
    You stole my planned project for next weekend! I was actually planning on doing something very similar to this.<p>I&#x27;m glad you beat me to this; I think what you made is likely better than what I would have produced.
    • jpwalsh2348 hours ago
      Thanks very much! If you have ideas or feature requests, let me know!
  • kinduff15 hours ago
    I love it, and I wish it was part of Mermaid. I&#x27;ve always struggled with the presentation and agents tend to hack or just straight use SVG lol
    • jpwalsh23415 hours ago
      Thanks! Mermaid is so cool, but I wanted this relative placement, too. I&#x27;ve played with having Claude make me infographics in HTML and also using SVG. They can be surprisingly decent, until you want something complicated, then it gets messy! I figure, let the agents just say what they want, and let the tool (Reladraw) worry about the arithmetic. No use having an agent burning tokens to recompute coordinates with dubious results! &gt;.&lt;&#x27;
  • lampcord8 hours ago
    Always struggle with Graphviz tweaking my carefully planned positions. Explicit control here looks like a godsend.
    • jpwalsh2348 hours ago
      Yea, I felt the same. I started with Graphviz (dot language) and had fun playing with it, but ended up always back to something like Draw.io, because I couldn&#x27;t get things positioned how I wanted.
  • DylanMerigaud5 hours ago
    Nice to see tools improving human-agent collaboration.
  • altcognito10 hours ago
    This is an area I think I&#x27;ve really enjoyed AI coding: DSLs are pretty fun to make and you can get pretty creative. Bravo on this
    • jpwalsh23410 hours ago
      Thanks :) It is fun to play with!
  • stellakhr2 hours ago
    I always wanted this kind of tool, it’s a great idea
  • v9v16 hours ago
    Great! Reminds me of Pikchr a bit <a href="https:&#x2F;&#x2F;pikchr.org&#x2F;home&#x2F;doc&#x2F;trunk&#x2F;homepage.md" rel="nofollow">https:&#x2F;&#x2F;pikchr.org&#x2F;home&#x2F;doc&#x2F;trunk&#x2F;homepage.md</a>
    • jpwalsh23416 hours ago
      Thanks! The big difference is that Pikchr uses &quot;turtle&quot; graphics (where a cursor walks along and draws shapes). Reladraw lets you state relationships and relative positions.<p>So, if you have a container with children, or multiple nodes off to the right of another, with links between them, adding or resizing one adjusts the rest, without re-specifying positions the way turtle graphics would require.
  • rodmena11 hours ago
    interesting. wonder how agents themselves can create something complex. I&#x27;ll use it for sure. I direct my agents to [Graphviz provider](<a href="https:&#x2F;&#x2F;graphviz.rodmena.co.uk&#x2F;" rel="nofollow">https:&#x2F;&#x2F;graphviz.rodmena.co.uk&#x2F;</a>)s these days.
    • jpwalsh23411 hours ago
      That&#x27;s cool! I&#x27;m curious to see how it goes if you try making some super complex :)
  • tnspacetime12 hours ago
    This seems nice but I’ll need to read the syntax more carefully to see how capable and convenient it is.
    • jpwalsh23412 hours ago
      Definitely! Capability vs convenience is tough! Hope you find it useful.
  • patriciobcs16 hours ago
    I was looking for something like this. I wish it had different themes, the will prob be the best improvement.
    • jpwalsh23416 hours ago
      Great idea! So, right now it defaults to this sorta &quot;dark&quot; theme, and the only option you&#x27;d have is to change the diagram background color or define styles. I&#x27;ll make defining some preset themes a priority!
      • jpwalsh23414 hours ago
        Just pushed an update to add a basket of themes, including light and dark themes.
  • ciefa15 hours ago
    Huh, can you read my mind?! :D<p>This is super cool. I love diagrams, charts, etc. and use them a lot. Both privately and for work.<p>Definitely going to make use of this, I didn&#x27;t know how much I wanted something like this until right now hahaha.
    • jpwalsh23414 hours ago
      Glad to hear it! I&#x27;m a big fan of diagrams for understanding, mapping out architecture, etc!
  • atoav7 hours ago
    The best looking diagram library where you can explicitly place elements IMO is schemdraw (python). Ironically it is a library for drawing electronic circuit diagrams with some flowchart functionality on the side.<p>Examples: <a href="https:&#x2F;&#x2F;schemdraw.readthedocs.io&#x2F;en&#x2F;stable&#x2F;gallery&#x2F;flowcharting.html" rel="nofollow">https:&#x2F;&#x2F;schemdraw.readthedocs.io&#x2F;en&#x2F;stable&#x2F;gallery&#x2F;flowchart...</a><p>Usage: <a href="https:&#x2F;&#x2F;schemdraw.readthedocs.io&#x2F;en&#x2F;stable&#x2F;elements&#x2F;flow.html" rel="nofollow">https:&#x2F;&#x2F;schemdraw.readthedocs.io&#x2F;en&#x2F;stable&#x2F;elements&#x2F;flow.htm...</a>
  • zakiiaminn3 hours ago
    wow this is amazing!
  • tetris1116 hours ago
    I like it. I have too many issues with Mermaid
    • jpwalsh23416 hours ago
      Thanks! I really like Mermaid, but if the diagram gets too complicated, it draws it how it wants and I end up reaching for Draw.io, which is also awesome, but can take a lot of time.
  • tamimio7 hours ago
    Add a way to convert drawio into this or generate it from drawio
    • jpwalsh2347 hours ago
      That&#x27;s a cool idea. I&#x27;ll add it to my todo list. Going from reladraw -&gt; drawio is probably the easier direction. drawio -&gt; reladraw is probably the more challenging piece, because it would have to convert absolute positions into the relative positions it thinks you intended. It could just make a best effort along with some simplifying assumptions.
  • light_hue_115 hours ago
    I wish this just implement tikz without latex. I&#x27;ve yet to see a better drawing library that is both simple and has the depth to build the most complicated things.
    • jpwalsh23414 hours ago
      tikz looks super powerful. Reladraw is opting for a narrower job - making diagrams with boxes, groups, arrows, where you can say relative positions and let Reladraw save you extra work.
  • monster_truck16 hours ago
    This genuinely fucks. Thank you<p>Fighting with mermaid is so frustraiting, especially when it comes to normal vs github formatting. This is going to replace several ad-hoc half impls I have laying around
    • jpwalsh23416 hours ago
      Glad to hear it :) If you find that you want Reladraw to do something that it can&#x27;t, let me know! I keep uncovering features by looking at actual Draw.io diagrams I&#x27;ve made and seeing if Reladraw can do it.
      • Jailbird14 hours ago
        (since you ask...) Edges drawn with right angles would be a nice option.
        • jpwalsh2349 hours ago
          Updated! Edges can now have right angles (sharp or rounded). And, I added in more edge customization, like solid&#x2F;dashed&#x2F;dotted and thickness.
        • jpwalsh23413 hours ago
          Great idea! Adding to the todo list.
      • monster_truck13 hours ago
        o7 will do, and if I cook anything up I think you might appreciate I&#x27;ll try and yeet over a nice PR
  • wrs13 hours ago
    Mermaid is open source, no? Can we just add these placement constraints to Mermaid instead of making a whole new language?
    • jpwalsh23413 hours ago
      That&#x27;s a very thought-provoking question. Adding placement constraints on top of an automatic layout engine sounds like a challenging problem. You&#x27;d have the engine deciding where to place things, but you&#x27;d also be nudging things or constraining things.<p>This might not be what you have in mind, but Graphviz has a `rank` which can be used as a coarse way to influence the shape of the diagram. (I&#x27;m assuming you had something more sophisticated in mind though)<p>Probably easier would be if the relative drawing were its own distinct Mermaid diagram type, but then it would be largely a new language anyway.
  • rixed5 hours ago
    So, like pic?
  • einpoklum13 hours ago
    If this were implemented in a language with fewer dependencies, it&#x27;d be great.
    • jpwalsh23413 hours ago
      Reladraw has no runtime dependencies and Typescript is only needed to build it. If you mean Node, though, that&#x27;s fair!
      • jeremycarter12 hours ago
        Maybe a couple of binaries? <a href="https:&#x2F;&#x2F;github.com&#x2F;vercel-labs&#x2F;scriptc" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;vercel-labs&#x2F;scriptc</a>
        • jpwalsh2349 hours ago
          I tried scriptc. Unfortunately, it doesn&#x27;t work with this code at present (e.g., maps keyed by object and a number of various things). However, thanks for suggesting it. I have a note to revisit at some point.<p>Another option that appears to work well is to use Deno. I tried on my machine and it worked great. Only downside is the executable size is beefy. Could be about 70-105MB, or roughly 30MB compressed.<p>I don&#x27;t know if that still sounds attractive? A 30MB download from Github, and then uncompressed to 100MB, and no other dependencies? (Most of it would be the Deno runtime, with only about 300KB being Reladraw)
        • jpwalsh23412 hours ago
          Oh wow. Let me give that a try. I was going to try bun or Deno, but your suggestion might result in much smaller binaries.
  • lastscattering16 hours ago
    This is basically tikz&#x27;s positioning library (right=of, below left=of) without having to touch LaTeX. With tikz it was never the nodes that hurt me, it was the edges. Once two edges want the same side of a box it gets ugly fast. Does the resolver do any routing, or is from:&#x2F;to: all you get? And what happens with conflicting statements, does the first one win or do you get an error?
    • jpwalsh23416 hours ago
      Appreciate the comment and questions!<p>Does the resolver do any routing? It doesn&#x27;t auto-route around obstacles. But, if nodes A, B, and C all have edges going to the left side of D, they share that side and space themselves apart so they don&#x27;t cross. If the side is too short, they&#x27;ll bow out to make space for each other, so you don&#x27;t have to manually fiddle. You can also give routing instructions like &quot;these edges pass between these two nodes on their way to D&quot;.<p>Conflicting statements? Statements that can all hold will all apply. Right of one node and below another is okay. Or, &quot;right of A and B and C&quot; will clear whichever sticks out furthest. If they all can&#x27;t hold, you&#x27;ll get an error naming the clashing statements (e.g., something both left and right of A). Nothing silently wins.
      • drfloyd5116 hours ago
        &gt;nothing silently wins.<p>Fantastic! Never change this.<p>People will complain. These people also prefer type unsafe languages. Hold fast.
        • jpwalsh23415 hours ago
          Thanks! My concern was that a resolver making decisions &quot;to be helpful&quot; could become surprising or frustrating.<p>For example, if you ask for edges to pass &quot;between C and D&quot;, but those two nodes sit diagonally, the gap you are asking for might be the vertical channel or horizontal channel between them. So instead of guessing for you, it will tell you of the ambiguity and let you spell out what you want.
  • vickyy20261 hour ago
    [dead]