Skip to main content

🚀 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.

Release files for fastapi-autoadmin 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 fastapi-autoadmin 0.1.1
File Size Uploaded
fastapi_autoadmin-0.1.1.tar.gz 25.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for fastapi-autoadmin 0.1.1
File Interpreter ABI Platform
fastapi_autoadmin-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 52.4 kB

Release files / fastapi_autoadmin-0.1.1.tar.gz

Download URL fastapi_autoadmin-0.1.1.tar.gz
Size 25.9 kB
Tags Source
SHA-256 checksum
How to use checksums
ad1e8a697d644b17f59840d9fb4845ac91106e6af4cf3a113a837cfc2cf82318
BLAKE2b-256 checksum
How to use checksums
ce6e0909ac6d64cbf8f49f40a3faeb9caf4f92407214f215870b49ba5a9335ea
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.12

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

Download URL fastapi_autoadmin-0.1.1-py3-none-any.whl
Size 26.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7ef7988464c66a96d7f6e989e964b002ab31ef1da44a943cf682d57629caec9e
BLAKE2b-256 checksum
How to use checksums
18b342d183f2e6d133dfc65e956db350752e12fcd04487ae4b3ee521096a240b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.12

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1.0

2 release files

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