Metadata-Version: 2.4
Name: litestar-flags
Version: 0.2.1
Summary: Production-ready feature flags library for Litestar
Keywords: litestar,feature-flags,feature-toggles,a/b-testing,rollouts
Author: Jacob Coffee
Author-email: Jacob Coffee <jacob@z7x.org>
License-Expression: MIT
Classifier: Development Status :: 3 - Alpha
Classifier: Environment :: Web Environment
Classifier: Framework :: AsyncIO
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Natural Language :: English
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Internet :: WWW/HTTP
Classifier: Topic :: Software Development :: Libraries
Classifier: Typing :: Typed
Requires-Dist: litestar>=2.0.0
Requires-Dist: litestar-flags[database,redis,observability,workflows,openfeature,prometheus] ; extra == 'all'
Requires-Dist: advanced-alchemy>=0.10.0 ; extra == 'database'
Requires-Dist: sqlalchemy[asyncio]>=2.0.0 ; extra == 'database'
Requires-Dist: structlog>=24.1.0 ; extra == 'logging'
Requires-Dist: litestar-flags[otel,logging] ; extra == 'observability'
Requires-Dist: openfeature-sdk>=0.8.0 ; extra == 'openfeature'
Requires-Dist: opentelemetry-api>=1.20.0 ; extra == 'otel'
Requires-Dist: prometheus-client>=0.17.0 ; extra == 'prometheus'
Requires-Dist: redis>=5.0.0 ; extra == 'redis'
Requires-Dist: litestar-workflows>=0.1.0 ; extra == 'workflows'
Requires-Python: >=3.11
Project-URL: Documentation, https://github.com/JacobCoffee/litestar-flags#readme
Project-URL: Homepage, https://github.com/JacobCoffee/litestar-flags
Project-URL: Issues, https://github.com/JacobCoffee/litestar-flags/issues
Project-URL: Repository, https://github.com/JacobCoffee/litestar-flags
Provides-Extra: all
Provides-Extra: database
Provides-Extra: logging
Provides-Extra: observability
Provides-Extra: openfeature
Provides-Extra: otel
Provides-Extra: prometheus
Provides-Extra: redis
Provides-Extra: workflows
Description-Content-Type: text/markdown

# litestar-flags

Production-ready feature flags for [Litestar](https://litestar.dev) applications.

[![PyPI version](https://badge.fury.io/py/litestar-flags.svg)](https://badge.fury.io/py/litestar-flags)
[![Python versions](https://img.shields.io/pypi/pyversions/litestar-flags.svg)](https://pypi.org/project/litestar-flags/)
[![License](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)

## Installation

```bash
uv add litestar-flags

# With extras
uv add litestar-flags[redis]        # Redis backend
uv add litestar-flags[database]     # SQLAlchemy backend
uv add litestar-flags[workflows]    # Approval workflows
uv add litestar-flags[openfeature]  # OpenFeature SDK provider
uv add litestar-flags[prometheus]   # Prometheus metrics
uv add litestar-flags[observability] # OpenTelemetry + structlog
uv add litestar-flags[all]          # Everything
```

## Quick Start

```python
from litestar import Litestar, get
from litestar_flags import FeatureFlagsPlugin, FeatureFlagsConfig, FeatureFlagClient

config = FeatureFlagsConfig()
plugin = FeatureFlagsPlugin(config=config)

@get("/")
async def index(feature_flags: FeatureFlagClient) -> dict:
    if await feature_flags.is_enabled("new_checkout"):
        return {"flow": "new"}
    return {"flow": "legacy"}

app = Litestar(plugins=[plugin])
```

## Features

- **Multiple backends** - Memory, Redis, and SQLAlchemy storage
- **Percentage rollouts** - Gradual releases with consistent hashing
- **User targeting** - Rules based on user attributes
- **Segment-based targeting** - Reusable user groups for complex targeting
- **A/B testing** - Weighted variants for experiments
- **Time-based rules** - Scheduled launches and maintenance windows
- **Multi-environment** - Environment inheritance, promotion, and per-env configs
- **Admin API** - REST endpoints for flag management with RBAC and audit logging
- **Analytics** - Evaluation tracking, metrics, and Prometheus export
- **OpenFeature support** - Vendor-agnostic evaluation via OpenFeature SDK
- **Approval workflows** - Human-in-the-loop governance for enterprise use

## Documentation

Full docs at [flags.litestar.scriptr.dev](https://flags.litestar.scriptr.dev).

## Development

```bash
git clone https://github.com/JacobCoffee/litestar-flags.git
cd litestar-flags
uv sync --all-extras
uv run pytest
```

## License

MIT
