Skip to content
artipricePublic

About

**BZML (GenDAM)** is an enterprise-grade, high-assurance Generative Digital Asset Management (DAM) engine designed for sub-millisecond metadata search, continuous generative AI inference batching, and immutable provenance tracking backed by **Backblaze B2 Cloud Storage**.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

BZML Logo

⚑ BZML β€” High-Performance Generative Digital Asset Management Engine

License Rust Safety Tauri Storage Providers

BZML (GenDAM) is an enterprise-grade, high-assurance Generative Digital Asset Management (DAM) engine designed for sub-millisecond metadata search, continuous generative AI inference batching, and immutable provenance tracking backed by Backblaze B2 Cloud Storage.

Engineered in High-Assurance Rust (#![deny(unsafe_code)]) on top of Axum and Tokio, BZML provides B2B media archives with deterministic performance, multi-tier caching (RAM + LSM-Tree Disk), and automated sidecar lineage audit trails. It seamlessly bridges Local AI (Candle/HuggingFace) and Cloud AI (Genblaze SDK) orchestration.


Disclaimer: BZML is an independent, third-party project. It is not a Backblaze product, and it is not affiliated with, endorsed by, or sponsored by Backblaze, Inc. It simply uses the Backblaze B2 object storage service (via its S3-compatible API) as a storage backend, the same way it could point at any other S3-compatible provider.


πŸ› System Architecture

                                  +-------------------------------------------------------+
                                  |       Client (Web Browser / Tauri Desktop App)        |
                                  +---------------------------+---------------------------+
                                                              |
                                                    HTTP / REST API (Axum)
                                                              |
                                                              v
                                  +-------------------------------------------------------+
                                  |               BZML Core Engine (Rust)                 |
                                  |                                                       |
                                  |   +-------------------+       +-------------------+   |
                                  |   | L1 Cache (RAM)    | <---> | L2 Cache (fjall)  |   |
                                  |   | quick_cache       |       | LSM-Tree Disk DB  |   |
                                  |   +---------+---------+       +-------------------+   |
                                  |             |                           |             |
                                  |             v                           v             |
                                  |   +-----------------------------------------------+   |
                                  |   | Continuous Request Aggregator (Batcher Actor) |   |
                                  |   +-----------------------+-----------------------+   |
                                  |             |                             |           |
                                  |             v                             v           |
                                  |  [ Native Local AI ]           [ Python Worker ]      |
                                  |  (Candle + Tokenizers)         (Genblaze Cloud SDK)   |
                                  +-------------|-----------------------------|-----------+
                                                +--------------+--------------+
                                                               |
                                                    Upload Assets & Sidecars
                                                               |
                                                               v
                                  +-------------------------------------------------------+
                                  |         Backblaze B2 Cloud Storage (S3 API)           |
                                  |                                                       |
                                  |  [ raw_asset.png ]  +  [ raw_asset.png.lineage.json ] |
                                  +-------------------------------------------------------+

✨ Key Features

1. πŸš€ Sub-Millisecond Multi-Tier Cache Engine

  • L1 Memory Cache: Built on quick_cache (S3-FIFO / Clock-PRO eviction policy), serving hot metadata lookups in < 800Β΅s.
  • L2 Persistent Storage: Powered by the fjall LSM-Tree database, providing crash-resilient disk persistence across system restarts with automated non-blocking L1 cache warming.

2. πŸ›‘ High Assurance & Zero Panic Invariants

  • Enforces strict lint levels across all Rust submodules.
  • Eliminates runtime panics (unwrap / expect-free in core domain logic), fully propagating fallible domain operations via strongly typed Result types.
  • Fully audited for thread safety, memory leak protection, and atomic disk writes.

3. πŸ”‘ Cloud AI API Keys & Multi-Provider Registry

  • Unified 8-Provider Cloud AI Management: Built-in dynamic configuration modal (/api/v1/settings) with live status badges (βœ“ Configured / Not Set) and masked key previews.
  • Supported Cloud AI Providers:
    1. OpenAI: DALL-E 3, Sora 2, GPT-4o
    2. Google Gemini: Veo, Imagen 3
    3. ElevenLabs: Text-to-Speech & Sound Effects
    4. Replicate: FLUX.1, SDXL
    5. RunwayML: Gen-3 Alpha
    6. Luma AI: Dream Machine
    7. Stability AI: Stable Diffusion & Stable Audio
    8. GMI Cloud: Kling Video, Image & Audio
  • Hot-Swappable Runtime Keys: Update API keys live from the Web UI without restarting the server.

4. 🧠 Hybrid AI Orchestration (Local & Cloud)

  • Native Local AI (Zero Python): Executes 1-step CPU Text-to-Image models directly in Rust RAM using candle and HuggingFace tokenizers.
  • Atomic Hugging Face Downloader: Built-in asynchronous model downloader with concurrency semaphores, atomic .tmp file renames, and clamped progress tracking [0.0, 99.9].
  • Process-Isolated Python Worker: Escalates to isolated Python workers running the genblaze SDK with stdout clean JSON separation and automatic local CPU fallback.

5. ⚑ Dynamic Inference Batching

  • Implements a background Tokio actor with sliding time windows (50ms) and dynamic batch capacity limits (16 items).
  • Features bounded MPSC channels for backpressure management, preventing memory exhaustion under traffic spikes.

6. πŸ”— Immutable Provenance & Backblaze B2 Integration

  • Native S3 integration via aws-sdk-s3 supporting custom endpoints, bucket listing pagination, multi-bucket switching, and secure presigned URLs.
  • Interactive Lineage Inspector: Every generative AI transformation automatically records and uploads a .lineage.json sidecar object containing SHA-256 digests, latency metrics, and parent-child asset relations rendered on an HTML5 Canvas graph.

7. 🎨 Desktop-Class UI & Compact View Optimizations

  • Available as a standalone Web App (HTMX + Tailwind) or a native Tauri Desktop Application (src-tauri).
  • Enhanced Compact (List) View: Layered z-index stacking (z-index: 10..30) and pointer-events: auto for seamless multi-select, thumbnail viewing, metadata inspection, and transformation dropdowns.

πŸ›  Tech Stack

  • Core Runtime: Rust 2021, Tokio, Axum, Tower-HTTP
  • Storage & Caching: aws-sdk-s3, quick_cache, fjall
  • AI / ML: candle-core (Local), tokenizers, Python 3.11+ genblaze SDK (Cloud)
  • Presentation: HTMX, Tailwind CSS, Tauri v2 (Desktop)
  • Infrastructure: Docker (Multi-stage), Docker Compose, Terraform, GitHub Actions

πŸ”‘ Environment Configuration

Create a .env file in the project root or export the required variables. Note: Bucket credentials and Cloud AI API keys can also be added dynamically via the Web UI.

# Backblaze B2 Storage Configuration (Optional at boot)
B2_KEY_ID="your_b2_key_id_here"
B2_APPLICATION_KEY="your_b2_application_key_here"
B2_BUCKET_NAME="bzml-media-bucket"
B2_ENDPOINT_URL="s3.eu-central-003.backblazeb2.com"
B2_REGION="eu-central-003"

# Cloud AI Provider API Keys (Optional - can be configured live via UI)
OPENAI_API_KEY="sk-proj-..."
GEMINI_API_KEY="AIzaSy..."
ELEVENLABS_API_KEY="sk_..."
REPLICATE_API_TOKEN="r8_..."
RUNWAYML_API_SECRET="key_..."
LUMAAI_API_KEY="luma-..."
STABILITY_API_KEY="sk-..."
GMI_API_KEY="gmi_..."

# Axum Web Server Configuration
SERVER_HOST="0.0.0.0"
SERVER_PORT=3000
SERVER_TIMEOUT_MS=10000

# Cache Subsystem Configuration
CACHE_L1_RAM_CAPACITY=10000
CACHE_L2_DISK_PATH="./data/fjall_db"
CACHE_BATCH_WINDOW_MS=50
CACHE_MAX_BATCH_SIZE=16

# Python Worker Configuration
WORKER_PYTHON_BINARY="python3"
WORKER_SCRIPT_PATH="./adapters/python/genblaze_worker.py"
WORKER_TIMEOUT_SECS=30

# Logging Filter
RUST_LOG="info,bzml=debug"

πŸš€ Quick Start & Deployment

Option A: Tauri Desktop App (Recommended for Local AI)

Run BZML natively on Windows, macOS, or Linux with a dedicated Webview window and secured process isolation.

# Install Tauri CLI prerequisites if needed
cargo install tauri-cli

# Build and run the desktop application
cargo tauri dev

Option B: Docker Compose

Spins up the BZML Rust engine and a pre-configured Alpine Python environment in seconds (~60MB footprint):

# 1. Clone repository & configure env
git clone https://github.com/artiprice/bzml.git && cd bzml
cp .env.example .env

# 2. Build and launch container stack
docker compose up --build -d

# 3. Access web interface
curl -i http://localhost:3000/health

Option C: Native Cargo Execution

# Build high-performance release binary
cargo build --release

# Start the application server
./target/release/bzml

Access the web interface at http://localhost:3000.

Option D: Infrastructure Provisioning via Terraform

Automatically provision Private Backblaze B2 buckets and scoped application keys using Infrastructure-as-Code:

cd terraform
terraform init
terraform apply

🌐 API Reference

Endpoint Method Description
/ GET Serves the main Single Page Application HTML shell.
/api/v1/search POST Executes sub-millisecond metadata search, returning HTMX grid partials.
/api/v1/transform POST Submits AI transformation requests to the dynamic batcher actor.
/api/v1/upload POST Accepts multipart/form-data uploads directly into B2 and the local cache.
/api/v1/sync POST Scans target B2 bucket via ListObjectsV2 and imports missing assets.
/api/v1/assets/open/{*key} GET Proxies asset bytes from B2 for inline viewing or download (?download=1).
/api/v1/lineage/{*key} GET Fetches the .lineage.json sidecar and renders the Canvas provenance graph.
/api/v1/settings GET / POST Fetches or updates Cloud AI API keys for all 8 providers live.
/api/v1/models GET Renders the Model & API Registry management modal.
/api/v1/models/add POST Registers a new Hugging Face Repo or Custom API endpoint.
/api/v1/models/download/{id} POST Triggers background async download of .safetensors/.gguf files.
/api/v1/connection POST Dynamically swaps the active B2 bucket connection at runtime.
/health GET Returns JSON status telemetry, engine status, and cache capacities.

πŸ§ͺ Formatting, Verification & Testing

Verify system integrity using Cargo:

# Check safety rules and workspace types
cargo check --workspace

# Enforce strict Clippy lint checks
cargo clippy --all-targets --all-features -- -D warnings

# Execute domain unit tests & integration checks
cargo test --workspace

πŸ“„ License

This project is licensed under the Apache License, Version 2.0. See the LICENSE-APACHE file for details.


🀝 Acknowledgments

Special thanks to Backblaze, Inc. for hosting the Backblaze Generative AI Media Hackathon and providing the cloud storage infrastructure.

About

**BZML (GenDAM)** is an enterprise-grade, high-assurance Generative Digital Asset Management (DAM) engine designed for sub-millisecond metadata search, continuous generative AI inference batching, and immutable provenance tracking backed by **Backblaze B2 Cloud Storage**.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages