Metadata-Version: 2.4
Name: backendbrain
Version: 1.0.0
Summary: AI-Powered Backend Intelligence & Acceleration Platform for Django
Author-email: Aman Gupta <amangupta@example.com>
License: MIT License
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Framework :: Django
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: System :: Monitoring
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: django>=3.2
Requires-Dist: pydantic>=2.0.0
Requires-Dist: psutil>=5.9.0
Requires-Dist: rich>=13.0.0
Requires-Dist: typer>=0.9.0
Requires-Dist: jinja2>=3.0.0
Provides-Extra: dev
Requires-Dist: pytest>=7.0; extra == "dev"
Requires-Dist: pytest-cov>=4.0; extra == "dev"
Requires-Dist: flake8>=6.0; extra == "dev"
Requires-Dist: black>=23.0; extra == "dev"
Requires-Dist: isort>=5.0; extra == "dev"
Dynamic: license-file

# BackendBrain 🧠

**BackendBrain** is an AI-Powered Backend Intelligence & Acceleration Platform built explicitly for Django.

It is NOT just another monitoring tool. BackendBrain is an intelligent backend engineer that sits inside your application to observe, learn, optimize, and accelerate your database performance.

## Core Features
- **Zero-Block Telemetry**: Event Bus architecture ensures telemetry has <3ms overhead.
- **SQL Analyzer**: Detects N+1 queries, missing indexes, and slow lookups.
- **AI Recommendations**: Explains *why* the DB is slow and exactly how to fix it in Django ORM.
- **Accelerator**: Smart Response Caching and Request Deduplication to handle traffic spikes.
- **Rich HTML Reports**: Generates actionable insight reports from the CLI.

## Installation
```bash
pip install backendbrain
```

## Django Setup
In your `settings.py`:

```python
# 1. Add to INSTALLED_APPS
INSTALLED_APPS += ['backendbrain.middleware.django']

# 2. Add to MIDDLEWARE (Place high up, after SecurityMiddleware)
MIDDLEWARE.insert(2, 'backendbrain.middleware.django.BackendBrainMiddleware')

# 3. Configure BackendBrain
BACKENDBRAIN = {
    "enabled": True,
    "cache_learning": True,
    "deduplication": True,
    "response_cache": True,
}
```

## CLI Usage

Generate an HTML report of your recent telemetry:
```bash
backendbrain analyze
backendbrain report --format html
```

## Architecture
BackendBrain operates on a decoupled Event Bus. The Django Middleware emits events asynchronously. A background daemon (Queue) batches and writes these metrics to a local SQLite database (`backendbrain.db`). The CLI tools then parse this database to generate AI recommendations.

## FAQ
**Q: Will this slow down my API?**
A: No. BackendBrain is designed to be invisible. Our benchmark tests prove it adds less than 3ms of overhead to a request.

**Q: Does it support PostgreSQL?**
A: Yes! BackendBrain instruments the generic Django ORM wrapper, so it supports SQLite, PostgreSQL, MySQL, and MariaDB natively without any code changes.
