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.3.tar.gz (188.3 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.3-py3-none-any.whl (199.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: snapinfra-1.1.3.tar.gz
  • Upload date:
  • Size: 188.3 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.3.tar.gz
Algorithm Hash digest
SHA256 35088f229196afe3c7fbedf8d1902c93a94e422402d02ea0a0be3e9c849b36aa
MD5 5ee767bd1eeb0d01143962cd98a8d1fc
BLAKE2b-256 55265fdc9c8a2d7ffeb08fc8408a1f5afe07153ecd2a5c325935bdcb1db72b5e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: snapinfra-1.1.3-py3-none-any.whl
  • Upload date:
  • Size: 199.5 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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 57fc3df6befa727c56e77ba80446a62c780c15d9271fd36ebe4a790bdbca38b9
MD5 065314bb7a6ac642604e70a15eaf9758
BLAKE2b-256 8f7c45a81e6dcbde95c61067b9d3d15c50f0d635f489cf1fb792126ac2cd6e13

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