VisualFlow is a production-ready fullstack Django web application that transforms natural language descriptions into professional, emoji-enhanced diagrams using advanced AI. Built with Django 5.2.7, PostgreSQL, Mermaid.js v10.9.1, and powered by Groq AI (openai/gpt-oss-120b model) with intelligent three-phase diagram generation: Analyze β Generate β Validate with auto-retry and loop protection.
| Diagram Type | Use Case | AI Prompt File | Status |
|---|---|---|---|
| Flowchart π | Process flows, workflows, decision trees | flowchart_prompt.py |
β Production |
| UML Class ποΈ | OOP designs, inheritance, relationships | class_diagram_prompt.py |
β Production |
| ER Diagram ποΈ | Database schemas, entity relationships | er_diagram_prompt.py |
β Production |
| Sequence π‘ | API interactions, message flows | sequence_diagram_prompt.py |
β Production |
| State π | Finite state machines, transitions | state_diagram_prompt.py |
β Production |
| DFD π | Data flow (Level 0/1/2+), processes | dfd_prompt.py |
β Production |
| System Design π | Architecture, microservices, infra | system_design_prompt.py |
β Production |
| Custom π¨ | AI auto-detects best type | custom_prompt.py |
β Production |
| Analyzer π | Prompt analysis & enhancement | analyzer_prompt.py |
β Production |
- Emoji-Enhanced Diagrams: Context-aware emojis in labels (π― βοΈ πΎ β β π π)
- Professional Design: Clean SVG rendering with proper spacing
- Mermaid v10.9.1: Latest stable version with advanced features
- Responsive: Works on desktop, tablet, and mobile
- Dark Mode Ready: Diagrams adapt to theme
- β Syntax Validator: Catches 15+ common Mermaid errors
- β Auto-Fix Engine: Fixes bracket mixups, edge syntax, node IDs
- β Loop Protection: Detects stuck generation (code unchanged)
- β Smart Retry: AI learns from errors (max 2 attempts)
- β Graceful Fallback: Always returns valid diagram template
- β Detailed Logging: Full trace for debugging
PostgreSQL Models:
- Session: Stores prompts, generated Mermaid code, SVG, status, timestamps
- Contact: Contact form submissions with email notifications
- AppSettings: Global config (debug mode toggle for showing code)
Features:
- UUID-based session IDs for security
- Full diagram history with search
- Export diagrams (SVG, PNG, PDF)
- Bulk delete operations
- Download original Mermaid code
Before installation, ensure you have:
| Requirement | Version | Purpose |
|---|---|---|
| Python | 3.10+ | Backend runtime |
| PostgreSQL | 12+ | Production database |
| Node.js | 16+ | Tailwind CSS compilation |
| npm | 8+ | Package manager |
| Git | Latest | Version control |
| Groq API Key | - | AI generation (free tier available) |
Operating Systems: Windows 10/11, macOS 10.15+, Linux (Ubuntu 20.04+)
git clone https://github.com/rishiyaduwanshi/visualflow.git
cd visualflow
cd visualflow # Navigate to Django project directoryWindows (PowerShell):
python -m venv venv
.\venv\Scripts\Activate.ps1
# If execution policy error: Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUserLinux/macOS:
python3 -m venv venv
source venv/bin/activateVerify activation: You should see (venv) in your terminal prompt.
pip install --upgrade pip
pip install -r requirements.txtKey Dependencies Installed:
Django==5.2.7- Web frameworkpsycopg==3.3.2- PostgreSQL adapterlangchain==0.3.27- AI frameworklangchain-groq==0.3.8- Groq integrationgroq==0.32.0- Groq clientdjango-tailwind==4.2.0- Tailwind CSS integrationpython-dotenv==1.1.1- Environment variablesgunicorn==25.0.3- Production server
Option A: Local PostgreSQL
# Install PostgreSQL (if not installed)
# Windows: Download from https://www.postgresql.org/download/windows/
# macOS: brew install postgresql@14
# Ubuntu: sudo apt install postgresql postgresql-contrib
# Create database
psql -U postgres
CREATE DATABASE visualflow_db;
CREATE USER visualflow_user WITH PASSWORD 'your_secure_password';
ALTER ROLE visualflow_user SET client_encoding TO 'utf8';
ALTER ROLE visualflow_user SET default_transaction_isolation TO 'read committed';
ALTER ROLE visualflow_user SET timezone TO 'UTC';
GRANT ALL PRIVILEGES ON DATABASE visualflow_db TO visualflow_user;
\qOption B: Cloud PostgreSQL (Aiven, AWS RDS, etc.)
Use your cloud database credentials in .env file with SSL enabled.
Copy example file:
# Make sure you're in visualflow/ directory
cp .env.example .envEdit .env file with your actual credentials:
# Database Configuration
DB_NAME=visualflow_db
DB_USER=visualflow_user # or postgres
DB_PASSWORD=your_secure_password_here
DB_HOST=localhost
DB_PORT=5432
# SSL Configuration (for cloud databases)
DB_SSL_REQUIRE=false # Set to true for cloud databases
DB_SSL_MODE=prefer
# Leave empty for local database
DB_SSL_CERT_PATH=
DB_SSL_KEY_PATH=
DB_SSL_CA_PATH=
DB_SSL_CA_CERT=
# AI/ML API Keys (REQUIRED)
GROQ_API_KEY=gsk_xxxxxxxxxxxxxxxxxxxx # Get from https://console.groq.com/keys
LANGCHAIN_API_KEY=lsv2_pt_xxxxxxxxxxxx # Optional: Get from https://smith.langchain.com/
LANGCHAIN_TRACING_V2=true
LANGCHAIN_PROJECT=visualflow
# Django Configuration
SECRET_KEY=django-insecure-CHANGE-THIS-IN-PRODUCTION-use-python-secrets
DEBUG=True # Set to False in production
ALLOWED_HOSTS=localhost,127.0.0.1,your-domain.com
# Application
APP_NAME=VisualFlow
APP_VERSION=1.0.0# Create migrations
python manage.py makemigrations
# Apply migrations to database
python manage.py migrate
# Verify tables created
python manage.py dbshell
\dt # List tables (PostgreSQL)
# You should see: diagrams_session, diagrams_contact, diagrams_appsettings
\qpython manage.py createsuperuser
# Enter username, email, password when prompted# Install Tailwind dependencies (Node.js required)
python manage.py tailwind install
# Build CSS for production
python manage.py tailwind buildOption A: Run with Tailwind watcher (Recommended for development)
Terminal 1 (Tailwind hot reload):
python manage.py tailwind startTerminal 2 (Django server):
python manage.py runserverOption B: Production build
python manage.py tailwind build
python manage.py runservergraph TD
User[π€ User] -->|Enters prompt| Frontend[π Frontend<br/>Tailwind + Mermaid.js]
Frontend -->|POST /generate| Django[βοΈ Django Views]
Django -->|1. Detect Type| AIService[π€ AI Service<br/>diagram_type_detection]
Django -->|2. Generate| MermaidService[π§ Mermaid Service<br/>3-Phase Pipeline]
MermaidService -->|Phase 1| Analyzer[π Analyzer AI<br/>Extract entities]
Analyzer -->|Phase 2| Generator[β¨ Generator AI<br/>9 specialized prompts]
Generator -->|Phase 3| Validator[π‘οΈ Validator<br/>Auto-fix + Retry]
Validator -->|Valid code| Renderer[π¨ Mermaid Renderer]
Validator -->|Invalid| Retry[π Auto-Retry<br/>max 2 attempts]
Retry -->|With feedback| Generator
Renderer -->|SVG| Database[(πΎ PostgreSQL<br/>Session Model)]
Database -->|Retrieve| Frontend
MermaidService -.->|API calls| Groq[βοΈ Groq AI<br/>gpt-oss-120b]
VisualFlow - Transform Ideas into Professional Diagrams with AI π
Made with β€οΈ by Abhinav Prakash
β Star us on GitHub if you find this useful!