Skip to content

An intelligent UML generation agent for C++ using LangGraph, Tree-sitter, and LLMs. Automates class and sequence diagram creation with self-correcting workflows.

License

Notifications You must be signed in to change notification settings

memory-killer/DocuGraph

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DocuGraph

An intelligent UML generation agent for C++ using LangGraph, Tree-sitter, and LLMs. Automates class and sequence diagram creation with self-correcting workflows.

Prerequisites

Item Version / Notes
Python (virtual environment recommended)
Java JRE/JDK 8+ (required by plantuml.jar)
OpenAI API key Set in .env file
PlantUML JAR Already included as plantuml.jar in the repo

Quick Start

# 1️⃣ Clone the repo (if not already)
git clone <repo-url>
cd uml-agent

# 2️⃣ Create & activate a virtual environment
python -m venv .venv
source .venv/bin/activate

# 3️⃣ Install dependencies
pip install -r requirements.txt

# 4️⃣ Create a .env file
echo "OPENAI_API_KEY=sk-..." > .env

# 5️⃣ Run the agent on a C++ file

# Generate Class Diagram (Default)
python -m src.main example.cpp

# Generate Sequence Diagram
# Use --target to specify the starting function (e.g. main, User::login)
python -m src.main example.cpp --type sequence --target main

Expected output

  • example.puml will be generated in the project root.
  • The console prints a short status message:
Analyzing example.cpp...
Successfully generated PlantUML to example.puml

Rendering the diagram

java -jar plantuml.jar example.puml

This creates example.png (or .svg depending on PlantUML settings) in the same directory.

Running the test suite

⚠️ Important: Always activate the virtual environment before running tests!

# Activate virtual environment first
source .venv/bin/activate

# Run tests
python -m pytest tests/

Or in one line:

source .venv/bin/activate && python -m pytest tests/

All tests should pass.

  • tests/test_analyzer.py: Checks class and inheritance extraction logic.
  • tests/test_sequence.py: Tests function body extraction for sequence diagram generation.
  • tests/test_validation.py: Tests validation logic such as checking target function existence.
  • tests/test_validator.py: Tests PlantUML syntax validation using the JAR file.

Project Structure

uml-agent/
├── src/
│   ├── __init__.py
│   ├── analyzer.py      # Tree-sitter based C++ parser
│   ├── validator.py     # PlantUML syntax validator
│   ├── workflow.py      # LangGraph state machine
│   └── main.py          # CLI entry point
├── tests/
│   ├── test_analyzer.py
│   ├── test_sequence.py
│   ├── test_validation.py
│   └── test_validator.py
├── example.cpp          # Sample source file
├── plantuml.jar         # PlantUML runtime
├── requirements.txt
└── README.md            # This file

FAQ

Q: "plantuml" command not found

A: The repository ships plantuml.jar. Use java -jar plantuml.jar … or install PlantUML globally (brew install plantuml on macOS).

Q: "ModuleNotFoundError: No module named 'src'" when running tests

A: You forgot to activate the virtual environment. Run:

source .venv/bin/activate

Q: How to change the LLM provider?

A: Update src/workflow.py to use ChatAnthropic, AzureOpenAI, etc., and set the corresponding environment variables.

About

An intelligent UML generation agent for C++ using LangGraph, Tree-sitter, and LLMs. Automates class and sequence diagram creation with self-correcting workflows.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published