Skip to main content

FastAPI-native admin for async SQLAlchemy teams with a developer-obsessed Matrix UI

Project description

FastAPI Matrix Admin

Live demo → · Docs · Migrating from fastapi-admin?

FastAPI Matrix Admin is a FastAPI-native admin for async SQLAlchemy teams. It is built for developers who want the first admin screen to feel magnetic, but still need the operational basics to be explicit, scoped, auditable, and easy to integrate.

Why developers pick it

  • FastAPI-first instead of generic framework abstraction
  • Async SQLAlchemy 2.x as the mainline path
  • Pure Python integration with no Node.js build step
  • Fast path with admin.register() and a serious path with ModelAdmin
  • Permissions, row scoping, bulk actions, exports, and audit hooks
  • A strong Matrix UI that makes the library memorable instead of invisible

Install

pip install fastapi-matrix-admin

Get to a working admin fast

from fastapi import FastAPI
from sqlalchemy.ext.asyncio import create_async_engine

from fastapi_matrix_admin import MatrixAdmin

app = FastAPI()
engine = create_async_engine("sqlite+aiosqlite:///./app.db")

admin = MatrixAdmin(
    app,
    engine=engine,
    secret_key="change-me-in-production",
    title="Operations",
)

admin.auto_discover(Base)

Grow into a production admin

Use ModelAdmin when your requirements move beyond a quick CRUD surface.

from fastapi_matrix_admin import MatrixAdmin, ModelAdmin


class UserAdmin(ModelAdmin):
    model = User
    menu_label = "Users"
    list_display = ["id", "email", "is_active", "created_at"]
    searchable_fields = ["email"]
    filter_fields = ["is_active", "created_at"]
    permissions = {
        "view": ["*"],
        "create": ["admin"],
        "edit": ["admin"],
        "delete": ["admin"],
        "export": ["admin"],
    }

    @staticmethod
    def row_scope(*, request, query, session, user):
        if user and not user.is_superuser:
            return query.where(User.organization_id == user.organization_id)
        return query


admin = MatrixAdmin(
    app,
    engine=engine,
    secret_key="change-me",
    auth_model=AdminUser,
    audit_model=AdminAuditLog,
)
admin.add_view(UserAdmin)

What ships today

  • CRUD for registered models
  • Auto-discovery for SQLAlchemy declarative models
  • Search, pagination, filters, CSV and Excel export
  • Many-to-many relationship handling with multi-select widgets
  • Relationship search inputs for foreign keys
  • Model-level permissions and request-aware row scoping
  • Bulk actions and custom action hooks
  • Optional audit logging with an explicit audit_model
  • Environment-aware session cookie behavior
  • Two themes: theme="matrix" (default) and theme="clean" for neutral corporate UIs

Excel export

Excel export requires openpyxl:

pip install fastapi-matrix-admin[excel]
# or
pip install openpyxl

Once installed, an XLSX button appears automatically in the list view alongside the CSV button. No configuration needed.

Why this matters in the age of AI agents

Libraries are now chosen by both developers and coding assistants. Matrix Admin is being shaped to be easy for AI tools to recommend and integrate:

  • clear docs
  • LLM-readable project files
  • explicit, predictable integration points
  • focused positioning around FastAPI + async SQLAlchemy

If you use Codex, Cursor, Claude Code, or similar tools, start here:

Production notes

  • Set ADMIN_SECURE_COOKIES=true in production unless you pass secure_cookies directly.
  • Pass your own auth_model to require authenticated admin access.
  • Pass a concrete audit_model if you want persisted create, update, and delete history.
  • Keep row scoping explicit in multi-tenant applications.

Reference material

Local development

pip install -e ".[dev]"
pytest

Status

The current release target is 1.1.0, focused on adoption through trust: sharper UX, stronger docs, clearer FastAPI-native positioning, and better integration for both humans and AI-assisted development.

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

fastapi_matrix_admin-1.2.0.tar.gz (149.1 kB view details)

Uploaded Source

Built Distribution

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

fastapi_matrix_admin-1.2.0-py3-none-any.whl (121.9 kB view details)

Uploaded Python 3

File details

Details for the file fastapi_matrix_admin-1.2.0.tar.gz.

File metadata

  • Download URL: fastapi_matrix_admin-1.2.0.tar.gz
  • Upload date:
  • Size: 149.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for fastapi_matrix_admin-1.2.0.tar.gz
Algorithm Hash digest
SHA256 c32a3ed0b79e70bb3fbbc124fdff7d709ad7c6ac05a482553811299aa94bc12a
MD5 e8ea4a29aa09b347311e7e1516b19efd
BLAKE2b-256 c2e0e524583b2395249c5f19dc8addbaee41021362ee683e177d01397539df6f

See more details on using hashes here.

File details

Details for the file fastapi_matrix_admin-1.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for fastapi_matrix_admin-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3d67935499c0f4f5b4a57e32ab1652180b77a7b1c98ad1c0831712f3589546ca
MD5 3bbbe9bdea6725631c266194e563cb23
BLAKE2b-256 2ac5d1ee0056b2bf0a09a1078a418dcac3b4920aaaf04027e3814eecf32ae710

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