Skip to content

darc1/auto-diagram

Repository files navigation

auto-diagram

Automatic diagram generation with GenAI

Setup

1) Create and activate a virtual environment

Mac/Linux:

python3 -m venv .venv
source .venv/bin/activate
python -m pip install --upgrade pip

Windows (PowerShell):

py -m venv .venv
.\.venv\Scripts\Activate.ps1
python -m pip install --upgrade pip

2) Install dependencies

pip install -r requirements.txt

3) Set your OpenAI API key

Mac/Linux:

export OPENAI_API_KEY="sk-..."

Windows (PowerShell):

$env:OPENAI_API_KEY = "sk-..."

The code uses the OPENAI_API_KEY environment variable (see src/core.py).

Run the CLI

You can run the CLI script directly. The --supporting-files option points to a directory whose files are added to context. An example context is provided under examples/NSCacheFlush/context.

# From the repo root
python src/cli.py create \
  "Generate a Mermaid diagram explaining the NSCacheFlush network flow" \
  --supporting-files examples/NSCacheFlush/context \
  --output output/diagram.mmd

The diagram text (Mermaid) is saved to output/diagram.mmd.

Run the Streamlit app

streamlit run src/streamlit.py

In the app:

  • Provide your OpenAI API key in the sidebar (or set OPENAI_API_KEY beforehand).
  • Enter a prompt describing the system or network flow.
  • Optionally upload supporting files (text/code/images) to ground the model.
  • Click “Generate Diagram” to produce editable Mermaid text.

About

Automatic diagram generation with GenAI

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages