Type something to search...
Introducing Swark: Automatic Architecture Diagrams from Code

Introducing Swark: Automatic Architecture Diagrams from Code

Software architecture is hard to get right. Misaligned teams, unclear diagrams, and time-consuming processes often result in frustration and suboptimal design decisions. As engineering teams embrace a decentralized, collaborative approach to architecture, the stakes grow even higher.

In my previous article, Software Architecture is Hard”, I explored these challenges in depth, highlighting the critical gaps in communication and diagramming standards that plague many teams.

In an attempt to make software architecture a bit easier, equipped with the new capabilities unlocked by AI and LLMs, I tried to tackle and automate one of the most vital parts of software architecture — diagramming.

Meet Swark

Swark is a free and open source VS Code extension that allows creating architecture diagrams from code automatically using large language models (LLMs).

Within a few clicks, you can create an architecture diagram for your repository:

Why Swark?

  • 🌟 Free and Open Source: All you need is GitHub Copilot, which is now available for free. You can review Swark’s code to understand how it works, and contribute to make it better.
  • 🌍 Universal Language Support: Classic code visualization solutions are deterministic and require to incrementally add support in new languages or frameworks. With Swark, all the “logic” is encapsulated within the LLM, and therefore it natively support all languages.
  • 🔑 Seamless Integration: Swark integrates directly with GitHub Copilot. No additional setup, authentication, or API keys required.
  • 🛡️ Privacy First: Your source code is shared only with GitHub Copilot — no other external APIs or providers involved.
  • 🧜‍♀️ Mermaid.js: Swark generates diagrams in Mermaid.js, a popular diagram-as-code framework. You can edit and refine the diagrams as needed.

Use Cases

  • 🔎 Learn a New Codebase: Instantly generate architecture diagrams to gain a high-level understanding of unfamiliar repositories. Ideal for onboarding and tackling new projects.
  • 🤖 Review AI-Generated Code: As AI-generated projects become more common, Swark helps you quickly visualize their structure and ensure they meet your standards.
  • 📕 Improve Documentation: Keep your documentation fresh and detailed with up-to-date architecture diagrams that take minutes to create.
  • 🧩 Spot Design Flaws: Visualize your repo’s dependency graph to identify unwanted dependencies or areas for optimization.
  • ✅ Test Coverage Insights: Include test files in Swark’s input to see test coverage at a glance and address gaps.

How It Works

  1. File Retrieval: Swark retrieves code files within the chosen folder. Swark automatically adjusts the number of retrieved files to match the LLM max token limit.
  2. Prompt Building: based on the retrieved files, Swark builds a prompt to generate an architecture diagram. The code files are included in the prompt, together with instructions on how to build the diagram.
  3. LLM Request: Swark invokes LLM request to GitHub Copilot via VS Code Language Model API.
  4. Diagram Preview: upon a successful response, the diagram is presented. This is done by creating a markdown file that includes the diagram in Mermaid syntax and previewing it.

Examples

Following are examples for architecture diagrams that have been created with Swark.

Swark

Programming Language: TypeScriptNumber of Files: 16

LangChain (Agents Lib)

Programming Language: PythonNumber of Files: 145

Join The Community

Got feedback, thoughts or ideas? would love to hear it via the comments below.

Related Posts

10 Creative Ways to Use ChatGPT Search The Web Feature

10 Creative Ways to Use ChatGPT Search The Web Feature

For example, prompts and outputs Did you know you can use the “search the web” feature of ChatGPT for many tasks other than your basic web search? For those who don't know, ChatGPT’s new

Read More
📚 10 Must-Learn Skills to Stay Ahead in AI and Tech 🚀

📚 10 Must-Learn Skills to Stay Ahead in AI and Tech 🚀

In an industry as dynamic as AI and tech, staying ahead means constantly upgrading your skills. Whether you’re aiming to dive deep into AI model performance, master data analysis, or transform trad

Read More
10 Powerful Perplexity AI Prompts to Automate Your Marketing Tasks

10 Powerful Perplexity AI Prompts to Automate Your Marketing Tasks

In today’s fast-paced digital world, marketers are always looking for smarter ways to streamline their efforts. Imagine having a personal assistant who can create audience profiles, suggest mar

Read More
10+ Top ChatGPT Prompts for UI/UX Designers

10+ Top ChatGPT Prompts for UI/UX Designers

AI technologies, such as machine learning, natural language processing, and data analytics, are redefining traditional design methodologies. From automating repetitive tasks to enabling personal

Read More
100 AI Tools to Finish Months of Work in Minutes

100 AI Tools to Finish Months of Work in Minutes

The rapid advancements in artificial intelligence (AI) have transformed how businesses operate, allowing people to complete tasks that once took weeks or months in mere minutes. From content creat

Read More
17 Mindblowing GitHub Repositories You Never Knew Existed

17 Mindblowing GitHub Repositories You Never Knew Existed

Github Hidden Gems!! Repositories To Bookmark Right Away Learning to code is relatively easy, but mastering the art of writing better code is much tougher. GitHub serves as a treasur

Read More