Drop-in admin panel for FastAPI + SQLAlchemy apps
Project description
FastAPI Console
A drop-in admin panel for FastAPI + SQLAlchemy apps, inspired by Django Unfold.
Features
- Zero-config auto-discovery of SQLAlchemy models
- Built-in authentication, RBAC, and audit logging
- Modern UI with Tailwind CSS, HTMX, and Alpine.js
- Fully customizable widgets, themes, and templates
- CLI for user management (
fconsole create-superuser,list-users,changepassword) - Async-first with support for PostgreSQL, MySQL, and SQLite
Installation
pip install fastapi-console
For database-specific async drivers:
pip install fastapi-console[postgres] # PostgreSQL via asyncpg
pip install fastapi-console[mysql] # MySQL via aiomysql
Quick Start
from contextlib import asynccontextmanager
from fastapi import FastAPI
from sqlalchemy import Column, Float, Integer, String
from sqlalchemy.ext.asyncio import AsyncSession, create_async_engine
from sqlalchemy.orm import DeclarativeBase, sessionmaker
from fastapi_console import Admin
from fastapi_console.auth.backend import BuiltinAuthBackend
class Base(DeclarativeBase):
pass
class Product(Base):
__tablename__ = "products"
id = Column(Integer, primary_key=True)
name = Column(String(100), nullable=False)
price = Column(Float, nullable=False)
DATABASE_URL = "sqlite+aiosqlite:///./app.db"
SECRET_KEY = "change-me-to-a-random-secret-key-in-production"
engine = create_async_engine(DATABASE_URL)
async_session = sessionmaker(engine, class_=AsyncSession)
@asynccontextmanager
async def lifespan(app: FastAPI):
async with engine.begin() as conn:
await conn.run_sync(Base.metadata.create_all)
yield
await engine.dispose()
app = FastAPI(lifespan=lifespan)
admin = Admin(
app=app,
engine=engine,
base=Base,
secret_key=SECRET_KEY,
auth_backend=BuiltinAuthBackend(),
)
admin.register(Product)
CLI Usage
# Create a superuser
fconsole create-superuser -e admin@example.com -p mypassword
# List all admin users
fconsole list-users
# Change a user's password
fconsole changepassword -e admin@example.com -p newpassword
All commands accept -d DATABASE_URL or read the DATABASE_URL environment variable.
Configuration
Environment Variables
| Variable | Description | Default |
|---|---|---|
DATABASE_URL |
Async database connection string | sqlite+aiosqlite:///./app.db |
SECRET_KEY |
Signing key for sessions/CSRF/JWT (min 32 chars) | Required in production |
Admin Options
admin = Admin(
app=app,
engine=engine,
base=Base,
secret_key=SECRET_KEY,
title="My Admin", # Admin panel title
admin_path="/admin", # URL prefix
dark_mode_default=False, # Dark mode on by default
# Theme
theme=ThemeConfig(preset="modern", primary_color="#6366F1"),
# Auth
auth_backend=BuiltinAuthBackend(),
# Environment badge
environment_label="Production",
environment_color="danger",
)
Database Support
- SQLite (default, built-in via
aiosqlite) - PostgreSQL:
pip install fastapi-console[postgres]+ setDATABASE_URL=postgresql+asyncpg://... - MySQL:
pip install fastapi-console[mysql]+ setDATABASE_URL=mysql+aiomysql://...
Development
# Install with dev dependencies
pip install -e ".[dev]"
# Run tests
pytest
# Lint
ruff check fastapi_console/
# Build distribution
pip install hatch
hatch build
License
MIT
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.5.tar.gz
(226.3 kB
view details)
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.5.tar.gz.
File metadata
- Download URL: fastapi_console-0.1.5.tar.gz
- Upload date:
- Size: 226.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
74f7163e36e4073ff8c03a4527ddb2c78afd8618cb6bce15d35d0827814e9bba
|
|
| MD5 |
ebe6b775a9ec898a274b6feb5f7952da
|
|
| BLAKE2b-256 |
41a613273942ef6a581dc82b216c15f3a5f84a306e55a469c00ff1048f2379f6
|
File details
Details for the file fastapi_console-0.1.5-py3-none-any.whl.
File metadata
- Download URL: fastapi_console-0.1.5-py3-none-any.whl
- Upload date:
- Size: 103.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
89d8998952aad39e7b70094eee00b4a45b01dc485a493e8661a582dfb04a49b9
|
|
| MD5 |
76320d7d9a0c75ed4de6f0ecaf7a6b73
|
|
| BLAKE2b-256 |
cfa2fd21c4b9e77881fcb4bfd65bea67b21bf6d84b6bbbabbff9ed766fd79388
|