Skip to main content

Turn static graphs into beautiful animations

Project description

Viviphi Logo

Stars Forks Issues Contributors License
Build Status Coverage Status Last Commit Repo Size Python Version
PyPI version Downloads PRs Welcome

Turn static graphs into beautiful animations!

Viviphi transforms your Mermaid.js diagrams into stunning animated SVGs with customizable themes and smooth transitions. Perfect for presentations, documentation, or just making your diagrams come alive.

✨ Features

  • 🎨 Multiple Themes: Cyberpunk, Corporate, and Hand-drawn styles
  • Easy to Use: Simple Python API with just a few lines of code
  • 🎯 Mermaid Compatible: Works with standard Mermaid.js syntax
  • 🚀 Fast Rendering: Powered by Playwright for reliable SVG generation
  • 🎛️ Customizable: Adjustable animation speeds and timing

🚀 Quick Start

Installation

# Install viviphi
uv add viviphi

# Install browser dependencies
uv run playwright install chromium

Basic Usage

from viviphi import Graph, MANIM_AQUA

# Define your Mermaid graph
mermaid_code = """
graph TD
    A[Start] --> B{Decision}
    B -->|Yes| C[Action 1]
    B -->|No| D[Action 2]
    C --> E[End]
    D --> E
"""

# Create and animate
graph = Graph(mermaid_code)
animated_svg = graph.animate(theme=MANIM_AQUA, output="my_graph.svg")

That's it! Your animated SVG is ready.

🎨 Themes

Viviphi comes with three built-in themes:

Manim Aqua 🌊

from viviphi import Graph, MANIM_AQUA

graph = Graph(mermaid_code)
graph.animate(theme=MANIM_AQUA, output="manim_aqua_graph.svg")
Manim Aqua Theme Example

Gradient Sunset 🌅

from viviphi import Graph, GRADIENT_SUNSET

graph = Graph(mermaid_code)
graph.animate(theme=GRADIENT_SUNSET, output="gradient_sunset_graph.svg")
Gradient Sunset Theme Example

Hand Drawn ✏️

from viviphi import Graph, HAND_DRAWN

graph = Graph(mermaid_code)
graph.animate(theme=HAND_DRAWN, output="hand_drawn_graph.svg")
Hand Drawn Theme Example

⚡ Animation Speed

Control the animation speed with the speed parameter:

# Slow and dramatic
graph.animate(theme=MANIM_AQUA, speed="slow")

# Default speed
graph.animate(theme=MANIM_AQUA, speed="normal")

# Quick and snappy
graph.animate(theme=MANIM_AQUA, speed="fast")

📊 Supported Diagram Types

Viviphi works with all standard Mermaid diagram types:

Flowcharts

flowchart = """
graph LR
    A[User] --> B[Login]
    B --> C{Valid?}
    C -->|Yes| D[Dashboard]
    C -->|No| E[Error]
"""
Flowchart Example

Sequence Diagrams

sequence = """
sequenceDiagram
    participant A as Alice
    participant B as Bob
    A->>B: Hello Bob
    B->>A: Hello Alice
"""
Sequence Diagram Example

Class Diagrams

class_diagram = """
classDiagram
    class Vehicle {
        +String make
        +String model
        +start()
        +stop()
    }
    class Car {
        +openTrunk()
    }
    Vehicle <|-- Car
"""
Class Diagram Example

State Diagrams

state_diagram = """
stateDiagram-v2
    [*] --> Idle
    Idle --> Running: start()
    Running --> Idle: stop()
    Running --> [*]: shutdown()
"""
State Diagram Example

🔧 Advanced Usage

Batch Processing

Process multiple diagrams at once:

from pathlib import Path
from viviphi import Graph, CYBERPUNK, CORPORATE, HAND_DRAWN

def animate_all_diagrams(input_dir: Path, output_dir: Path):
    themes = {
        "cyberpunk": CYBERPUNK,
        "corporate": CORPORATE, 
        "hand_drawn": HAND_DRAWN
    }
    
    for mermaid_file in input_dir.glob("*.mmd"):
        content = mermaid_file.read_text()
        graph = Graph(content)
        
        for theme_name, theme in themes.items():
            output_file = output_dir / f"{mermaid_file.stem}_{theme_name}.svg"
            graph.animate(theme=theme, output=str(output_file))

Custom Timing

Fine-tune animation timing:

from viviphi import Graph, Theme

# Create a custom theme with specific timing
custom_theme = Theme(
    primary_color="#ff6b6b",
    background="#2d3748",
    edge_style="neon",
    animation_duration=2.5,  # Longer animations
    stagger_delay=0.5        # More delay between elements
)

graph = Graph(mermaid_code)
graph.animate(theme=custom_theme)

🎯 Real-World Examples

Documentation Workflow

from viviphi import Graph, GRADIENT_SUNSET

# Load your workflow diagram
workflow = """
graph TD
    A[Write Code] --> B[Create Mermaid Diagram]
    B --> C[Generate Animated SVG]
    C --> D[Include in Documentation]
    D --> E[Profit! 🎉]
"""

# Generate for docs
graph = Graph(workflow)
graph.animate(theme=GRADIENT_SUNSET, speed="normal", output="docs/workflow.svg")

System Architecture

from viviphi import Graph, MANIM_AQUA

architecture = """
graph TB
    subgraph "Frontend"
        UI[React App]
        API[API Client]
    end
    
    subgraph "Backend" 
        SERVER[Express Server]
        DB[(PostgreSQL)]
        CACHE[(Redis)]
    end
    
    UI --> API
    API --> SERVER
    SERVER --> DB
    SERVER --> CACHE
"""

graph = Graph(architecture)
graph.animate(theme=MANIM_AQUA, output="architecture.svg")

📁 Project Structure

viviphi/
├── viviphi/           # Main package
│   ├── animator.py    # SVG animation engine  
│   ├── graph.py       # Main Graph class
│   ├── mermaid.py     # Mermaid rendering
│   └── themes.py      # Theme definitions
├── examples/          # Usage examples
├── resources/         # Sample Mermaid files
└── tests/            # Test suite

🛠️ Development

# Clone the repository
git clone <repository-url>
cd viviphi

# Install dependencies
uv sync --no-install-project

# Run tests
uv run pytest

# Check code quality
ruff check
ruff format

🤝 Contributing

We welcome contributions! Please feel free to submit issues and pull requests.

📄 License

This project is open source. See LICENSE file for details.


Made with ❤️ by the Viviphi team

Transform your static diagrams into dynamic stories!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

viviphi-1.1.2.tar.gz (35.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

viviphi-1.1.2-py3-none-any.whl (20.3 kB view details)

Uploaded Python 3

File details

Details for the file viviphi-1.1.2.tar.gz.

File metadata

  • Download URL: viviphi-1.1.2.tar.gz
  • Upload date:
  • Size: 35.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for viviphi-1.1.2.tar.gz
Algorithm Hash digest
SHA256 3d35355380f42b9cb4956cad7cd888475070f456705c5b27941529540a792639
MD5 2e9b9826582c7db886781332a4f93748
BLAKE2b-256 538491d9673c5807357627ca1a1c7f2d15cd4ceb79b729449e6d185c5b874e5c

See more details on using hashes here.

Provenance

The following attestation bundles were made for viviphi-1.1.2.tar.gz:

Publisher: publish.yml on dbudaghyan/viviphi

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file viviphi-1.1.2-py3-none-any.whl.

File metadata

  • Download URL: viviphi-1.1.2-py3-none-any.whl
  • Upload date:
  • Size: 20.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for viviphi-1.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 0b291f94c294ecf4029e6c33a63d051e3cbf5b2b50663b4fb733df1c0576da93
MD5 4122bc6beaa31beadd19f9e087cc371a
BLAKE2b-256 486c62ef59ba0a06c5eb08cfac0af81e93d44a943562c88723ecdbb92f4b908e

See more details on using hashes here.

Provenance

The following attestation bundles were made for viviphi-1.1.2-py3-none-any.whl:

Publisher: publish.yml on dbudaghyan/viviphi

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page