A dynamic visual admin dashboard and CRUD panel for FastAPI backend applications with auto model-schema discovery.
Project description
🚀 FastAPI-AutoAdmin
A self-generating visual admin dashboard and CRUD panel for FastAPI applications.
FastAPI-AutoAdmin dynamically discovers your SQLAlchemy / SQLModel database models, inspects their column structures and relations, generates secure JSON REST endpoints, and hosts a stunning client-side single-page dashboard featuring customizable analytics widgets, visual charts, and inline data management.
✨ Features
- 🔍 Zero-Boilerplate Auto-Discovery: Scans your application's memory space and dynamically registers SQLAlchemy & SQLModel schemas.
- 📊 Dynamic Board Panels: Add, drag, configure, and delete visual analytics charts (Bar, Line, Pie, Doughnut, KPI metric cards) grouped by columns and aggregated (Sum, Avg, Count, Min, Max).
- 🛠️ Fully-Featured CRUD Views: Auto-generated interfaces for managing database values, with built-in search, sorting, pagination, and data export (to CSV).
- 🧬 Type-Aware Forms: Automatically builds input form controls (such as toggles for booleans, selectors for Enums, date-pickers for Datetime) based on SQLAlchemy metadata.
- 🎨 Premium Modern Design: Built with a sleek dark/light theme engine, glassmorphic UI elements, vivid gradients, and smooth transition animations.
- 💾 Local Widget Persistence: Remembers your customized board widget layout directly in your browser (
localStorage).
📦 Installation
To use FastAPI-AutoAdmin in your project, install it directly from the GitHub repository:
# Using pip
pip install git+https://github.com/Harshidpatel12/FastAPI-AutoAdmin.git
# Using UV package manager
uv pip install git+https://github.com/Harshidpatel12/FastAPI-AutoAdmin.git
🚀 Quick Start (2-Line Setup)
Integrating FastAPI-AutoAdmin into any existing FastAPI project takes only two lines of code.
from fastapi import FastAPI
from sqlalchemy.orm import sessionmaker
from fastapi_autoadmin import FastAPIAutoAdmin
# 1. Your existing FastAPI application & DB setup
app = FastAPI()
SessionLocal = sessionmaker(...)
# 2. Mount FastAPIAutoAdmin! (session_factory & models are automatically discovered)
FastAPIAutoAdmin(app)
💡 Complete Integration Example
Here is a full example illustrating how FastAPI-AutoAdmin automatically detects database models (User and Order) and your SQLAlchemy sessionmaker, mounting the admin panel on /dashboard:
import datetime
from fastapi import FastAPI
from sqlalchemy import create_engine, Column, Integer, String, Float, DateTime
from sqlalchemy.orm import declarative_base, sessionmaker
from fastapi_autoadmin import FastAPIAutoAdmin
# Setup standard SQLAlchemy engine
DATABASE_URL = "sqlite:///./app.db"
engine = create_engine(DATABASE_URL)
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
Base = declarative_base()
# Declare your database models
class User(Base):
__tablename__ = "users"
id = Column(Integer, primary_key=True)
username = Column(String, unique=True, nullable=False)
email = Column(String, unique=True, nullable=False)
class Order(Base):
__tablename__ = "orders"
id = Column(Integer, primary_key=True)
total_amount = Column(Float, nullable=False)
order_date = Column(DateTime, default=datetime.datetime.utcnow)
# Run migrations (create tables)
Base.metadata.create_all(bind=engine)
# Initialize FastAPI
app = FastAPI()
# Mount FastAPIAutoAdmin (Auto-discovers sessionmaker and SQLAlchemy models)
FastAPIAutoAdmin(app)
Now, run your app with Uvicorn:
uvicorn main:app --reload
And navigate to: 👉 http://127.0.0.1:8000/dashboard
🛠️ Advanced Customization
Explicit Model Selection
By default, FastAPI-AutoAdmin automatically scans sys.modules for any registered database model. If you want to restrict the dashboard to show only specific models, pass them explicitly:
from my_models import Product, Category
FastAPIAutoAdmin(
app,
session_factory=SessionLocal,
models=[Product, Category] # Only show these two models
)
Automatic Sessionmaker Discovery
By default, FastAPI-AutoAdmin will scan all imported modules in sys.modules for a SQLAlchemy sessionmaker or async_sessionmaker instance (e.g., SessionLocal). If only one instance exists in your project, it will be automatically selected and bound.
If you have multiple database setups, use multiple sessionmakers, or simply want to be explicit, you can pass the sessionmaker object directly to the session_factory parameter.
📂 Project Structure
fastapi-autoadmin/
├── fastapi_autoadmin/ # Main Library Directory
│ ├── __init__.py # Exposes FastAPIAutoAdmin class
│ ├── discovery.py # Metadata / SQL introspection
│ ├── api.py # Dynamic CRUD & aggregate API builder
│ ├── ui.py # Frontend SPA server routes
│ └── templates/
│ └── dashboard.html # Responsive HTML/CSS/JS template
│ ├── demo_app.py # Self-contained runnable sandbox demo
├── pyproject.toml # Build configurations (PEP 517)
└── README.md # Project documentation
🛡️ License
This project is licensed under the MIT License. Feel free to use, modify, and distribute it for personal and commercial projects.
Project details
Release history Release notifications | RSS feed
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_autoadmin-0.1.1.tar.gz.
File metadata
- Download URL: fastapi_autoadmin-0.1.1.tar.gz
- Upload date:
- Size: 25.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ad1e8a697d644b17f59840d9fb4845ac91106e6af4cf3a113a837cfc2cf82318
|
|
| MD5 |
192f8b88544c01d25b80baea2a71612e
|
|
| BLAKE2b-256 |
ce6e0909ac6d64cbf8f49f40a3faeb9caf4f92407214f215870b49ba5a9335ea
|
File details
Details for the file fastapi_autoadmin-0.1.1-py3-none-any.whl.
File metadata
- Download URL: fastapi_autoadmin-0.1.1-py3-none-any.whl
- Upload date:
- Size: 26.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7ef7988464c66a96d7f6e989e964b002ab31ef1da44a943cf682d57629caec9e
|
|
| MD5 |
c158af0a174902e9a0c088e7321d45f2
|
|
| BLAKE2b-256 |
18b342d183f2e6d133dfc65e956db350752e12fcd04487ae4b3ee521096a240b
|