Skip to main content

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 ModelAdmin config, 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_permissions table; 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_flush event; 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)

  1. inspection.py + field_types.py — model inspection and type→widget mapping
  2. registry.py + admin.py — registration API and ModelAdmin base
  3. auth/ — models, session, AuthBackend, PermissionChecker, dependencies
  4. audit/ — listener, diff, AuditLog model
  5. widgets/ — base class, built-in widgets, WidgetRegistry
  6. views/ + router.py — route factories, form pipeline
  7. templates/ — Jinja2 templates and macros
  8. plugins/AdminPlugin base, 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

fastapi_console-0.1.1.tar.gz (247.9 kB view details)

Uploaded Source

Built Distribution

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

fastapi_console-0.1.1-py3-none-any.whl (101.2 kB view details)

Uploaded Python 3

File details

Details for the file fastapi_console-0.1.1.tar.gz.

File metadata

  • Download URL: fastapi_console-0.1.1.tar.gz
  • Upload date:
  • Size: 247.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.5

File hashes

Hashes for fastapi_console-0.1.1.tar.gz
Algorithm Hash digest
SHA256 aa863c57a727015a26d5818d035ccbb2534cdd382740feba3eaf7ddf3473f76f
MD5 da9a42e4182297b05c3238046ef35410
BLAKE2b-256 3dc2feebc231992aca5eae91a3c6a203753bae11035adabb264716d7b8d38d87

See more details on using hashes here.

File details

Details for the file fastapi_console-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for fastapi_console-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c4835af0eeb251aae680d8e19c67a4cdd7f42f656c625aa9ee24416314c798bd
MD5 4c4de7409bf95539db9ac04dda69cba3
BLAKE2b-256 95e63de12392f3ca3cab6b87de1ff0d4768accfc1abcd7a9d8c1f7515cee215a

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