7 ms·
The C4 model for visualising software architecture (2017)
- mickeypi 3y agoThe same article posted for the 14th time since 2017. https://news.ycombinator.com/from?site=c4model.com https://news.ycombinator.com/from?site=c4model.com
- deleted 3y ago[deleted]
- pvg 3y agohttps://hn.algolia.com/?dateRange=all&page=0&prefix=true&query=by%3Adang%20%22reposts%20are%20ok%22%20attention&sort=byDate&type=comment https://hn.algolia.com/?dateRange=all&page=0&prefix=true&que...
- IshKebab 3y agoInteresting but I don't think this especially adds anything. The high level diagrams are great but then you can already make those without having to read any fancy visual model websites. The site even kind of admits this: > As an industry, we do have the Unified Modeling Language (UML), ArchiMate and SysML, but asking whether these provide an effective way to communicate software architecture is often irrelevant because many teams have already thrown them out in favour of much simpler "boxes and lines" diagrams. This is very true, but then they seem to have ignored the reasons why UML class diagrams were a total failure. They somehow acknowledge that nobody likes them, but then the 4th C of their model (code) is... UML class diagrams! You don't need this. Just do ad-hoc diagrams and make them clear, with labelled arrows. Their first three diagrams are actually good examples of this.
- sgt 3y agoThat's what I do. Boxes and lines between them. It helps a lot when thinking up new concepts and brainstorming too, so that the tool doesn't slow you down. I use Freeform now, which is super simple but works. Mark two objects and cmd-click/right click, then click "add connecting line".
- wejick 3y agoIs it Freeform as the Apple Freeform? I tried it last week to create high Level design, still not as smooth as I expected. Mainly the text editing flow feels not seamless yet, the deal breaker was I couldn't get the file successfully shared thru any available options. To be fair it's still in its early of its time, I'll wait bit longer.
- sgt 3y agoApple Freeform yes, comes with macOS. Before that I used Keynote.
- almostnormal 3y agoOne step further: Powerpoint. Sooner or later the diagrams will usually be needed in a presentation. Having them in a presentable format saves another step, and is a constant reminder to produce something worth presenting. Those diagrams that don't end up in presentations will be write-only anyway, and could be in any random format. No-one is going to read them.
- sgt 3y agoFreeform is basically a simplified Keynote, which it is based on. I used Keynote before. Might actually return to it since Freeform is pretty basic right now (it's pretty new).
- joegahona 3y agoThat’s a really good point, I’ve had to redo diagrams before to fit them into a presentation, and because they were sprawling all over the place in Figma or Miro, they required extra work to fit correctly and be readable. Powerpoint or Google Slides forces you to concision and the aspect ratio of the slide, for good or bad.
- pjmlp 3y agoUML is still highly used at the architecture command deck, even if the dream to generate code from diagrams failed. Just a couple of months ago I finalized yet another archictecture document, with enough class diagrams, sequence diagrams and use cases on it.
- nitwit005 3y agoTry testing if people can comprehend the diagrams by asking a question after showing them a somewhat complicated one. You'll likely be disappointed. We don't seem to be using them because they work.
- pjmlp 3y agoAs it happens, most people understand easier a standard notation that can refer to, and get a book at the library, than NIH boxes and lines. Now people straigth out of bootcamps calling themselves engineers, without having a Software Engineer degree, yeah maybe not. Then again, they can get that book I just mentioned, and in the process maybe discover other goodies at the local library, or just ask ChatGPT.
- IshKebab 3y ago> As it happens, most people understand easier a standard notation that can refer to, and get a book at the library, than NIH boxes and lines. I do not believe this for a second. You're possible arguing against a straw man. The alternative to UML isn't a "NIH UML" which uses a different array of arrows. It's labelled boxes and lines. You don't need to go to a library to understand the diagram because the diagram is self-explanatory. Here's a really good example: https://buck2.build/docs/concepts/concept_map/ https://buck2.build/docs/concepts/concept_map/ Every arrow is labelled. No tedious textbook needed.
- pjmlp 3y agoYou are free to believe in whatever makes you happy, I am not UML missionary.
- bdg 3y agoHaving structured architecture conventions becomes more important when you have many architecture conversations across multiple people and would like to gain insights from the diagrams too.
- IshKebab 3y agoBut you don't need and official standard that everyone learns. Just use words. If your box is a class, write "class Foo". If your arrow means "contains 1 or more" just write that next to the arrow.
- lfpeb8b45ez 3y agoYes, that’s exactly the convention that C4 specifies: add legends on every diagram and make sure things are labeled in a way that people can understand.
- IshKebab 3y agoWell they don't follow their own rules then because the "Level 4" diagram on that page is just standard awful UML with no legend or labels.
- captaincaveman 3y agoIn practice this doesn't work very well in an enterprise, the boxes end up a mix bag of different levels of things, some abstract some concrete, some just random. So if you need to piece together larger chunks of architecture, a supply chain for example, you basically have to redo it all. There is a lot of waste in this, and no one has a sufficiently clear view of the overall architecture, which leads to other waste and quality issues. For some reasons most engineers get very defensive about a more formal approach, I suspect mostly because it doesn't immediately benefit them or they haven't had too deal with large scale architecture and don't see the problem.
- ryan-duve 3y ago> Ideally this diagram would be automatically generated using tooling... The biggest problem I've seen with architecture diagrams is they fall out of sync with the code base. In my opinion, automatic generation of these diagrams is necessary. Otherwise, teams have no way to know whether the picture in front of them accurately represents the latest state of the system.
- hcks 3y agoIn my experience diagrams that are pedestrian enough to be automatically generated from the codebase don’t add much value
- dackerlunghack 3y ago[dead]
- layer8 3y agoDiagrams are similar to textual documentation: You generally can’t auto-generate useful ones from code, unless the code has extra markup that specifies what to generate. Diagrams often present a specific perspective that emphasizes certain features while omitting others. You might have several diagrams for the same entity, each illustrating a different aspect or scenario. The upshot is that diagrams have to be maintained in conjunction with the code and application architecture, just like textual documentation. There’s just no alternative to simply putting the work in, and making it a regular part of change management.
- simpaticoder 3y agoThe correct solution is a synthesis: generate the boxes and arrows from code. Then let a human hide, move, and style those objects. When the code changes, the boxes and arrows will change, and perhaps the style will want to change, but at least the diagram will remain correct. This is precisely the distinction between semantic markup and css, btw. Implying that the html would be auto generated, the css would be hand crafted.
- discodachshund 3y agoI get the points about not needing a formalised system for diagrams, even if C4 is quite light touch in my opinion (I never go down to the code level). However, I do have to credit structurizr, which outputs C4 diagrams, as a great productivity boost. One model producing multiple views at all specificities is fantastic compared to mermaid, plantuml, etc, where every diagram needs to be self contained and define and redefine the same components over and over. Branching off, editing the model, presenting ideas, has been a very successful workflow for me.
- jhund 3y agoPlus one for structurizr. Its model driven approach makes it a lot easier to keep the diagrams consistent with the code: You describe the architecture, and structurizr renders the diagrams.
- phlakaton 3y agoMermaid's definitely not well-suited for the amount of text and text formatting that C4 requires. You can do it, but you will be jumping through hoops, and the autolayout breaks down pretty quickly when the arrows between boxes get chatty.
- gengstrand 3y agoTrue but the big selling point for mermaid is the github integration and you can audit the changes to the diagrams via git log -p
- williamdclt 3y agoI’ve only tried structirizr briefly, but I found it too inflexible. No way to draw concepts that aren’t strictly part of C4. For example I wanted to encapsulate 2 components in a box to represent that they’re currently deployed as one service (not necessarily a good thing to do in absolute but would have helped my team to grok it better): impossible. I do like the idea of describing architecture formally, but the lack of customizability of diagram output was too painful
- Veuxdo 3y agoIf you find the C4 model to be too arbitrary and over-specified, I wrote on an alternative practice earlier this year: https://www.ilograph.com/blog/posts/concrete-diagramming-models/ https://www.ilograph.com/blog/posts/concrete-diagramming-mod...
- nickdothutton 3y agoThis is how you know software engineering is still an immature discipline. It’s 25+ years (in my case) as still we are having largely the same discussions about “basic” things. I’m not saying this is bad, but progress is slow, and we can’t blame any particular company or consortia or commercial interest here.
- bdg 3y agoHonestly we have the same problem outside of engineering. C4 is really just a way to focus conversations along one level of abstraction. How many times have you talked to someone who bounces up and down from high detail high complexity to zoomed-out simplicity in the same thought, and not understood what they wanted to tell you? We have the same issue when devs think "I will just yolo some boxes and arrows on this board, it makes sense in my head so it is a good diagram!"
- motohagiography 3y agoI like the model, and have had to use UML in security architecture where the whole thing hinges on consistency from the top level context to the code. The simplicty of this C4 model is a forcing function, where if there is hidden context or components, they have to shake out in the model. I'd suggest resistance to something this simple chould indicate there may be hidden elements (which there are more often than not on large projects). Forcing people to clarify their thinking into something like this decentralizes them by having them commit to statements and ideas instead of just reserving a right to suggest and criticize, and you can get a lot of resistance to that as well. These aren't model problems though, but they're what happens when models meet people. I'll use something like this as a reference for security design as I really like its consistency.
- jackconsidine 3y agoMermaid supports C4 now [0]; though still experimental, it works in Notion and Github renderers. [0] https://mermaid.js.org/syntax/c4.html https://mermaid.js.org/syntax/c4.html
- mikehollinger 3y agoI like C4. I'd previously discounted the "context" diagrams that inevitably show "User -{do their job}-> System-of-Record" as useless. Now I see the point. I'm working through a new piece of system design for a complex system using C4 with our extended teams. In drawing the top level this time around though I realized that b/c we have a semi-disconnected mobile app (aside from a web UI) we need to degrade certain behaviors gracefully if we don't have certain results yet, either b/c we're offline, or the backend is just slow for some reason. That rippled down into the next layer of the system as a job queue, which then rippled into the UX, because we can now say definitively which parts of the system may take an unbounded amount of time to complete a request. I'm sure we'd have gotten to this conclusion eventually but the analysis put the issue front and center. All because I had to draw a picture with "Remote-User --{Mobile Stuff}--> Backend." Also whichever tool you use is up to you. I just use draw.io for example with different tabs for each layer. As we elaborate on this at some point we'll break the lower layers out to their own files.
- wokwokwok 3y agoI dunno, I kind of subscribe to software architecture being like, a set of design decisions that guide the implementation. That's what (in my experience) most software architects do; lay down guidance and structure for the software engineers. > The C4 model was created as a way to help software development teams describe and communicate software architecture, both during up-front design sessions and when retrospectively documenting an existing codebase. > It's a way to create maps of your code, at various levels of detail, in the same way you would use something like Google Maps to zoom in and out of an area you are interested in. This seems different. I have no idea why you would refer to the a code diagram as your software architecture. That's literally the code level. How is that architectural? It's like saying the circuit diagram in the plug should go on the house blueprint. "You should use automated tools for this" ... so, it's for documenting existing code bases at the per-function level? How is that useful for architecting / designing / planning software? That sounds like software structure to me, not software architecture. Sure, a map of existing software that explains how it's structured sounds cool... but I dunno. Like, if you're talking about design patterns, you're not gonna give someone a function-by-function map of how to implement a singleton. They're not stupid. You'd tell them you think it should have a singleton (or repository, or whatever). Software design is totally a thing, and this seems entirely reasonable for designing software. ...but software design and implementation and software architecture are not the same thing and they're not done by the same people, in my experience. This feels more like... systems design, which a software architect would contribute advice to in the way that the systems were designed so they aligned with good software architecture principals. Maybe I'm just being pedantic. /shrug
- chrisweekly 3y agoExcellent points. (also, not too pedantic) (also, principals -> principles)
- dexterbt1 3y agoInteresting, as I kinda share also that there are lines to be drawn between software architecture, design and implementation (all three). Much like in the real world building of real-estate for example, I see there are different roles between the architect vs the engineers vs. the foremen. What do you draw the line? What concerns/areas are to be covered in each of these [arch vs design vs implem]?
- auggierose 3y agoI watched the talk on the site, and I liked it. But I also immediately had the question: Where do my actual abstractions live? So, not the concrete instances of an abstraction that runs somewhere, maybe as a component, maybe as code, maybe even as a whole container; but the abstraction itself.
- jackblemming 3y agoYou can see a crappy house that’s falling apart pretty easily. Conversely management cannot see a crappy codebase that’s rife with technical debt. Maybe they would make more intelligent decisions if they could visualize the problem.
- manicennui 3y agoCode quality does not seem to have any correlation with business success. Why should business care?
- jackblemming 3y agoWell this is just wrong, so I don't really know how to respond. You're probably thinking about monopolies such as Facebook, Google, or the like, where not only does code quality not matter, but not much matters at all. Most businesses do not have this luxury.
- manicennui 3y agoNope. I'm thinking about every single company I've ever worked at. My previous job was in healthcare and most of the software in the entire industry is atrocious.
- jackblemming 3y agoI guess if my rep sheet was McDonalds, Subway, and Tacobell I wouldnt think food quality mattered either.
- eitland 3y agoIf you think about code quality in terms like line length, spelling errors, etc it might not matter. If you think of it in terms of: - how long does it take to get at new developer up to speed? (everything from readability to build systems) - can this be hacked any day of the week if someone puts their mind to it? (both own code and libraries) - can we be resonably sure that new changes don't introduce (large) defects? (testing, modularization) it becomes impossible to argue that it cannot affect business success. Yes: - it might work as long as the old dev is happy and alive, but break down when he isn't available anymore - it might work as long as nobody targets this business specifically - it might work as it exist now but at some point be impossible to update anymore and the day new tax rules or whatever are introduced, it breaks
- FourthProtocol 3y agoAdmittedly I'm a greybeard. Wrote my first app in 1984. Moved through the ranks, from support to dev roles, application architecture, enterprise architecture and finially process optimisation. And so wow, those diagrams in the links - how does one even manage all those boxes?!? Architecture is easier than coding, if you stay away from more/bigger/but_my_app_is_a_special_little_snowflake mantras. Consider the age-old, tried, tested, proven architecture models of yore (other than their most excellent diagram notations, stay away from UML). Architecture (design) is layered, not spaghetti thrown at a wall, hoping something sticks. Most (99.9%) software domains can be divided into three horizontal layers - 1. UI 2. Application/business layer 3. Data layer (note that both internal and external service layers sit at the same level as data layers, allowing them to be called from the application layer) Finally, there are vertical layers (shared across the initial three layers) These typically include - 4. Communication 5. Exception management 6. Security 7. Logs Start with that as an overview/index of the entire solution, and when the beast needs to grow, just grow it. But grow it wisely. Use the standard 3-tiered architecture model. Re-use those cross-cutting concens in new applications. Federate identities. Standardise access/permissions management. Finally, don't feel compelled to use all the things - if the solution is services-based, don't code a UI for it. Simply connect your client to the relevant, existing service. Yes, services can be tiered, assuming your management processes are mature. As to the management issue. Governance is what keeps your estate from turning into a hairball. Make extensive and judicious use of 1. Risk management 2. Change management 3. Stakeholder management 4. Design reviews 5. Project review (where team members grade managers) Establish a technical design authority. The TDA concerns itself with broadly technical matters that facilitate a system-wide perspective. This might include - 1. Systems and solutions 2. Data 3. Communications 4. Quality objectives, including security 5. Development and development operations (devops) 6. Infrastructure (including but not limited to directories; networks; servers, both on-site and remote/in clouds; workstations and mobile devices). 7. Testing (Tools, techniques, platforms, languages and frameworks) 8. Locations
- tudorw 3y agoNice, thanks.
- IAmGraydon 3y agoThe talk about programmatically creating these diagrams is interesting, but it would be more interesting to use this in reverse with AI. Create a C4 diagram with a GUI, programmatically factor it down to some kind of text-based format and use that as an input for a code-generating AI. Imagine rewriting vast chunks of code by just editing the structure diagram.
- dpflan 3y agoI've seen some cool results when asking GenAI (here it was ChatGPT) to create code based upon a sequence diagram and vice versa. The goal is to have an abstraction to generate code from. Or at least build the 80% of the text for something to be a seed for generating code.
- bane 3y agoC4 is very interesting and I think tackles certain problems related to software architecture really well. It sort of turns the lower levels of an architecture, which is mostly hardware and system software, into broad abstractions and focuses the effort on the stuff that sits above that in the stack. Which turns out to be surprisingly suitable for today's cloud-based/containerized scalable approaches. Related, Archimate is also very good and there's a lot of overlap, but grounds itself more into the infrastructure bits. I've used some version of diagram approaches similar to Archimate in the past to really great effect to deconflict systems and data sources and demonstrate how all the stuff we're buying and gluing together supports specific business and user workflow needs. Comments here about how this stuff all gets out of sync with the codebase are absolutely correct. But I've found that they can be excellent tools for use when you need to analyze a complex system or communicate systems and plans to a larger group. It's surprising how often there isn't really any form of cohesive documentation and just sitting down for a couple weeks and drawing boxes with lines connecting them can unblock and simplify failing and frustrated efforts to move forward, especially when teams are working in the same playpen. C4, Archimate, UML, whatever are really just good constrained diagramming languages you can use to capture specific things you wish to communicate, analyze, or memorialize. I think they aren't very good as preplanning and design tools. Many of us suffered from the big UML push days where every facet of a system down to class definitions were supposed to be laid out in excruciating detail by some chief architect's office before a line of code was laid down. Madness like "we'll just generate the code from the diagrams" caused millions to suffer. When coding actually did start, those thousands of hours of planning usually were just ignored and the developers just did what they wanted anyways.
- d--b 3y ago> Ask somebody in the building industry to visually communicate the architecture of a building and you'll be presented with site plans, floor plans, elevation views, cross-section views and detail drawings. Well ask an architect to visually communicate “how the building is going to work”, ie, where do pilots go, how security works, how long will the waiting line be. What happnes to people missing the plane after they go through security. Then we’ll talk about those software diagrams.
- wholesomepotato 3y agoEven as a non civil engineer I can understand floor plans and alikes and find then immediately useful. Even as a professional SWE these example diagrams don't seem useful or informative enough to justify bothering with them. Code is too multidimensional to be approximated with 2d drawings. It just doesn't work. What could work are more conventional architectural code patterns. Things like structured concurrency, but also for higher level. Maybe.
- ozim 3y agoMostly because software architecture diagrams need a lot of context or have to be in specific context and quite tight scope. Floor plan has really fixed context and very limited scope. Like I don't have to explain windows ... but in software most of the time you actually have to explain "window" because every "window" or element will be different, you cannot just say this is window and copy it 20x.
- GorsyGentle 3y agoI've tried creating diagrams of this nature (not realizing this is a thing) but I chose them for documenting the system to others that weren't already familiar with the project so it felt necessary to layer it all together. Those diagrams shown looked more like team meetings hashing out the details. Seemed kind of an unfair comparison. That being said, the biggest issue I ran into is in the diagram tooling. At the time we had Gliphy. One could not make it interactable, such that double-clicking on a node would explode the container and let someone drill-down. At best they had layers which were awfully crude to work with. And at the end of the day didn't export in SVG so were useless for embedding. Overall, a waste of time. :(
- dang 3y agoRelated: The C4 model for visualising software architecture - https://news.ycombinator.com/item?id=21032805 https://news.ycombinator.com/item?id=21032805 - Sept 2019 (59 comments)
- ChicagoDave 3y agoIf you model software, both existing and future state, as a primary business and technology activity, modularize where needed, reduce high level abstractions, follow SOLID/DRY for the most part, and use bounded context operational data stores, the architectural diagrams serve a greater purpose and are a primary artifact. In other words, no one should change code without first validating those changes with the existing model(s).
- js8 3y agoTo quote Jamie Hyneman: "When in doubt, C4".
- wildermuthn 3y agoI think most visualizations suffer from identifying the wrong piece of complexity — the essential complexity is state management, not code management. Ideally, we should be able to visualize state and how state changes. This isn’t a state machine, and it isn’t database modeling. It is an understanding of information flow. Sometimes this flow of information has real-world side-effects (moving a robot’s arm), but mostly this flow is about information being created, transformed, and delivered. I use the word information because this decouples the visualization from concerns about data and modeling. The important thing is information, not necessarily the way we model that information — those kind of visualizations already exist and are helpful for writing code. But the kind of information flow visualization I’m imaging would help us to understand not how to write code, but what code that needs to be written in the first place. The most complex pieces of code tend to be buggy when changes are made to them, because they are acting upon state in ways that are essentially complex and interdependent. Wouldn’t it be nice to know that when you update a person’s first name that is is actually affecting systems X, Y, and Z rather than merely systems A, B, and C? Maybe the credit card validation system utilizes the first name in some odd way that your profile page doesn’t, but how would you know that by looking at the code for the profile page? You wouldn’t. An information flow visualization could potentially identify that. Or maybe not. People don’t usually reference visualizations or keep them updated. A visualization would have to be 10x more useful than they are today to become a routine part of the daily grind of software development, ideally built into the dev experience like IDE type errors are. Imagine an analog to jumping to a function definition for a state usage — jumping to a visualization of the information you are about to put your dirty paws upon. I suppose this would require a many-to-many relationship between the information flow visualization and state (and anywhere that state was stored, accessed, or mutated). Fun dream.
- zoom6628 3y agoIn the 80s I learnt SSADM and it was great for making sure business logic and architecture were understood and viable before a line of code was run. Which was very important on old mainframes with several hour turnarounds on compiles. For last few decades I have only used diagrams to design and to explain. Have found too hard to keep diagrams up to date when iterating on compiles multiple times per hour. What I feel is needed is ways to keep code, infra and spec in sync throughout the lifecycle.
- capn_duck 3y agoI've always been unsure where this stuff fits in. Do you make it before your system is built, when its unclear how where all the cards will fall? Or after your system is made and in production and all the warts of reality are present and your graph is not so nice and neat anymore. This seems like an architects picture of things. Close enough to give people the false confidence to think they understand things, but not close enough to be of use to anyone actually working in the salt mines.
- BerislavLopac 3y agoThe best tool for writing C4 documentation I have seen so far is https://icepanel.io/ https://icepanel.io/
- commandersaki 3y agoThis reeks of too much ceremony. Best diagrams used to describe software architecture / design is context-sensitive and ad-hoc.
- MaryGab 3y ago[dead]