Generate, Visualize, and Edit Mermaid flowcharts using local LLMs (Ollama) in a simple Streamlit GUI.
This application enhances the local diagram generation workflow with several key features:
- 100% Local Execution: No subscriptions, no cloud APIs. All computation runs on your machine using Ollama and local LLMs.
- Dynamic LLM Selection: Automatically detects and lets you select any installed model from your local Ollama server.
- Interactive GUI: Built with Streamlit for a simple, responsive, and iterative user experience.
- Live Visualization: Instantly renders the generated Mermaid code into an SVG diagram directly in the browser.
- In-App Editing: Allows manual code fixes and instant re-rendering without having to regenerate the prompt.
- Error Debugging: Provides clear
mmdcoutput logs directly in the interface if code generation fails.
You must have the following tools installed and running before starting the application:
- Ollama: The local LLM runner must be installed and running on
http://localhost:11434.- Check: Ensure you have at least one model pulled (e.g.,
ollama pull llama3).
- Check: Ensure you have at least one model pulled (e.g.,
- Node.js & npm: Required to install the Mermaid CLI tool.
- Mermaid CLI (
mmdc): The command-line tool used to convert the Mermaid code into image files (SVG/PNG).
Install the necessary dependencies globally using npm:
# Installs the official Mermaid CLI package
npm install -g @mermaid-js/mermaid-cli-
Clone the Repository
Bash
git clone [https://github.com/aairom/ollama-mermaid-architect.git] (https://github.com/aairom/ollama-mermaid-architect.git) cd ollama-mermaid-architect -
Setup Python Environment (Recommended)
Bash
python -m venv venv source venv/bin/activate # On Windows, use `venv\Scripts\activate` -
Install Python Dependencies
Bash
pip install -r requirements.txt(Create a
requirements.txtfile containingstreamlit,requests, and any other dependencies.)
-
Start Ollama: Ensure your Ollama server is running in the background.
Bash
ollama run granite4 # Or any model you plan to use -
Run the Streamlit Application
Bash
streamlit run appST.py -
Interface Guide
- The app will open in your default browser (
http://localhost:8501). - Sidebar: Select your active Ollama model from the dropdown.
- Input: Enter a natural language description of the flowchart you want (e.g., "Create a graph for a CI/CD pipeline showing stages for build, test, and deploy").
- Generate: Click the
🚀 Generatebutton. - View/Edit: Use the tabs to switch between the Diagram Visualization (image) and the Edit Code view. You can modify the code in the second tab and click
🔄 Update Diagramto instantly see the changes.
python app_V3.py - The app will open in your default browser (
.
├── app_V3.py # The main console version application code.
├── appST.py # The main Streamlit application code.
├── requirements.txt # List of Python dependencies.
├── README.md # This file.
└── input/ # The foloder were MMD files could be stored to be processed recursivley
└── output/ # Directory where generated SVG/PNG files are saved.
Contributions are welcome! If you have suggestions for new features (like PDF export, new chart types, or improved error handling), please feel free to open an issue or submit a pull request.
Distributed under the MIT License. See LICENSE for more information.