🎉 Keadex Mina 1.0 is now available!

Diagram Generation w/ AI

Mina integrates AI to generate diagram code based on a natural language description of your architecture.

Screenshot of Keadex Mina generatic diagrams with the AI

Since Mina strongly supports open-source technologies, it offers a configurable AI integration that allows you to choose the AI APIs and model you want to use.

Whatever AI APIs you decide to implement, make sure they are compatible with the OpenAI format. Tools like LiteLLM (opens in a new tab) can be used to ensure the OpenAI format.

This flexibility allows you to leverage AI features for free by running an open-source AI model like Llama (opens in a new tab) locally, using tools such as Ollama (opens in a new tab).

Keadex Mina will then interpret the AI's response and utilize its own rendering system to render the generated diagram code.

Example of usage with Ollama

In this example, we'll use Ollama (opens in a new tab) to run the Code Llama LLM (opens in a new tab) locally and configure Mina to leverage it for enabling AI features, including generating diagrams from natural language prompts.

Run the LLM locally

  1. Download Ollama from https://ollama.com/ (opens in a new tab)
  2. Install and run Ollama
  3. Open the terminal and run the following command: ollama run codellama:7b-instruct. This command will download and locally run the Code Llama LLM (opens in a new tab), which can generate code from text prompts. In this case, we're downloading the smallest version of the model due to the hardware limitations of the local machine. However, you're free to choose a larger version or a different LLM based on your requirements.
⚠️

Since we're running the smallest version of the LLM locally, code generation may be slow and might not always produce valid results. For better performance and more accurate outputs, consider running a larger version of the LLM on more powerful hardware.

Configure Mina to integrate with the locally running LLM

  1. Open your project in Mina
  2. Click on the project icon () in the sidebar
  3. Click on the settings button
  4. In the AI Integration section, fill in the following details:
    • AI API Key: The API key for accessing the AI APIs. Enter ollama since we're using Ollama.
    • AI API (OpenAI compatible) Base URL: The base URL of the AI APIs you're using (compatible with OpenAI). Ollama provides OpenAI-compatible APIs (opens in a new tab) at this base URL: http://localhost:11434/v1 (opens in a new tab)
    • AI Model: Enter the name of the LLM you're using. Since we selected codellama:7b-instruct in step 3, you can use that name here.
  5. Click on the save button
  6. Mina can now interact with the LLM to generate diagrams

Generate a diagram using AI assistance

  1. Open a diagram in Mina
  2. In the code editor, place the cursor where you want the generated code to appear
  3. In the code editor toolbar, click on the AI icon (). This will open a text area where you can enter your prompt.
  4. Enter in the text area the description of the architecture for which you want to generate the C4 Model diagram
  5. Click on the generate button
Keadex logo
Keadex ©2024. Code licensed under an MIT-style License. Documentation licensed under CC BY 4.0.