The diagrams_gen
project is an asynchronous, stateless Python API service designed to empower users to create diagrams using natural language descriptions. Leveraging MCP agent powered by a Large Language Model (LLM), this service allows users to describe diagram components, nodes, or flows in natural language and receive a rendered image in return. The project supports generating diagrams for various architectures, such as web applications and microservices. This innovative approach simplifies the process of diagram creation, making it accessible to users without requiring detailed technical knowledge of diagramming tools.
# OpenAI
OPENAI_API_KEY=sk-proj-xxx
Prerequisites:
- Python 3.12+
- UV package manager
Install:
uv sync --all-groups
Run the application locally using:
uv run run.py
Run the server using Docker:
make docker-compose-up
Run the development container with Podman:
make podman-cpu
The methods generate_diagram
and generate_diagram_mock
in the api.py
file are designed to handle POST requests for generating diagrams based on natural language prompts. Here's a description of each method:
Expects a JSON object with a prompt field, which is a string containing the natural language description of the diagram to be generated.
Expects a JSON object with a json config name: example_1
and example_2
.
Create a diagram showing a basic web application with an Application Load Balancer, two EC2 instances for the web servers, and an RDS database for storage. The web servers should be in a cluster named 'Web Tier'.
Design a microservices architecture with three services: an authentication service, a payment service, and an order service. Include an API Gateway for routing, an SQS queue for message passing between services, and a shared RDS database. Group the services in a cluster called 'Microservices'. Add CloudWatch for monitoring.
Run tests to ensure the functionality of the project:
uv run pytest --cov=diagrams_gen --cov-report=html
View the test coverage report by opening the following file in a browser:
file:///home/workspace/diagrams_gen/htmlcov/index.html