| # Any2SVG Architecture | |
| ## Overview | |
| Any2SVG is a Gradio 6 application that converts raster images to SVG vector graphics. It's designed to work both as a standalone web application and as an MCP (Model Context Protocol) server for AI agent integration. | |
| ## DNA Architecture | |
| The project follows the DNA architecture pattern: | |
| ``` | |
| any-to-svg/ | |
| βββ app.py # Main Gradio application | |
| βββ dna/ | |
| β βββ atoms/ # Core utilities | |
| β β βββ vectorizer.py # Low-level vtracer wrapper | |
| β βββ molecules/ # Composite components | |
| β β βββ mcp_handler.py # MCP request processing | |
| β βββ proteins/ # High-level orchestration | |
| βββ knowledge-base/ # Documentation | |
| βββ output/ # Generated SVG files | |
| ``` | |
| ## Components | |
| ### Atoms Layer | |
| - `vectorizer.py`: Core vectorization using vtracer library | |
| - `VectorizerConfig`: Configuration dataclass | |
| - `image_to_svg_string()`: Convert to SVG string | |
| - `image_to_svg_file()`: Convert and save to file | |
| ### Molecules Layer | |
| - `mcp_handler.py`: MCP integration | |
| - `process_mcp_request()`: Handle MCP tool calls | |
| - `get_output_directory()`: Manage output paths | |
| ### Application Layer | |
| - `app.py`: Gradio interface and MCP server | |
| - Web UI with configurable parameters | |
| - MCP tool endpoint at `/gradio_api/mcp/sse` | |
| ## MCP Integration | |
| The application exposes an MCP tool `image_to_svg` that: | |
| 1. Accepts image input (URL or base64) | |
| 2. Converts to SVG using vtracer | |
| 3. Saves to configured output directory | |
| 4. Returns file path and SVG content | |
| ## Security Considerations | |
| - Input validation on all image uploads | |
| - Sanitized file paths for output | |
| - Environment variable protection for sensitive config | |
| - No arbitrary code execution | |