Automatic Architecture Diagrams from Code
Free • Open Source • Powered by LLMs
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.
- 🔎 Learn a New Codebase: Swark helps you quickly generate an architecture diagram of a repository, providing a high-level overview of the codebase without the need to manually explore files or folder structure. This allows you to focus on the areas most relevant to your work.
- 📕 Documentation: enhance your documentation with up-to-date architecture diagrams that are simple to create and require minimal engineering effort.
- 🧩 Visualize Dependencies: a dependency graph of your repo can help you spot unwanted dependencies and suboptimal design.
- ✅ Test Coverage: include your tests in Swark's input to visualize your test coverage and identify areas that may be missing.
- 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.
- 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.
- LLM Request: Swark invokes LLM request to GitHub Copilot via VS Code Language Model API.
- 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.
It's important to note that source code is only shared with GitHub Copilot, and with no other external APIs or providers.
- 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.
- Mermaid Markdown Preview: to preview the diagram in VS Code you can install the Markdown Preview Mermaid Support extension. Otherwise, you can use the provided links to open it in Mermaid Live Editor.
Simply install Swark via the VS Code Extension Marketplace.
- 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) orctrl+shift+r
(Windows). - Select a folder to use in Swark's file search.
- Within a few seconds, a tab will open displaying a preview of your architecture diagram.
Another tab will contain the diagram's code, which you can edit manually or copy for use in other tools.
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. |
The LLM's output may occasionally generate a cycle in the Mermaid code, resulting in the following error:
Syntax error in text
mermaid version 11.4.0
Setting Node as parent of Node would create a cycle
This occurs when a parent and child node share the same name.
To resolve this issue:
- Re-run Swark to generate a new result.
- Edit the diagram code manually by renaming the parent node to give it a unique name.
See CHANGELOG.md.
Swark welcomes community contributions. Please see our Contribution Guide for details on how to contribute.
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.
Swark is licensed under the GNU Affero General Public License v3.0