Drop-in admin panel for FastAPI + SQLAlchemy apps
Project description
FastAPI Admin — Agent Guide
What This Project Is
A drop-in admin panel for FastAPI + SQLAlchemy apps. Register a model, get full CRUD UI, auth, permissions, and audit logging — no manual form or view definitions required.
Spec Documents
| File | Covers |
|---|---|
fastapi_admin_core_spec.md |
The 3 core bets: auto-discovery, audit log + RBAC, modern UI. Start here. |
AUTH_RBAC_SYSTEM.md |
Auth model extensibility (built-in / extend / BYO), session flow, RBAC permission tables and checks |
FORM_WIDGET_SYSTEM.md |
Widget class layer → Jinja2 macro layer, form pipeline, validation, relationship widgets |
PLUGIN_SYSTEM.md |
Every extension point: widgets, hooks, routes, auth, storage, audit sinks, dashboard, UI |
Architecture in One Paragraph
On startup, Admin() inspects every registered SQLAlchemy model, maps column types to widgets, and auto-generates CRUD routes under /admin/{table}/. Each request hits an auth middleware (session cookie → AuthBackend.get_user), then a PermissionChecker that reads admin_permissions rows keyed by user.role_id. Forms are rendered via Widget.render_context() → Jinja2 macros (Tailwind + HTMX + Alpine.js). Every DB write fires SQLAlchemy session events that write to admin_audit_log. Everything is replaceable via protocols.
Key Concepts
- RegisteredModel — central dataclass holding the model class, its
ModelAdminconfig, inspected columns/relationships, and resolved widgets - Widget — two-layer: Python class (parse + validate) + Jinja2 macro (HTML). Override either independently
- PermissionChecker — instantiated per request; checks
admin_permissionstable; superusers bypass all checks - AuthBackend — two methods:
authenticate()on login,get_user()on every request - AdminPlugin — bundles widgets, macros, routes, nav items, hooks into a distributable package
- AuditLog — written via SQLAlchemy
after_flushevent; stores full snapshot + diff for UPDATEs
Project Structure (key paths)
fastapi_admin/
├── admin.py # Admin class, public API, wires everything at init
├── registry.py # AdminRegistry singleton
├── inspection.py # SQLAlchemy model → ColumnMeta / RelationMeta
├── field_types.py # Column type → widget name mapping
├── router.py # Auto-route generation per registered model
├── auth/ # AuthBackend, PermissionChecker, session, dependencies
├── audit/ # AuditLog model, SQLAlchemy event listener, diff, context
├── widgets/ # Widget base class, all built-in widgets, WidgetRegistry
├── views/ # Route handler factories (list, form, delete, roles, dashboard)
├── templates/ # Jinja2: base.html, pages/, partials/, macros/
└── static/ # Tailwind CSS, HTMX, Alpine.js, Heroicons
Tech Stack
FastAPI · SQLAlchemy 2.x · Jinja2 · Tailwind CSS · HTMX · Alpine.js · itsdangerous · passlib/bcrypt . uv
What to Build (suggested order)
inspection.py+field_types.py— model inspection and type→widget mappingregistry.py+admin.py— registration API andModelAdminbaseauth/— models, session,AuthBackend,PermissionChecker, dependenciesaudit/— listener, diff,AuditLogmodelwidgets/— base class, built-in widgets,WidgetRegistryviews/+router.py— route factories, form pipelinetemplates/— Jinja2 templates and macrosplugins/—AdminPluginbase, plugin registration
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fastapi_console-0.1.0.tar.gz.
File metadata
- Download URL: fastapi_console-0.1.0.tar.gz
- Upload date:
- Size: 246.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7d20248b971e68a7dc3784f8291e0ed64e38e1a7603cae4040b67229e0f9fa8d
|
|
| MD5 |
db363a48d11f7df521f7fff253e88065
|
|
| BLAKE2b-256 |
3116c2faf4c0a3f78aef5b14c97c7823770073a9fc534522de0a903431a29d95
|
File details
Details for the file fastapi_console-0.1.0-py3-none-any.whl.
File metadata
- Download URL: fastapi_console-0.1.0-py3-none-any.whl
- Upload date:
- Size: 101.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
604d115d2812920caae602e6f19fcbfc6afa160213fcb7a93ccfe4c00731173f
|
|
| MD5 |
2211b2f4489ed477db70a9b5f27821ff
|
|
| BLAKE2b-256 |
7e6d4ebdf1f47f45cd878b50da03b5684edda5a56816d5143053b4cb375e2634
|