Metadata-Version: 2.4
Name: fastapi-tenants
Version: 0.0.1
Summary: A multi-tenancy solution for FastAPI (database-per-tenant, schema-per-tenant, and row-level-tenants strategies).
Project-URL: Homepage, https://github.com/KapilDagur/fastapi-tenants
Author-email: Kapil Dagur <kapildagur1306@gmail.com>
License: MIT
License-File: LICENSE
Classifier: Development Status :: 3 - Alpha
Classifier: Framework :: FastAPI
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Database
Classifier: Topic :: Software Development :: Libraries
Requires-Python: >=3.9
Description-Content-Type: text/markdown


---

# fastapi-tenants

*A multi-tenancy solution for FastAPI with support for database-per-tenant, schema-per-tenant, and row-level tenancy strategies.*

---

## ✨ Features

* **Flexible strategies** → database-per-tenant, schema-per-tenant, row-level.
* **Tenant-aware middleware** → resolve tenant from headers, subdomains, or tokens.
* **DB session management** → per-tenant scoped sessions.
* **Pluggable design** → extend strategies or authentication as needed.
* **FastAPI-first** → built for dependency injection and async support.

---

## 📦 Installation

```bash
pip install fastapi-tenants
```

Optional extras:

```bash
pip install "fastapi-tenants[postgres]"
pip install "fastapi-tenants[mysql]"
```

---

## 🚀 Quick Start

```python
from fastapi import FastAPI, Depends
from fastapi_tenants import TenancyMiddleware, get_tenant_session

app = FastAPI()

# Enable tenancy
app.add_middleware(
    TenancyMiddleware,
    strategy="schema",   # or "database", "row"
    header="X-Tenant-ID"
)

@app.get("/users")
def list_users(session = Depends(get_tenant_session)):
    return session.query(User).all()
```

---

## 📚 Roadmap

* [ ] Schema-based tenancy ✅
* [ ] Database-per-tenant support
* [ ] Row-level tenancy
* [ ] Multi-backend support (Postgres, MySQL, SQLite)
* [ ] Example apps & docs

---

## 🤝 Contributing

Contributions are welcome!
Check out [CONTRIBUTING.md](CONTRIBUTING.md) (coming soon).

---

## 📜 License

MIT License © 2025 [Kapil Dagur](https://github.com/KapilDagur)

---
