Skip to content

alexgalayda/diagrams_gen

Repository files navigation

Engini HomeTask

Project Overview

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.

Run

.env

# OpenAI
OPENAI_API_KEY=sk-proj-xxx

Local

Prerequisites:

  • Python 3.12+
  • UV package manager

Install:

uv sync --all-groups

Run the application locally using:

uv run run.py

Docker

Run the server using Docker:

make docker-compose-up

Podman

Run the development container with Podman:

make podman-cpu

Usage

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:

Endpoint: /generate-diagram

Expects a JSON object with a prompt field, which is a string containing the natural language description of the diagram to be generated.

Endpoint: /generate-diagram-mock

Expects a JSON object with a json config name: example_1 and example_2.

Examples

Example 1

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'.

Basic%20Web%20Application.png

Example 2

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. Microservices%20Architecture

Testing

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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published