Skip to main content

A 'Zen Mode' infrastructure engine for Python developers.

Project description

🧘 Xenfra: Infrastructure in Zen Mode

Xenfra is a modular infrastructure engine for Python developers that automates the deployment of applications to DigitalOcean. It is designed as a library first, with a beautiful and interactive CLI as the default frontend.

It handles the complexity of server provisioning, context-aware configuration, Dockerization, and automatic HTTPS, allowing you to focus on your code.

✨ Core Philosophy

  • Engine as the Brain: xenfra.engine is the core library. It owns the DigitalOcean API, the SSH "Auto-Heal" retry loops, and the Dockerizer services. It is stateful, robust, and can be imported into any Python project.
  • Clients as the Face: Frontends like the default CLI (xenfra.cli) are thin, stateless clients responsible only for user interaction.
  • Zen Mode: If a server setup fails due to common issues like a locked package manager, the Engine automatically fixes it without exposing raw errors to the user.

🚀 Quickstart: As a Library

This demonstrates the power of Xenfra's engine for programmatic infrastructure management.

1. Installation

# Install from PyPI (once published)
pip install xenfra

2. Prerequisites

Ensure your DigitalOcean API token is available as an environment variable:

export DIGITAL_OCEAN_TOKEN="your_secret_token_here"

3. Programmatic Usage

from xenfra.engine import InfraEngine

# Optional: a logger to receive status updates
def my_logger(message):
    print(f"[My App] {message}")

try:
    # The engine automatically finds and validates the API token
    engine = InfraEngine()

    # Define the server and deploy
    result = engine.deploy_server(
        name="my-app-server",
        region="nyc3",
        size="s-1vcpu-1gb",
        image="ubuntu-24-04-x64",
        logger=my_logger
    )

    print(f"🎉 Deployment successful! IP Address: {result.get('ip')}")

except Exception as e:
    print(f"❌ Deployment failed: {e}")

💻 CLI Usage

Xenfra also provides a beautiful, interactive CLI for manual control.

1. Installation

pip install xenfra

2. Configuration

Create a .env file in your project root with your DigitalOcean token:

DIGITAL_OCEAN_TOKEN=dop_v1_your_token_here

3. Run the CLI

Once installed, simply run the xenfra command:

xenfra

This will launch the interactive menu where you can:

  • 🚀 Deploy New Server: A guided workflow to provision and deploy your application.
  • 📋 List Active Servers: View your current DigitalOcean droplets.
  • 🧨 Destroy a Server: Decommission servers you no longer need.

📦 Supported Frameworks & Features

  • Smart Context Detection: Automatically detects your package manager (uv or pip).
  • Automatic Dockerization: If a web framework is detected (FastAPI, Flask), Xenfra will:
    • Generate a Dockerfile, docker-compose.yml, and Caddyfile.
    • Deploy your application as a container.
    • Configure Caddy as a reverse proxy with automatic HTTPS.

🤝 Contributing

Contributions are welcome! Please check our CONTRIBUTING.md for more details.

📄 Created by DevHusnainAi

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

xenfra-0.1.3.tar.gz (11.2 kB view details)

Uploaded Source

Built Distribution

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

xenfra-0.1.3-py3-none-any.whl (13.9 kB view details)

Uploaded Python 3

File details

Details for the file xenfra-0.1.3.tar.gz.

File metadata

  • Download URL: xenfra-0.1.3.tar.gz
  • Upload date:
  • Size: 11.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for xenfra-0.1.3.tar.gz
Algorithm Hash digest
SHA256 95f9aa4641aaf14eb25dbd13aeb91073e46973cbecb10624f67fe63509085661
MD5 5e83b334892e96d52d645872c5e64994
BLAKE2b-256 7888a0f2f4a36e27589b62ac40029d3272403fbc22d0bdd9a1053f6c7d98c860

See more details on using hashes here.

File details

Details for the file xenfra-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: xenfra-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 13.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for xenfra-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 0042e157bd7aba189ed48b7ce651e596a3bf3e60c87770f3cc14164c7a324fa1
MD5 f8f5666efd277cff3a9a64a2cca68e71
BLAKE2b-256 84c46c3b61ff34cf03bd4b88e1db0d08cea62e0eea047bfa43e79464a4d94ef2

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