Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fastapi_autoadmin-0.1.0.tar.gz (25.7 kB view details)

Uploaded Source

Built Distribution

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

fastapi_autoadmin-0.1.0-py3-none-any.whl (26.4 kB view details)

Uploaded Python 3

File details

Details for the file fastapi_autoadmin-0.1.0.tar.gz.

File metadata

  • Download URL: fastapi_autoadmin-0.1.0.tar.gz
  • Upload date:
  • Size: 25.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for fastapi_autoadmin-0.1.0.tar.gz
Algorithm Hash digest
SHA256 6b8eb5a70f59a94d258f43317863c46321ad3a2e47515e0454cd376bcf0ae2cb
MD5 0b3876ba55aa42de73c661c21ef1a181
BLAKE2b-256 0bfa1d0fe2492ee59f26307294b3f373c7a654a2e701851e3330bd8570666939

See more details on using hashes here.

File details

Details for the file fastapi_autoadmin-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for fastapi_autoadmin-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b4479d35263c2e46d1b3d06a96f7c200403be67a2960718a6dc5ecf3a772d0ce
MD5 e2a55d430bf6987ed9bc9e65f54dde31
BLAKE2b-256 fa2f1a2e4af76397ab60751671eba8759e0b21a59074516cb764e2b6932df4bf

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