Skip to main content

Django + Bun deployment platform

Project description

djb - Django + Bun Platform

djb mascot

djb is a deployment platform for Django applications with modern frontend tooling (Bun). It provides utilities for secrets management, deployment, and development workflows.

Architecture

djb is organized as a Python package within the beachresort25 project:

djb/
├── __init__.py          # Package initialization
├── secrets/             # Encrypted secrets management
│   ├── __init__.py      # Public API exports
│   └── core.py          # Encryption/decryption implementation
└── cli/                 # Command-line interface
    ├── __init__.py
    ├── djb.py           # Main CLI entry point
    ├── init.py          # Environment initialization
    ├── secrets.py       # Secrets management
    └── deploy.py        # Heroku deployment

Features

Initialization

One-command setup for development environment:

# Full initialization
djb init

# Initialize with options
djb init --skip-brew          # Skip Homebrew dependencies
djb init --skip-frontend      # Skip frontend setup
djb init --skip-secrets       # Skip secrets initialization
djb init --project-root /path # Specify project directory

This installs:

  • System dependencies via Homebrew (age, PostgreSQL, GDAL, Bun)
  • Python dependencies (uv sync)
  • Frontend dependencies (bun install)
  • Encrypted secrets management

Secrets Management

Age-style encrypted secrets for secure configuration:

# Initialize secrets
djb secrets init

# Edit environment secrets
djb secrets edit dev
djb secrets edit production

# View secrets
djb secrets view dev
djb secrets list

Documentation: See docs/SECRETS_GUIDE.md

Deployment

Heroku deployment with frontend builds, secrets sync, and migrations:

# Deploy to Heroku (uses DJB_APP_NAME from Django settings)
djb deploy heroku

# Or specify app explicitly
djb deploy heroku --app myapp

# Deploy with options
djb deploy heroku --skip-build --skip-secrets

# Revert to previous deployment
djb deploy revert

# Revert to specific commit
djb deploy revert abc1234

App Name Auto-Detection: If DJB_APP_NAME is set in your Django settings, deployment commands will use it automatically. You can still override with --app.

# In settings.py
DJB_APP_NAME = "myapp"

Usage

Command Line

djb provides two CLI interfaces:

  1. Direct: djb <command>
  2. Via beachresort: br <command> (convenience wrapper)

Both are equivalent. The beachresort CLI delegates to djb internally.

Python API

Import djb modules directly in Python code:

from djb.secrets import load_secrets, AgeKey, SecretsManager

# Load secrets for current environment
secrets = load_secrets()
api_key = secrets['api_keys']['stripe']

# Encrypt/decrypt programmatically
key = AgeKey.generate()
manager = SecretsManager(secrets_dir=Path('secrets'), age_key=key)
manager.save_secrets('dev', data, [key.to_public_string()], encrypt=True)

Installation

djb is included in the beachresort25 project. After cloning:

# One-command setup (installs all dependencies)
djb init

# Or install manually
uv sync

# Verify djb is available
djb --help

Development

Adding New Commands

  1. Create a new subcommand module in djb/cli/
  2. Define your Click command group
  3. Register it in djb/cli/djb.py:
from djb.cli.mycommand import mycommand

djb_cli.add_command(mycommand)

Adding New Features

  1. Implement the feature in an appropriate module under djb/
  2. Export public API in djb/__init__.py if needed
  3. Add CLI commands if applicable
  4. Update documentation

Architecture Decisions

Why djb is in beachresort25

djb started as a separate project but has been integrated into beachresort25 to:

  1. Simplify dependency management
  2. Allow rapid iteration on both the platform and application
  3. Enable project-specific customization
  4. Avoid version conflicts between djb and application dependencies

The original external djb project will be deprecated in favor of this integrated approach.

Why Age Encryption

  • Modern cryptography: X25519 + ChaCha20-Poly1305
  • Simple key management: Single key file vs PGP keyring complexity
  • Git-safe: Encrypted values can be committed
  • Future-proof: Compatible with Kubernetes sealed secrets

Future Plans

Planned djb features:

  • Environment initialization - djb init
  • Deployment commands (Heroku) - djb deploy heroku, djb deploy revert
  • App name auto-detection from Django settings (DJB_APP_NAME)
  • Git hooks setup via djb init (pre-commit hook for editable djb check)
  • Deployment commands (Kubernetes)
  • Development server management
  • Database migration utilities
  • Multi-recipient secret encryption
  • Secret rotation automation
  • Environment variable syncing

References

License

djb is licensed under the MIT License.

Mascot Attribution

The djb mascot (dj_bun) was created for this project and is distributed under CC BY-SA 4.0.



/dj_bun: playin' dev and deploy since 1984 🎶

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

djb-0.2.19.tar.gz (45.7 kB view details)

Uploaded Source

Built Distribution

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

djb-0.2.19-py3-none-any.whl (54.3 kB view details)

Uploaded Python 3

File details

Details for the file djb-0.2.19.tar.gz.

File metadata

  • Download URL: djb-0.2.19.tar.gz
  • Upload date:
  • Size: 45.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for djb-0.2.19.tar.gz
Algorithm Hash digest
SHA256 1344a2d359bfdb00331c634d15fa5bd5bb68e62a3337f4f29652d28b1cfdb884
MD5 d8044cef632d3cb9be0d25cc50892a5b
BLAKE2b-256 ec793641e43f59ebbf0af8532af7759acc6a2654521e31b5a95ebc8d74169007

See more details on using hashes here.

Provenance

The following attestation bundles were made for djb-0.2.19.tar.gz:

Publisher: publish.yaml on kajicom/djb

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file djb-0.2.19-py3-none-any.whl.

File metadata

  • Download URL: djb-0.2.19-py3-none-any.whl
  • Upload date:
  • Size: 54.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for djb-0.2.19-py3-none-any.whl
Algorithm Hash digest
SHA256 e7d81d17e15bec4dd401ca9fcbd5eeeadb7afb26077d09cf267eea2b2062bea9
MD5 76648a6c46543eba3547c306c814f515
BLAKE2b-256 10dda60b4b9407fda9ba99c8b06a27ea546d5e01dfad3a48563c90f8e661c146

See more details on using hashes here.

Provenance

The following attestation bundles were made for djb-0.2.19-py3-none-any.whl:

Publisher: publish.yaml on kajicom/djb

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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