Skip to main content

FluxCRUD is a easy to use, fast, and modern CRUD framework for FastAPI.

Project description

FluxCRUD Logo

Modern, High-Performance, Async-First CRUD Framework for FastAPI ⚡

CI Status Coverage PyPI Version License


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

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.

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:

uvicorn main:app --reload

🧩 Advanced Usage

Customizing the Repository

Need custom logic? Extend FluxRepository seamlessly.

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.

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 to get started.

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fluxcrud-0.1.0.tar.gz (17.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fluxcrud-0.1.0-py3-none-any.whl (25.7 kB view details)

Uploaded Python 3

File details

Details for the file fluxcrud-0.1.0.tar.gz.

File metadata

  • Download URL: fluxcrud-0.1.0.tar.gz
  • Upload date:
  • Size: 17.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for fluxcrud-0.1.0.tar.gz
Algorithm Hash digest
SHA256 58088c33b04da72f5ea283ff38f1032a7ea9457417a7e049172fc9079e554e36
MD5 59732cf70ae6a7e81fa9f29c4c0b6fd7
BLAKE2b-256 bb64bbc815de881cb8da88294e8c5152064bd6363ff23e890a2ec1f1ab64683d

See more details on using hashes here.

File details

Details for the file fluxcrud-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: fluxcrud-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 25.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for fluxcrud-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f6f358eb5285366ef33a4a9f17c17d0a877d1a010292be8f9a64fbc911874269
MD5 99b5659e2a625df9ff1c1c02973a28a2
BLAKE2b-256 c77864af76fb9350e952a80daa7ca54ac70a7437d4cfbdb17f66ceed122042ce

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page