Metadata-Version: 2.4
Name: b4n1-boost
Version: 0.1.8
Classifier: License :: Other/Proprietary License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Rust
Classifier: Operating System :: OS Independent
Classifier: Topic :: Software Development :: Libraries :: Python Modules
License-File: LICENSE
Summary: B4N1-BOOST — Transparent middleware accelerator for Django, FastAPI and Flask
Home-Page: https://b4n1.com
Author-email: Bani Montoya <b4n1@b4n1.com>
License: BSL-1.1
Requires-Python: >=3.10
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
Project-URL: Homepage, https://b4n1.com
Project-URL: PyPI, https://pypi.org/project/b4n1-boost
Project-URL: Repository, https://github.com/B4N1-com/b4n1-boost

<div align="center">

# 📦 b4n1-boost

**Transparent native middleware acceleration layer for Python frameworks (Django, FastAPI, Flask, WSGI/ASGI).**

[![License](https://img.shields.io/badge/license-BSL%201.1-lightgrey)](LICENSE)
[![PyPI](https://badge.fury.io/py/b4n1-boost.svg)](https://pypi.org/project/b4n1-boost/)

</div>

# 🌍 Languages / Idiomas / 语言

|  |  |  |  |
|--|--|--|--|
| 🇬🇧 [English](README.md) | 🇪🇸 [Español](README.es.md) | 🇫🇷 [Français](README.fr.md) | 🇩🇪 [Deutsch](README.de.md) |
| 🇵🇹 [Português](README.pt-BR.md) | 🇨🇳 [简体中文](README.zh-CN.md) | 🇯🇵 [日本語](README.ja.md) | |

---

## 🚀 Features

- Transparent middleware for Django, FastAPI, Flask, WSGI and ASGI.
- Native gzip and Brotli response compression.
- Automatic `Accept-Encoding` negotiation.
- Correct `Content-Encoding`, `Content-Length` and `Vary` headers.
- Safe Python fallback when the native extension is unavailable.
- JSON utilities and runtime diagnostics.

## Components and licenses

| Component | License |
|---|---|
| b4n1-boost | Business Source License 1.1 (BSL 1.1) |
| Rust standard library | MIT / Apache-2.0 |
| PyO3 | Apache-2.0 |
| serde / serde_json | MIT / Apache-2.0 |
| serde_yaml | MIT / Apache-2.0 |
| clap | MIT / Apache-2.0 |
| thiserror | MIT / Apache-2.0 |
| chrono | MIT / Apache-2.0 |
| flate2 / miniz_oxide | MIT / Apache-2.0 |
| brotli | MIT |

See `LICENSE` for the b4n1-boost license terms and the project notices for
third-party license details.

---

## 📦 Installation

```bash
pip install b4n1-boost
```

Precompiled native wheels are provided for supported platforms; no local compiler is required when a compatible wheel is available.

---

## 🚀 Quick Start

No code rewrites. Initialize the SDK when your app starts:

### Django
In your `settings.py` or `wsgi.py`:

```python
import b4n1_boost

b4n1_boost.install_django()
```

### FastAPI
In your main module:

```python
from fastapi import FastAPI
import b4n1_boost

app = FastAPI()
b4n1_boost.install_fastapi(app)
```

### Flask
In your app initialization:

```python
from flask import Flask
import b4n1_boost

app = Flask(__name__)
b4n1_boost.install_flask(app)
```

### Auto-detection
Let b4n1-boost detect the active framework automatically:

```python
import b4n1_boost

b4n1_boost.autoboost()
```

### Native compression (brotli/gzip, GIL-free)
Wrap any WSGI app (Flask, Django via WSGI, or plain WSGI) to compress large
responses in Rust when the client accepts an encoding:

```python
from b4n1_boost.middleware import B4N1BoostCompressionMiddleware

app.wsgi_app = B4N1BoostCompressionMiddleware(app.wsgi_app)
```

For FastAPI/Starlette use the ASGI variant:

```python
from b4n1_boost.middleware import FastAPIBoostCompressionMiddleware

app.add_middleware(FastAPIBoostCompressionMiddleware)
```

Both negotiate `Accept-Encoding` (brotli preferred, then gzip), only compress
bodies above 1 KB, set `Content-Encoding`, `Content-Length` and `Vary`
correctly, and fall back to the untouched body when the native engine is
unavailable or compression fails.

---

## 🔍 Status & Diagnostics

Check the engine state and active accelerations:

```python
import b4n1_boost

print(b4n1_boost.status())
```

Expected output:

```json
{
  "native_extension": true,
  "version": "0.1.8",
  "features": ["json_acceleration", "orm_interception", "websocket_acceleration"]
}
```

Run the native benchmark suite:

```python
report = b4n1_boost.run_benchmarks(iterations=100_000)
print(f"JSON ops/sec: {report['json_bench']['ops_per_sec']:,.0f}")
print(f"ORM ops/sec:  {report['orm_bench']['ops_per_sec']:,.0f}")
```

---

## 🔗 Links

- Website: https://b4n1.com
- PyPI: https://pypi.org/project/b4n1-boost
- Licensing: https://b4n1.com/licensing or `b4n1@b4n1.com`

---

## 📄 License

This project is distributed under the **Business Source License 1.1 (BSL 1.1)**.

- **Free** for development, evaluation, testing, personal projects, and startups generating under **$100,000 USD** in annual gross revenue.
- **Commercial license** required for organizations with annual gross revenue **>= $100,000 USD**, government agencies, and public bidding projects.
- After the **Change Date** (4 years), the work converts to **Apache License 2.0**.

See [LICENSE](LICENSE) for the full legal text.

---

_b4n1-boost is a core component of the B4N1 sovereign computing stack, providing transparent native middleware acceleration for Python frameworks._

_Built with ❤️ by the B4N1 team._
