Visual Terraform Infrastructure Designer with Stripe subscriptions
TFVisualizer is a Python Flask web application that allows users to visually design, manage, and optimize Terraform infrastructure. It features drag-and-drop interface design, real-time cost estimation, module support, and Stripe-powered subscriptions.
- Visual Terraform Designer: Drag-and-drop AWS resources onto a canvas
- Real-time Cost Estimation: See infrastructure costs as you build
- Import/Export: Import existing .tf files and export to Terraform code
- Module Support: Use Terraform Registry modules visually
- Data Sources: Query existing AWS infrastructure
- Stripe Subscriptions: $4.99/month Pro tier with unlimited projects
Backend:
- Python 3.11+
- Flask web framework
- SQLAlchemy ORM
- PostgreSQL database
- Redis for caching
- Stripe Python SDK
- python-hcl2 for Terraform parsing
Frontend:
- Vanilla JavaScript
- HTML5/CSS3
- Interactive canvas-based UI
Infrastructure:
- Docker & Docker Compose
- GitHub Container Registry (ghcr.io)
- DigitalOcean Kubernetes Service (DOKS)
- AWS S3-compatible (DigitalOcean Spaces)
- Gunicorn WSGI server
- Docker (for containerized deployment)
- OR Python 3.11+ with PostgreSQL and Redis (for local development)
- Stripe account (for payment processing)
- GitHub account (for container registry)
Docker images are hosted on GitHub Container Registry:
# Pull latest image
docker pull ghcr.io/elliotechne/tfvisualizer:latest
# Login for private images
echo $GITHUB_TOKEN | docker login ghcr.io -u your-username --password-stdinSee GHCR_SETUP.md for complete configuration guide.
- Build the image
docker build -t tfvisualizer:latest .- Run with Docker network
# Create network
docker network create tfvisualizer-network
# Run PostgreSQL
docker run -d --name postgres --network tfvisualizer-network \
-e POSTGRES_DB=tfvisualizer -e POSTGRES_USER=tfuser -e POSTGRES_PASSWORD=secure_pass \
postgres:15-alpine
# Run Redis
docker run -d --name redis --network tfvisualizer-network redis:7-alpine
# Run Application
docker run -d --name tfvisualizer-app --network tfvisualizer-network -p 80:80 \
-e DATABASE_URL=postgresql://tfuser:secure_pass@postgres:5432/tfvisualizer \
-e REDIS_URL=redis://redis:6379 \
-e DB_HOST=postgres -e DB_PORT=5432 -e DB_NAME=tfvisualizer \
-e DB_USER=tfuser -e DB_PASSWORD=secure_pass \
-e SECRET_KEY=change_this_in_production \
-e JWT_SECRET=change_this_in_production \
-e STRIPE_SECRET_KEY=sk_test_your_key \
-e STRIPE_PUBLISHABLE_KEY=pk_test_your_key \
tfvisualizer:latest- Access the application
- Landing page: http://localhost
- Visual editor: http://localhost/editor
- Health check: http://localhost/health
See DOCKER.md for complete Docker documentation.
cp .env.example .env
# Edit .env with your configuration
docker-compose up -d- Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate- Install dependencies
pip install -r requirements.txt- Set up database
flask db upgrade- Run development server
# Note: Running on port 80 requires sudo on Linux/Mac
sudo flask run --host=0.0.0.0 --port=80
# Or run on a different port for development
PORT=8080 flask run --host=0.0.0.0 --port=8080- Create a Stripe account at https://stripe.com
- Get your API keys from https://dashboard.stripe.com/apikeys
- Create a Product and Price for $4.99/month recurring
- Set up webhook endpoint:
https://yourdomain.com/api/webhooks/stripe - Add webhook events:
customer.subscription.createdcustomer.subscription.updatedcustomer.subscription.deletedpayment_intent.succeededpayment_intent.payment_failed
STRIPE_SECRET_KEY=sk_test_...
STRIPE_PUBLISHABLE_KEY=pk_test_...
STRIPE_WEBHOOK_SECRET=whsec_...
STRIPE_PRICE_ID_PRO=price_...- Stores user accounts with authentication
- Tracks Stripe customer ID and subscription status
- Links to Stripe subscription IDs
- Tracks billing periods and cancellation status
- User's Terraform infrastructure designs
- Supports versioning
- Records all payment transactions
POST /api/auth/register- Register new userPOST /api/auth/login- LoginGET /api/auth/me- Get current user
POST /api/subscription/create-checkout-session- Start Pro subscriptionPOST /api/subscription/create-portal-session- Manage subscriptionGET /api/subscription/status- Get subscription statusPOST /api/subscription/cancel- Cancel subscription
POST /api/webhooks/stripe- Stripe webhook handler
GET /api/projects- List projectsPOST /api/projects- Create projectGET /api/projects/:id- Get project details
- JWT-based authentication
- Password hashing with bcrypt
- Stripe webhook signature verification
- PCI DSS compliance via Stripe
- Non-root Docker containers
- Environment variable secrets
# Run tests
pytest
# Run with coverage
pytest --cov=app tests/
# Run specific test
pytest tests/test_subscription.pyAll infrastructure is defined as code using Terraform:
cd terraform
terraform init
terraform applyThis creates:
- β DOKS Kubernetes cluster
- β PostgreSQL and Redis (on DOKS)
- β Application deployment with auto-scaling
- β Load balancer with SSL
- β DNS records
- β Spaces bucket
See KUBERNETES_DEPLOYMENT.md for complete guide.
π‘ Note: The
k8s/folder contains YAML files for reference only. All resources are managed by Terraform. See YAML_TO_TERRAFORM_MAPPING.md for details.
Ensure these are set in production:
FLASK_ENV=production- Strong
SECRET_KEYandJWT_SECRET - Production Stripe keys
- Database credentials
- AWS credentials for S3
# Build production image
docker build -t tfvisualizer:latest .
# Run container
docker run -d \
-p 80:80 \
--env-file .env \
tfvisualizer:latestcurl http://localhost/health- Up to 3 projects
- Basic AWS resources
- Import/Export .tf files
- Cost estimation
- Community support
- Unlimited projects
- All cloud providers
- Module support
- Real-time collaboration
- Version history
- Priority support
- Export to PNG/SVG
tfvisualizer/
βββ app/
β βββ __init__.py
β βββ main.py # Application entry point
β βββ config/
β β βββ settings.py # Configuration
β βββ routes/
β β βββ auth.py # Authentication routes
β β βββ pages.py # HTML page routes
β β βββ projects.py # Project management
β β βββ subscription.py # Stripe subscriptions
β β βββ terraform.py # Terraform operations
β β βββ webhooks.py # Stripe webhooks
β βββ models/
β β βββ user.py # User model
β β βββ subscription.py # Subscription model
β β βββ payment.py # Payment history
β β βββ project.py # Project model
β βββ services/
β β βββ stripe_service.py # Stripe integration
β βββ middleware/
β β βββ error_handler.py # Global error handling
β βββ utils/
β βββ logger.py # Logging utilities
βββ templates/
β βββ index.html # Landing page
β βββ editor.html # Visual Terraform editor
β βββ login.html # Login page
β βββ register.html # Registration page
βββ static/ # CSS, JS, images
βββ migrations/ # Database migrations
βββ tests/ # Test suite
βββ Dockerfile
βββ docker-compose.yml
βββ requirements.txt
βββ .env.example
βββ DESIGN.md
βββ README.md
- Create database model in
app/models/ - Create service in
app/services/ - Create routes in
app/routes/ - Add tests in
tests/ - Update DESIGN.md
MIT License - see LICENSE file
Contributions welcome! Please read CONTRIBUTING.md first.
- Email: support@tfvisualizer.com
- GitHub Issues: https://github.com/elliotechne/tfvisualizer/issues
- Documentation: https://docs.tfvisualizer.com
- Stripe for payment processing
- Terraform for infrastructure as code
- Flask community
- AWS pricing data
Built with β€οΈ for DevOps engineers