Skip to main content

Aegis Admin

PyPI version Python License: MIT

Aegis is an enterprise admin framework for FastAPI that auto-generates a full admin UI and JSON API for your SQLAlchemy models — with zero boilerplate.


Features

  • Auto-generated admin UI — list, create, edit, delete for every registered model
  • Searchable list views — ILIKE search across all string columns
  • Bulk delete — select multiple records and delete in one action
  • FK dropdowns & autocomplete — foreign key fields render as <select> or live-search autocomplete
  • JSON API endpoints — paginated, filterable, searchable REST endpoints alongside the UI
  • Pluggable auth — bring your own session, JWT, OAuth2, or any custom backend
  • Multi-database support — register models against different database engines
  • Async-first — built on SQLAlchemy 2.0 async engine

Installation

pip install aegis-admin

Also install an async database driver, e.g. aiosqlite for SQLite or asyncpg for PostgreSQL.


Quick Start

Async project (SQLAlchemy async engine)

from fastapi import FastAPI
from sqlalchemy import Column, Integer, String
from sqlalchemy.orm import DeclarativeBase
from sqlalchemy.ext.asyncio import create_async_engine

from aegis.core.app import Aegis
from aegis.core.auth import AllowAllAuthBackend   # swap for your own in production

class Base(DeclarativeBase):
    pass

class User(Base):
    __tablename__ = "users"
    id     = Column(Integer, primary_key=True)
    name   = Column(String(100))
    email  = Column(String(200))

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

aegis = Aegis(
    app=app,
    engines={"default": engine},
    auth_backend=AllowAllAuthBackend(),   # replace with your auth backend
    title="My Admin",
)

aegis.register(User)

Sync project (standard SQLAlchemy engine)

Already have a non-async FastAPI project? Pass a regular create_engine — no async driver needed.

from fastapi import FastAPI
from sqlalchemy import Column, Integer, String, create_engine
from sqlalchemy.orm import DeclarativeBase

from aegis.core.app import Aegis
from aegis.core.auth import AllowAllAuthBackend

class Base(DeclarativeBase):
    pass

class User(Base):
    __tablename__ = "users"
    id     = Column(Integer, primary_key=True)
    name   = Column(String(100))
    email  = Column(String(200))

app    = FastAPI()
engine = create_engine("sqlite:///./app.db")   # standard sync engine — no aiosqlite needed

aegis = Aegis(
    app=app,
    engines={"default": engine},
    auth_backend=AllowAllAuthBackend(),
    title="My Admin",
)

aegis.register(User)

Aegis detects sync vs async engines automatically — no configuration required.

Visit http://localhost:8000/admin/ui/ to see the admin panel.


Authentication

Aegis does not ship with a built-in login page — it integrates with your project's existing auth system via the AuthBackend interface.

from fastapi import Request
from aegis.core.auth import AuthBackend

class MyAuthBackend(AuthBackend):
    async def get_current_user(self, request: Request):
        # Resolve the user from a cookie, JWT, session, etc.
        token = request.cookies.get("session")
        return await db.get_user_by_token(token)   # your existing logic

    async def is_authenticated(self, user) -> bool:
        # Return True only if this user may access the admin
        return user is not None and user.is_admin

Common patterns:

Pattern How
Cookie / session Read request.session["user_id"] (requires SessionMiddleware)
JWT Decode request.headers["Authorization"] or a cookie
Reuse existing dependency Call your verify_token() / get_current_user() directly

When a request is not authenticated, Aegis automatically redirects UI routes to login_url (default /login).


Endpoints Generated

For every registered model, Aegis creates:

Method Path Description
GET /admin/{table}/ JSON list — paginated, searchable, filterable
GET /admin/ui/{table}/ HTML list view with search + bulk delete
GET/POST /admin/ui/{table}/create/ Create form
GET/POST /admin/ui/{table}/{pk}/edit/ Edit form
GET/POST /admin/ui/{table}/{pk}/delete/ Delete confirmation
POST /admin/ui/{table}/bulk-delete/ Bulk delete confirmation
GET /admin/api/{table}/autocomplete/ FK autocomplete search

JSON API query parameters

GET /admin/users/?limit=50&offset=0&search=alice&role=admin
Param Description
limit Max 100, default 50
offset Pagination offset
search ILIKE search across all string columns
<column> Exact-match filter on any column

Multiple Databases

aegis = Aegis(
    app=app,
    engines={
        "default": primary_engine,
        "analytics": analytics_engine,
    },
    auth_backend=MyAuthBackend(),
)

aegis.register(User)                        # uses "default"
aegis.register(Report, database="analytics")

Configuration

aegis = Aegis(
    app=app,
    engines={"default": engine},
    auth_backend=MyAuthBackend(),
    base_path="/admin",      # URL prefix (default: /admin)
    title="My Admin",        # Shown in the UI header
    login_url="/login",      # Redirect target when unauthenticated
)

License

MIT

Metadata

Release files for aegis-admin 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for aegis-admin 0.1.1
File Size Uploaded Provenance
aegis_admin-0.1.1.tar.gz 21.0 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for aegis-admin 0.1.1
File Interpreter ABI Platform
aegis_admin-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 46.4 kB

Release files / aegis_admin-0.1.1.tar.gz

Download URL aegis_admin-0.1.1.tar.gz
Size 21.0 kB
Tags Source
SHA-256 checksum
How to use checksums
fe1a8e120c1071c1e10859caf3b8edbd063496b0d534a16e8e72596a209926e9
BLAKE2b-256 checksum
How to use checksums
38ae0d13c565b9fa2ff3319d7fc3e163bcc1b6c50e967aecbe06d005094ab0fb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.8.10

Release files / aegis_admin-0.1.1-py3-none-any.whl

Download URL aegis_admin-0.1.1-py3-none-any.whl
Size 25.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2ea40f5a9868f39d97b2c1b94ab3941aa8e39aa82d8b0fdf48d27606c6c55b7e
BLAKE2b-256 checksum
How to use checksums
a0cb987189fd6cbf09d441fe894473b81c4bf39423d4dc92ef5481730264d0a8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.8.10

Security for aegis-admin 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page