[HN Gopher] Diagram as Code
       ___________________________________________________________________
        
       Diagram as Code
        
       Author : delduca
       Score  : 138 points
       Date   : 2020-05-12 15:13 UTC (3 hours ago)
        
 (HTM) web link (diagrams.mingrammer.com)
 (TXT) w3m dump (diagrams.mingrammer.com)
        
       | kovek wrote:
       | This is cool! I was hoping it would look something like:
       | 
       | ''' import diagrams calc_d =
       | diagrams.new_diagram("calculator_123")
       | 
       | calc_d.Datum("SuperNumber") class SuperNumber(int): pass
       | 
       | @calc_d.Service("Calculator", "takes numbers and operations and
       | operates") class Calculator(object): @calc_d.Endpoint("Add",
       | calls=["Increment"], main_data={"b": "SuperNumber}) def add(self,
       | a, b: SuperNumber): out = a for i in range(b):
       | calc_d.multi(calls=["Increment"]) out = self.increment(out)
       | @calc_d.Function("Increment")       def increment(self, a):
       | return a+1
       | 
       | def integration_test(): calc_d.instantiate("Calculator") calc =
       | Calculator() ... '''
       | 
       | EDIT: Dear dang and YC Hacker News, I would love to create code
       | blocks using surrounding triple quotes..
        
       | samsquire wrote:
       | I've got a similar project which takes a diagram of your
       | infrastructure, such as [1] and runs the diagram to build your
       | devops infrastructure [2].
       | 
       | [1]: http://devops-pipeline.com/architecture.tb.png [2]:
       | http://devops-pipeline.com/
        
       | 2fast4you wrote:
       | Sent this to a few people at work and it spread pretty quickly.
       | We all love it!
        
       | nautilus12 wrote:
       | When I first read this I thought this did the inverse of what it
       | actually does. Let you interactively draw out diagrams then it
       | would generate the boilerplate code to achieve that diagram.
        
         | hinkley wrote:
         | If we had a decent diff tool for visual elements, then a whole
         | lot of tools would be practical, including the one you suggest.
         | 
         | Certainly a lot of the building blocks for such a system now
         | exist.
        
         | maitredusoi wrote:
         | I have the exact seem disappointment ;(. As we evolve towards a
         | world were low code will become a part of everday tools,
         | diagram generating code is to me a good answer, at least on a
         | scaffolding level...
        
       | jameskraus wrote:
       | I was hoping this tool would support directionality/sequencing of
       | nodes.
       | 
       | A tool I've used in the past is SequenceDiagram.org for
       | diagraming a sequence of service calls. While a bit old-school,
       | it's good for its purpose.
       | 
       | I've also used Whimsical[0] to model flows and graph-like
       | relationships. It's got the added benefit of allowing multiple
       | users to view and edit the same document. Whimsical is still my
       | favorite tool right now due to flexibility, but it's a closed-
       | source/paid product, so I'm open to alternatives.
       | 
       | [0] https://whimsical.com/
        
         | dorian-graph wrote:
         | What about mermaid-js? Here's a sequence diagram example:
         | https://mermaid-js.github.io/mermaid-live-editor/#/edit/eyJj...
        
         | camillovisini wrote:
         | Visually Whimsical looks absolutely stunning... Wow
        
       | the_arun wrote:
       | Thanks for sharing! This is really cool.
        
       | mugsie wrote:
       | I like this a lot - trying to store diagrams that look good,
       | without sticking a visio file into a git repo is something I keep
       | an eye out for.
        
         | hugozap wrote:
         | You may also find value in diagram.codes (I'm the author)
         | 
         | It's focused on non technical users so the syntax will always
         | be very simple (at the cost of flexibility but that's on
         | purpose).
        
       | subhobroto wrote:
       | It seems to be hyperfocused on system architecture diagrams.
       | 
       | There are some other kinds of diagrams would we like to draw
       | that's not system architecture diagrams, eg:
       | 
       | - algorithms
       | 
       | - decision trees
       | 
       | - UML/ER Diagrams
       | 
       | Mermaid (JS) helps draw quality diagrams quickly - more than
       | system architecture diagrams.
       | 
       | It would have been perfect if the development cycles that went
       | here was used to create Mermaid templates instead.
       | 
       | Unless this also lets us draw more than just system architecture
       | diagrams.
        
         | josegonzalez wrote:
         | This would have been perfect for you maybe. I find the Diagrams
         | package to be just fine as it is. A tool or library doesn't
         | have to support _every_ bit of functionality in order to be
         | useful.
        
         | cs02rm0 wrote:
         | The focus would make sense to me if, say, it exported to
         | initial terraform templates or something like that.
        
           | jekriro7 wrote:
           | I'd prefer to avoid text blob artifacts if this was being
           | used at work with plenty of text blobs to babysit already
           | 
           | IMO the end days for TF and YAML engineering are close, at
           | least for new work
           | 
           | It's all HTTP APIs. Build a web UX and store the state in a
           | DB.
           | 
           | SRE/ops people ...at work just use the methods everyone else
           | does
           | 
           | Unless the company still has hardware, cloud ops/SRE is just
           | making their lives harder to be different
        
             | kronin wrote:
             | There is significant value in text blob workflows.
             | 
             | Requiring the definition of everything that makes up your
             | stack to be stored in a format that is not text adds
             | complexity to the disaster recovery process, not to mention
             | mutation, diffing, reviewing, approving, promoting, etc.
             | 
             | For places where a single environment that is updated in
             | place and requires little/no approval to do so, sure.
             | Personally I really like textual definition of
             | infrastructure and configuration, and disagree that it is
             | end days for them.
        
             | mugsie wrote:
             | > It's all HTTP APIs. Build a web UX and store the state in
             | a DB.
             | 
             | Please no. Don't make running a stateful service a
             | requirement for tooling people need to use when the world
             | is on fire. Or needs to load 40Mb of JS to rebuild a
             | deployment, and works only on Chrome 46.012.2039465.
             | Ops/SRE/DevOps/SysAdmin/SysOps/etc _are_ different, and
             | have optimised things to reduce the amount of dependancies.
        
               | snejj5 wrote:
               | What's the alternative you'd recommend?
        
               | mugsie wrote:
               | The explicit, declarative model, using tools that don't
               | need a ton of other things deployed.
               | 
               | Ideally the same tool can be run locally and in CI (with
               | the same invocation commands) so that an Op can run tests
               | locally, and even see the potential diff, before putting
               | it up for review.
               | 
               | The advantage of this approach is you can see a diff, and
               | use standard tooling like git / pr reviews to approve
               | changes in day to day, and when the world is on fire,
               | someone can break the glass and run it locally.
               | 
               | Never underestimate the value of peer review on a change
               | to the infra - there is a reason things like ITIL exist,
               | and we should learn from them.
        
       | polote wrote:
       | Why do we need a tool to draw its architecture and we don't have
       | a tool which auto discover the architecture and auto updates it
       | and draw it form here ?
       | 
       | That will shrink the gap between the current architecture and the
       | current diagram that almost always exists
        
         | rurounijones wrote:
         | xloudcraft.com auto-generates and updates from live account and
         | gives you info like cost etc.
         | 
         | Looks really.i.ptessive
        
           | rurounijones wrote:
           | cloudcraft.com
           | 
           | Stupid mobile keyboards...
        
       | Bedon292 wrote:
       | I have been thinking about using this for some diagrams, but
       | whats been on the back of my mind since I heard about it is how
       | to combine it with Terraform, or Troposphere, and have your
       | infrastructure as code also draw the diagrams automatically.
        
       | bingo_cannon wrote:
       | This looks really neat! Is it possible to have embedded diagrams.
       | For example, Gitlab lets you embed a PlantUML[1] diagram in any
       | Markdown or ADoc file using a proxy server. This makes it really
       | easy to write and serve documentation.
       | 
       | Personally, I'm a fan of PlantUML. Having an svg served in a
       | browser that has labels linking directly to the relevant entity
       | (code, resource etc) is a huge plus for new hire onboarding.
       | 
       | 1: https://plantuml.com/
        
       ___________________________________________________________________
       (page generated 2020-05-12 19:00 UTC)