Skip to main content

AI-powered CLI that generates infrastructure code and architecture diagrams from natural language. Features interactive progress tracking, syntax-highlighted previews, and automated architecture-first workflow. Supports Terraform, Kubernetes, Docker with multi-provider AI backends.

Project description

SnapInfra

PyPI version Downloads Python 3.8+ License: Apache 2.0

AI-powered infrastructure code generation from natural language

Transform plain English into production-ready infrastructure code and architecture diagrams. SnapInfra generates Terraform, Kubernetes, Docker configurations with beautiful visualizations using state-of-the-art AI models.

pip install snapinfra
snapinfra

What's New in v1.1.0

  • Architecture-First Workflow: Automatically generates architecture diagrams before infrastructure code
  • Enhanced Progress Tracking: Real-time progress bars with ETA and time elapsed
  • Syntax-Highlighted Previews: Beautiful code previews directly in terminal
  • Interactive File Trees: Visual tree view of all generated files
  • Streamlined UX: Cleaner messaging, better prompts, no clutter
  • Smart Detection: Automatically detects infrastructure type and formats output

Key Features

  • Architecture-First Generation: Diagrams generated first, then infrastructure code
  • Multi-Format Diagrams: Python (diagrams library), Mermaid, D2 - all in one command
  • Interactive Terminal: Progress bars, syntax highlighting, file previews
  • Multi-Provider AI: OpenAI, Groq, AWS Bedrock, Ollama support
  • Production-Ready: Security best practices and scalability built-in
  • Browser Viewer: Optional localhost diagram viewer with zoom and export
  • Cross-Platform: Works on Windows, macOS, and Linux

Quick Start

Install

pip install snapinfra

Set API Key

# Free Groq API (recommended)
export GROQ_API_KEY="your-api-key"

# Or OpenAI
export OPENAI_API_KEY="your-api-key"

Generate Infrastructure

# AWS Infrastructure
snapinfra "terraform for AWS VPC with public/private subnets"

# Kubernetes
snapinfra "k8s deployment for nginx with ingress"

# Docker
snapinfra "docker-compose for React app with PostgreSQL"

# With specific AI provider
snapinfra -b groq "serverless architecture with API Gateway and Lambda"

Supported Infrastructure

Platform Templates Features
Terraform AWS, Azure, GCP Multi-cloud, modules, best practices
Kubernetes Deployments, Services, Ingress RBAC, security policies, monitoring
Docker Dockerfiles, Compose Multi-stage, optimization, security
CloudFormation Serverless, Containers AWS native, nested stacks
Ansible Configuration, Deployment Automation, orchestration
Helm Charts, Values Kubernetes package management

AI Providers

Provider Speed Cost Best For
Groq Ultra-fast Free tier Development, prototyping
OpenAI Fast Pay-per-use Production, complex scenarios
AWS Bedrock Fast Enterprise AWS environments
Ollama Variable Free Privacy, offline usage

Setup Examples

Groq (Recommended)

export GROQ_API_KEY="gsk_..."
snapinfra -b groq "terraform for EKS cluster"

OpenAI

export OPENAI_API_KEY="sk-..."
snapinfra -b openai -m gpt-4 "complex microservices architecture"

Local with Ollama

# No API key needed
snapinfra -b ollama "docker setup for development"

Enhanced User Experience

SnapInfra v1.1.0 features a dramatically improved terminal interface:

snapinfra > create AWS VPC with Terraform

Generating TERRAFORM Infrastructure

Step 1/2: Creating Architecture Diagrams
Generating Python, Mermaid, and D2 formats

⠋ Analyzing infrastructure and creating diagrams... ████████████░░░░  75%  0:00:12  0:00:04

✓ terraform_architecture.py
✓ terraform_architecture.mmd
✓ terraform_architecture.d2

[SUCCESS] Diagrams created successfully (3 files)

Step 2/2: Creating Infrastructure Code
Writing terraform configuration

⠋ Writing infrastructure configuration... ████████████████████  100%  0:00:08  0:00:00

✓ terraform_infrastructure.tf
156 lines

[SUCCESS] All files generated successfully!

TERRAFORM Infrastructure
├── Architecture Diagrams
│   ├── terraform_architecture.py (1.2 KB)   ├── terraform_architecture.mmd (856 bytes)   └── terraform_architecture.d2 (723 bytes)
└── Infrastructure Code
    └── terraform_infrastructure.tf (4.5 KB)

Show code preview in terminal? [Y/n]
Open architecture viewer in browser? [y/N]

Features:

  • Real-time progress bars with ETA
  • Clean, professional output
  • Interactive file tree visualization
  • Syntax-highlighted code previews
  • Architecture-first generation workflow

Common Use Cases

Cloud Infrastructure

# Complete AWS setup
snapinfra "3-tier architecture: ALB, ECS, RDS with monitoring"

# Multi-cloud
snapinfra "hybrid setup: AWS primary, Azure DR"

# Serverless
snapinfra "event-driven architecture with Lambda and SQS"

Container Orchestration

# Microservices
snapinfra "k8s platform: ingress, services, deployments, monitoring"

# Development environment
snapinfra "docker-compose: app, database, redis, monitoring"

# Production setup
snapinfra "helm chart for multi-tier application"

Development Workflows

# CI/CD
snapinfra "GitHub Actions: test, build, deploy to EKS"

# Infrastructure as Code
snapinfra "Terraform modules for reusable VPC patterns"

# Security
snapinfra "k8s network policies and RBAC for microservices"

Advanced Features

Interactive Chat Mode

snapinfra "basic AWS setup"
# SnapInfra generates initial code
# Continue refining: "add monitoring", "make it multi-region", "add security groups"

Architecture as Code

# Generate diagrams in multiple formats
snapinfra diagram generate "3-tier AWS architecture" --view

# View diagrams interactively
snapinfra diagram view architecture.mmd

# Get example diagrams
snapinfra diagram example

See QUICKSTART_DIAGRAMS.md for the complete diagram guide.

Multiple Output Formats

# Save to files
snapinfra -o main.tf "terraform VPC setup"

Batch Processing

# Multiple environments
snapinfra "terraform modules for dev, staging, prod"

# Different cloud providers
snapinfra "same app architecture for AWS, Azure, GCP"

Configuration

Environment Variables (Simple)

# Choose your AI provider
export GROQ_API_KEY="gsk_..."
export OPENAI_API_KEY="sk_..."

TOML Config (Advanced)

# ~/.config/snapinfra/config.toml
default_backend = "groq"

[backends.groq]
type = "groq"
api_key = "$GROQ_API_KEY"
default_model = "llama-4-scout-17b"

[backends.openai]
type = "openai"
api_key = "$OPENAI_API_KEY"
default_model = "gpt-4"

[backends.bedrock]
type = "bedrock"
aws_profile = "default"
aws_region = "us-east-1"

CLI Reference

Basic Usage

snapinfra [OPTIONS] "your infrastructure description"

Common Options

-b, --backend TEXT     AI provider (groq, openai, bedrock, ollama)
-m, --model TEXT       Specific model to use
-o, --output FILE               Save code to file
-q, --quiet                      Non-interactive mode
--list-models                    Show available models
--validate / --no-validate       Run validation after generation (default from config)
--save-validation-report         Save validation report to the project directory
--report-format [markdown|json|text]  Format for saved validation report

Examples

snapinfra -b groq "k8s setup"
snapinfra -o main.tf "terraform VPC"
snapinfra --clipboard "docker compose"

Why Choose SnapInfra?

For Developers

  • Generate infrastructure faster than manual coding
  • Learn best practices through AI-generated examples
  • Consistent, documented infrastructure code
  • Works with your existing tools and workflows

For Teams

  • Standardize infrastructure patterns across projects
  • Reduce knowledge silos with documented code
  • Faster onboarding with readable, explained infrastructure
  • Multi-environment consistency (dev/staging/prod)

For Enterprises

  • Security best practices built into every template
  • Compliance-ready configurations
  • Cost-optimized resource specifications
  • Integration with existing CI/CD pipelines

Enterprise Support

Professional Services

  • Custom AI model integration
  • Enterprise template development
  • Team training and onboarding
  • Architecture review and optimization

Support Channels

  • GitHub Issues: Bug reports and feature requests
  • Enterprise Support: Priority support and SLA
  • Community: Discussions and examples

Compliance & Security

  • SOC 2 compliant infrastructure templates
  • CIS benchmarks integration
  • Security scanning and validation
  • Audit logging and compliance reporting

Development

From Source

git clone https://github.com/manojmaheshwarjg/snapinfra-cli.git
cd snapinfra-cli
pip install -e ".[dev]"

Testing

pytest
pytest --cov=snapinfra

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Add tests for new functionality
  4. Ensure all tests pass
  5. Submit a pull request

Project Structure

src/snapinfra/
├── cli/          # Command-line interface
├── backends/     # AI provider implementations  
├── config/       # Configuration management
├── diagram/      # Architecture diagram generators and viewers
├── types/        # Data models and types
└── utils/        # Utility functions

License

Apache License 2.0

SnapInfra is open-source software licensed under the Apache License 2.0. This means:

  • Commercial use allowed
  • Modification and distribution permitted
  • Patent protection provided
  • Private use permitted
  • Must include license and copyright notice
  • Must state changes made to the code

Built by developers, for developers

GitHubPyPIIssuesDiscussions

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

snapinfra-1.1.1.tar.gz (189.7 kB view details)

Uploaded Source

Built Distribution

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

snapinfra-1.1.1-py3-none-any.whl (201.0 kB view details)

Uploaded Python 3

File details

Details for the file snapinfra-1.1.1.tar.gz.

File metadata

  • Download URL: snapinfra-1.1.1.tar.gz
  • Upload date:
  • Size: 189.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.5

File hashes

Hashes for snapinfra-1.1.1.tar.gz
Algorithm Hash digest
SHA256 5d607625630a4e986a100f4d0a53c15ccbd17f38e1fe722d967f7ec47db4c764
MD5 9fb4bea3b1f09591ae59627d695b8c32
BLAKE2b-256 d22276cc34e060fcdf5534db6925d6c82150f5843477668e582c126172f3c145

See more details on using hashes here.

File details

Details for the file snapinfra-1.1.1-py3-none-any.whl.

File metadata

  • Download URL: snapinfra-1.1.1-py3-none-any.whl
  • Upload date:
  • Size: 201.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.5

File hashes

Hashes for snapinfra-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6a11abe18ac03bb9715e6fb881fc731abec48327ab69dd82e665029af20c6209
MD5 3be2ef77c45863d3d03812c84a2a113f
BLAKE2b-256 315484aeafe2b6be065e7f215ac3a20339bea854c66f099de34aaf9dc226c2d1

See more details on using hashes here.

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