Metadata-Version: 2.4
Name: fluxcrud
Version: 0.1.1
Summary: FluxCRUD is a easy to use, fast, and modern CRUD framework for FastAPI.
Project-URL: Homepage, https://fluxcrud.mahimai.dev
Project-URL: Repository, https://github.com/mahimailabs/fluxcrud
Author-email: Mahimai Raja J <hello@mahimai.dev>
License-Expression: MIT
License-File: LICENSE
Keywords: async,crud,fastapi,fluxcrud,pydantic,sqlalchemy
Classifier: Development Status :: 4 - Beta
Classifier: Framework :: AsyncIO
Classifier: Framework :: FastAPI
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Database
Classifier: Topic :: Software Development :: Libraries
Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
Classifier: Typing :: Typed
Requires-Python: <4,>=3.10
Requires-Dist: aiosqlite>=0.22.0
Requires-Dist: fastapi>=0.124.0
Requires-Dist: pydantic>=2.12.5
Requires-Dist: sqlalchemy[asyncio]>=2.0.44
Provides-Extra: all-cache
Requires-Dist: aiomcache>=0.8.2; extra == 'all-cache'
Requires-Dist: redis[hiredis]>=7.1.0; extra == 'all-cache'
Provides-Extra: all-drivers
Requires-Dist: aiomysql>=0.3.2; extra == 'all-drivers'
Requires-Dist: asyncpg>=0.31.0; extra == 'all-drivers'
Provides-Extra: cli
Requires-Dist: rich>=14.2.0; extra == 'cli'
Requires-Dist: typer>=0.20.0; extra == 'cli'
Provides-Extra: memcached
Requires-Dist: aiomcache>=0.8.2; extra == 'memcached'
Provides-Extra: msgpack
Requires-Dist: msgpack>=1.1.2; extra == 'msgpack'
Provides-Extra: mysql
Requires-Dist: aiomysql>=0.3.2; extra == 'mysql'
Provides-Extra: postgresql
Requires-Dist: asyncpg>=0.31.0; extra == 'postgresql'
Provides-Extra: redis
Requires-Dist: redis[hiredis]>=7.1.0; extra == 'redis'
Description-Content-Type: text/markdown

<p align="center">
  <a href="https://fluxcrud.mahimai.dev">
    <img src="https://github.com/mahimailabs/fluxcrud/blob/main/assets/logo.png?raw=true" width="400" alt="FluxCRUD Logo">
  </a>
</p>

<p align="center">
    <em>Modern, High-Performance, Async-First CRUD Framework for FastAPI ⚡</em>
</p>

<p align="center">
  <a href="https://github.com/mahimailabs/fluxcrud/actions/workflows/ci.yml">
    <img src="https://github.com/mahimailabs/fluxcrud/actions/workflows/ci.yml/badge.svg" alt="CI Status">
  </a>
  <a href="https://codecov.io/gh/mahimailabs/fluxcrud">
    <img src="https://codecov.io/gh/mahimailabs/fluxcrud/branch/main/graph/badge.svg" alt="Coverage">
  </a>
  <a href="https://pypi.org/project/fluxcrud/">
    <img src="https://img.shields.io/pypi/v/fluxcrud" alt="PyPI Version">
  </a>
  <a href="https://github.com/mahimailabs/fluxcrud/blob/main/LICENSE">
    <img src="https://img.shields.io/github/license/mahimailabs/fluxcrud" alt="License">
  </a>
</p>

---

**FluxCRUD** is a developer-friendly framework designed to eliminate boilerplate when building efficient, scalable APIs with **FastAPI** and **SQLAlchemy 2.0**. It provides a fully typed, async-first experience with built-in best practices like **caching**, **N+1 query prevention (DataLoaders)**, and **automatic extensive pagination**.

## ✨ Features

- **🚀 Async & Fast**: Built on top of `asyncpg`, `aiosqlite`, and `SQLAlchemy 2.0`.
- **🛠️ Zero Boilerplate**: Auto-generates fully typed CRUD routes (Create, Read, Update, Delete, List).
- **⚡ Smart Caching**: Integrated support for **Redis**, **Memcached**, and **In-Memory** caching.
- **🔍 Query Optimization**: Built-in **DataLoaders** to solve N+1 query problems automatically.
- **📄 Advanced Pagination**: Cursor-based and limit-offset pagination out of the box.
- **🛡️ Type Safe**: Deep integration with **Pydantic v2** for robust data validation.
- **📦 Modular**: Use what you need—Router, Repository, or the full Framework.

## 📦 Installation

```bash
pip install fluxcrud

# OR with standard extras
pip install "fluxcrud[postgresql,redis]"
```

## 🚀 Quick Start

Build a comprehensive API in less than 30 lines of code.

```python
from fastapi import FastAPI
from sqlalchemy.orm import Mapped, mapped_column
from pydantic import BaseModel
from fluxcrud import Flux, Base

# 1. Define your Database Model
class Item(Base):
    __tablename__ = "items"
    id: Mapped[int] = mapped_column(primary_key=True)
    name: Mapped[str]
    price: Mapped[float]

# 2. Define Pydantic Schemas
class ItemSchema(BaseModel):
    id: int
    name: str
    price: float

class CreateItemSchema(BaseModel):
    name: str
    price: float

# 3. Initialize App & Flux
app = FastAPI()
flux = Flux(app, db_url="sqlite+aiosqlite:///:memory:")
flux.attach_base(Base)

# 4. Register Routes
# Auto-generates: GET /items, POST /items, GET /items/{id}, PATCH /items/{id}, DELETE /items/{id}
flux.register(
    model=Item,
    schema=ItemSchema,
    create_schema=CreateItemSchema
)
```

Run it locally:

```bash
uvicorn main:app --reload
```

## 🧩 Advanced Usage

### Customizing the Repository

Need custom logic? Extend `FluxRepository` seamlessly.

```python
from fluxcrud.core import FluxRepository

class ItemRepository(FluxRepository[Item]):
    async def get_expensive_items(self, min_price: float):
        query = select(Item).where(Item.price > min_price)
        return await self.all(query)
```

### Enabling Caching

FluxCRUD makes caching trivial.

```python
from fluxcrud.cache import RedisBackend

# Configure Redis cache with 60s TTL
flux = Flux(
    app,
    db_url="...",
    cache_backend=RedisBackend("redis://localhost"),
    cache_ttl=60
)
```

## 🤝 Contributing

We welcome contributions! Please check out our [Contributing Guide](CONTRIBUTING.md) to get started.

## 📄 License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
