swark

swark

Create architecture diagrams from code automatically using large language models (LLMs).

Stars: 115

Visit
 screenshot

Swark is a VS Code extension that automatically generates architecture diagrams from code using large language models (LLMs). It is directly integrated with GitHub Copilot, requires no authentication or API key, and supports all languages. Swark helps users learn new codebases, review AI-generated code, improve documentation, understand legacy code, spot design flaws, and gain test coverage insights. It saves output in a 'swark-output' folder with diagram and log files. Source code is only shared with GitHub Copilot for privacy. The extension settings allow customization for file reading, file extensions, exclusion patterns, and language model selection. Swark is open source under the GNU Affero General Public License v3.0.

README:

Automatic Architecture Diagrams from Code
Free β€’ Open Source β€’ Powered by LLMs

GitHub Issues PRs welcome!

Swark

Swark is a VS Code extension that allows creating architecture diagrams from code automatically using large language models (LLMs).
Swark is directly integrated with GitHub Copilot, and requires no authentication or API key.

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.
  • πŸ•°οΈ Understand Legacy Code: Quickly visualize and comprehend the structure of legacy codebases, making it easier to maintain and refactor.
  • 🧩 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.

Requirements

  • GitHub Copilot: Swark is integrated with GitHub Copilot to invoke LLM queries. Install it via Visual Studio Marketplace. Notice that GitHub Copilot now offers a free tier.
  • [Optional] Mermaid Markdown Preview: To preview the diagram in VS Code you can install the Markdown Preview Mermaid Support extension. Alternatively, you can use the provided links to open it in Mermaid Live Editor.

Installation

Simply install Swark via the VS Code Extension Marketplace.

How to Use

  1. In VS Code, open the Command Palette and run: Swark: Create Architecture Diagram.
    Alternatively, you can use Swark's default keybindings: cmd+shift+r (Mac) or ctrl+shift+r (Windows).
  2. Select a folder to use in Swark's file search.
  3. Within a few seconds, a tab will open displaying your architecture diagram.

Swark Demo

Output

Swark saves its output in swark-output folder under your workspace root folder.
On each run, Swark creates two output files:

  • Diagram file: Contains the diagram's Mermaid code. This file is presented when you run Swark.
    Filename: <date>__<time>__diagram.md
  • Log file: Contains information about the run, configuration, and files used to create the diagram. Can be used for debugging and issue reporting.
    Filename: <date>__<time>__log.md

For example:

workspace-root
└── swark-output
 Β Β  β”œβ”€β”€ 2025-01-09__20-18-38__diagram.md
 Β Β  └── 2025-01-09__20-18-38__log.md

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.

Code Access and File Sharing

It's important to note that source code is only shared with GitHub Copilot, and with no other external APIs or providers.

Extension Settings

This extension contributes the following settings:

Setting Description
swark.maxFiles Max number of files to read.
The number of files read is also affected by the LLM max token limit.
swark.fileExtensions List of file extensions to include in search.
swark.excludePatterns List of glob patterns to exclude from file search.
Defaults include: **/.* for hidden files, **/node_modules/** for node modules.
swark.languageModel Language model to use for diagram generation.

Release Notes

See CHANGELOG.md.

Contributing

Swark welcomes community contributions. Please see our Contribution Guide for details on how to contribute.

Privacy Notice

This extension collects telemetry data to help improve the product experience. The data collected includes:

  • Extension activation and usage events
  • Selected model information
  • Number of files processed and prompt length
  • LLM response time
  • Error events

No source code, file contents, or personal information is ever included in the telemetry data.

We use @vscode/extension-telemetry module to collect this data. The data is sent to Azure Application Insights and is used solely to improve Swark's functionality and user experience.

You can disable telemetry collection by setting "telemetry.telemetryLevel": "off" in your VS Code settings.

License

Swark is licensed under the GNU Affero General Public License v3.0

For Tasks:

Click tags to check more tools for each tasks

For Jobs:

Alternative AI tools for swark

Similar Open Source Tools

For similar tasks

For similar jobs