<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Joshualouis on Medium]]></title>
        <description><![CDATA[Stories by Joshualouis on Medium]]></description>
        <link>https://medium.com/@joshualouis911?source=rss-38cdba9f3d83------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*dIjhqQcwZFdG0cQodoEC2w.jpeg</url>
            <title>Stories by Joshualouis on Medium</title>
            <link>https://medium.com/@joshualouis911?source=rss-38cdba9f3d83------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 23:32:25 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@joshualouis911/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Draw, Edit, Feed Back: Building a Round-Trip Diagram Generator with Claude]]></title>
            <link>https://medium.com/@joshualouis911/draw-edit-feed-back-building-a-round-trip-diagram-generator-with-claude-c2d5acd24eff?source=rss-38cdba9f3d83------2</link>
            <guid isPermaLink="false">https://medium.com/p/c2d5acd24eff</guid>
            <category><![CDATA[vibe-coding]]></category>
            <category><![CDATA[draw-io]]></category>
            <category><![CDATA[ai-experiments]]></category>
            <category><![CDATA[poc]]></category>
            <category><![CDATA[short-story]]></category>
            <dc:creator><![CDATA[Joshualouis]]></dc:creator>
            <pubDate>Fri, 03 Jul 2026 22:59:20 GMT</pubDate>
            <atom:updated>2026-07-03T22:59:20.936Z</atom:updated>
            <content:encoded><![CDATA[<p><em>How I got a language model and a draw.io canvas to pass an architecture diagram back and forth — and why the trick was teaching the model to stop drawing.</em></p><p>I draw a lot of AWS architecture diagrams. Boxes for the Lambdas, a dashed rectangle for the VPC, subnets nested inside, arrows tracing the request as it hops from CloudFront to a load balancer to something quietly minding a database. Then I write the document that explains the picture. Then, two weeks later, the design changes and the diagram and the document quietly drift apart, and I do it all again.</p><p>So I ran an experiment. I wanted to see how far the current crop of AI assistants — Copilot living in my editor, Claude sitting alongside — could take a plain-English design description and hand me back something real. Not a screenshot. Not a picture I’d have to redraw the moment anything changed. Something I could open in draw.io, nudge with the mouse, and keep working with.</p><p>The part I actually cared about wasn’t the generation. It was the loop.</p><h3>One-shot isn’t enough</h3><p>Anyone can get a model to produce <em>a</em> diagram. What I wanted was a conversation with the drawing. Type a design, get a diagram, drag a box where it should really go, then tell the model “now split that orchestrator into two” — and have it understand the diagram <em>as it currently stood</em>, edits and all, not regenerate the whole thing from memory and lose my changes.</p><p>A back-and-forth. Human and model both holding the pen, taking turns.</p><p>That framing is what made the whole thing interesting, and also what made my first attempt fall over.</p><h3>The wall</h3><p>My first instinct was the obvious one: ask the model to write the draw.io file directly. draw.io diagrams are just XML under the hood — surely a capable model can emit XML.</p><p>It can. It just can’t emit <em>good</em> XML. I got boxes overlapping other boxes, arrows cutting diagonally across the canvas and through three unrelated components, subnets that didn’t contain the things they were supposed to contain. Every regeneration produced a fresh new tangle. The model clearly knew <em>what</em> belonged in the diagram. It had no idea <em>where</em>any of it should go.</p><p>That was the whole lesson, sitting right there in the mess:</p><blockquote>A language model is brilliant at knowing what belongs in a diagram. It is genuinely terrible at knowing where to put it.</blockquote><p>Coordinates, geometry, routing, “does this box fit inside that box” — that’s not a language problem. It’s a layout problem. And I’d been asking the wrong part of the system to solve it.</p><h3>The idea that unlocked it</h3><p>So I split the job in two, and this is the bit worth stealing.</p><p><strong>The model classifies. The code draws.</strong></p><p>Instead of asking for a diagram, I asked the model — Claude, via the API — for a <em>structured description</em> of one. Just a list: here are the components, here’s the AWS service each one is, here’s which flows connect to which, and here’s which box sits inside which network boundary. Plain JSON. No coordinates. No XML. Nothing the model is bad at.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HYmslIkg7EkawssRIL0s4g.png" /><figcaption>Graph JSON of the diagram</figcaption></figure><p>Then deterministic code — ordinary, boring, testable code — takes that JSON and does everything the model couldn’t. It runs a layout algorithm to place every box. It sizes the VPC to wrap its subnets and the subnets to wrap their contents. It maps each service to its real AWS icon. It routes the arrows. It writes the draw.io XML.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iUbuI7DQpMhXSeBH00JygA.png" /><figcaption>Draw.io XML — mxGraphModel (sample)</figcaption></figure><p>The model does judgement. The code does precision. Suddenly the diagrams came out clean, every time, because “clean” was no longer something a model had to get lucky at — it was something an algorithm guaranteed.</p><h3>Closing the loop</h3><p>With that split in place, the back-and-forth I’d wanted became almost easy.</p><p>I embedded a real draw.io editor in the page. When the model produced a diagram, it loaded there, fully editable. And here’s the round-trip: when I dragged things around or edited a label, those edits streamed back out of the editor as XML — and I wrote a small parser to turn that XML <em>back</em> into the same structured JSON the model speaks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aYplUyZkPvMPCQCSYjIeag.png" /><figcaption>Embedded Draw.io with edit capability</figcaption></figure><p>So the loop closes cleanly. The current state of the canvas — my edits included — is always expressible as the same little graph. When I type “add a NAT gateway to the public subnet,” that instruction goes to the model <em>with the current graph as context</em>. It hands back an updated graph. The code re-renders. My structural intent survives; the model reasons about what’s actually on the screen.</p><p>Human turn. Model turn. Human turn. Exactly the conversation I was after.</p><h3>The details that fought back</h3><p>It’s never just the clever idea, of course. It’s the hundred small things after it.</p><p>The AWS icons came out washed-out and ghostly, and I couldn’t work out why until I realised I was painting a white icon glyph on a pale pastel tile — invisible on invisible. AWS icons want their solid brand colours: compute orange, networking violet, database magenta. Once I stopped fighting the style guide, they popped.</p><p>Nesting was its own puzzle. A VPC containing subnets containing services is a containment problem, and containment layout has to work bottom-up: lay out the innermost things first, size each box to hold its children plus a little breathing room, then treat that box as a unit inside its parent, and repeat. Get it right and the whole thing just wraps itself.</p><p>And the arrows tangled — until I stopped exiting every connector from the same side and started choosing sides based on where the boxes actually sat relative to each other. Small change. Enormous difference.</p><h3>Collating it all into a document</h3><p>The last piece pulled everything together, and it’s the part I’m fondest of.</p><p>By this point the tool was quietly holding a lot: the original design prompt, every follow-up instruction I’d typed to refine the diagram, the structured graph itself, and the finished picture. All of that is <em>context</em> — and context is exactly what you need to write a good architecture document. So I added a step that collates it.</p><p>Press a button and the tool gathers the lot — the prompts that described the intent, the graph that captured the components and their containment, and the diagram rendered as an image — and hands it back to Claude with one job: write this up as a proper technical architecture document. Introduction, component inventory, the network topology pulled straight from the containment, the data flows read off the arrows, security considerations, assumptions. The diagram itself drops into the document as a figure, right where it belongs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mGP7o-gLq2ff4BYc3c4K8A.png" /><figcaption>Technical architecture document authored by AI with edit capability</figcaption></figure><p>What comes out isn’t a summary of the diagram. It’s the design <em>and</em> its explanation, assembled from the same material that produced the picture — every prompt and every edit folded into the narrative. The thing I’d always done by hand, twice, and watched drift apart, now falls out of the tool as a single artefact.</p><h3>The stack, briefly</h3><p>Nothing exotic, which was rather the point. The interface is a single-page <strong>React</strong> app — a split view with the prompt and controls on one side and the live diagram on the other. The clever-but-boring middle layer is plain JavaScript: the layout engine that places and sizes every box, and the serialiser that turns the structured graph into draw.io XML. The editable canvas is a <strong>draw.io</strong> editor embedded in an iframe, driven through its messaging API so I can push a diagram in and read edits back out.</p><p>Behind it sits a small <strong>Node</strong> service that does two jobs: serve the React app and act as the one door to the model.</p><h3>What I actually came away with</h3><p>At the end I had the thing I set out to build: type a design in prose, get back a nested AWS diagram with real icons, edit it by hand, ask for changes in plain English against what’s on screen, and — from the very same structured graph, plus every prompt and the rendered diagram — collate a technical architecture document to go with it. The picture and the words, finally, from one source of truth.</p><p>But the diagram tool isn’t really the point. The point is the shape of the collaboration.</p><p>The most useful thing I did in the whole experiment was decide, deliberately, what to <em>not</em> ask the AI to do. Judgement — what’s in this design, what connects to what, how should this document read — went to the model, and it was excellent at it. Precision — pixels, geometry, valid files — went to deterministic code that never has a bad day. And a human stayed in the loop the entire time, editing, correcting, feeding it back.</p><p>Working <em>with</em> Claude on this felt less like prompting a black box and more like pairing with someone who was very good at the fuzzy half of the problem and happy to let me own the exact half. The trick to getting something trustworthy out of a language model, it turns out, isn’t a cleverer prompt. It’s knowing which half of the job to keep for the machinery — and which half to keep for yourself.</p><p><em>Built as a weekend experiment in AI-assisted document and diagram generation. The pattern — model for judgement, deterministic code for precision, human in the loop — has been quietly showing up in everything I’ve built since.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c2d5acd24eff" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>