1111</p >
1212
1313<p align =" center " >
14- <a href =" https://pypi.org/project /crudadmin " >
15- <img src =" https://img.shields.io/pypi/v/ crudadmin?color=%2334D058&label=pypi%20package " alt =" Package version " />
14+ <a href =" https://github.com/igorbenav /crudadmin/actions/workflows/tests.yml " >
15+ <img src =" https://github.com/igorbenav/ crudadmin/actions/workflows/tests.yml/badge.svg " alt =" Tests " />
1616</a >
17- <a href =" https://pypi.org/project/crudadmin " >
18- <img src =" https://img.shields.io/pypi/pyversions/crudadmin.svg?color=%2334D058 " alt =" Supported Python versions " />
17+ <a href =" https://pypi.org/project/crudadmin/ " >
18+ <img src =" https://img.shields.io/pypi/v/crudadmin?color=%2334D058&label=pypi%20package " alt =" PyPi Version " />
19+ </a >
20+ <a href =" https://pypi.org/project/crudadmin/ " >
21+ <img src =" https://img.shields.io/pypi/pyversions/crudadmin.svg?color=%2334D058 " alt =" Supported Python Versions " />
1922</a >
2023</p >
2124
22- <hr >
23- <p align =" justify " >
24- <b >CRUDAdmin</b > is a robust admin interface generator for <b >FastAPI</b > applications, offering secure authentication, comprehensive event tracking, and essential monitoring features. Built on top of FastCRUD and SQLAlchemy, it helps you create production-ready admin panels with minimal configuration.
25- </p >
25+ ---
2626
27- < p >< b >Documentation</ b >: < a href = " https://igorbenav.github.io/crudadmin/ " > https://igorbenav. github.io/crudadmin/</ a ></ p >
27+ ** CRUDAdmin ** is a robust admin interface generator for ** FastAPI ** applications, offering secure authentication, comprehensive event tracking, and essential monitoring features. Built with [ FastCRUD ] ( https://github.com/benavlabs/fastcrud ) and HTMX, it helps you create production-ready admin panels with minimal configuration.
2828
29- > [ !WARNING]
30- > CRUDAdmin is still experimental.
29+ ** Documentation** : [ https://igorbenav.github.io/crudadmin/ ] ( https://igorbenav.github.io/crudadmin/ )
3130
32- <hr >
31+ > [ !WARNING]
32+ > CRUDAdmin is still experimental. While actively developed and tested, APIs may change between versions. Upgrade with caution in production environments, always carefuly reading the changelog.
3333
3434## Features
3535
36- - 🔒 ** Session-based Authentication** : Secure session management with inactivity timeouts and concurrent session limits
37- - 🛡️ ** Built-in Security** : IP restrictions, HTTPS enforcement, and secure cookie handling
38- - 📝 ** Event Tracking** : Comprehensive audit logs for all admin actions with user attribution
39- - 🏥 ** Health Monitoring** : Real-time system status dashboard with key metrics
40- - 📊 ** Auto-generated Interface** : Creates admin UI directly from your SQLAlchemy models
41- - 🔍 ** Smart Filtering** : Type-aware field filtering and efficient search
42- - 🌗 ** Modern UI** : Clean interface with dark/light theme support
43-
44- ## Requirements
45-
46- Before installing CRUDAdmin, ensure you have:
36+ - ** 🔒 Multi-Backend Session Management** : Memory, Redis, Memcached, Database, and Hybrid backends
37+ - ** 🛡️ Built-in Security** : CSRF protection, rate limiting, IP restrictions, HTTPS enforcement, and secure cookies
38+ - ** 📝 Event Tracking & Audit Logs** : Comprehensive audit trails for all admin actions with user attribution
39+ - ** 📊 Auto-generated Interface** : Creates admin UI directly from your SQLAlchemy models with intelligent field detection
40+ - ** 🔍 Advanced Filtering** : Type-aware field filtering, search, and pagination with bulk operations
41+ - ** 🌗 Modern UI** : Clean, responsive interface built with HTMX and [ FastCRUD] ( https://github.com/benavlabs/fastcrud )
4742
48- - ** FastAPI** : Latest version for the web framework
49- - ** SQLAlchemy** : Version 2.0+ for database operations
50- - ** Pydantic** : Version 2.0+ for data validation
43+ ## Quick Start
5144
52- ## Installing
45+ ### Installation
5346
5447``` sh
55- pip install crudadmin
48+ uv add crudadmin
5649```
5750
58- Or using poetry:
59-
51+ For production with Redis sessions:
6052``` sh
61- poetry add crudadmin
62- ```
63-
64- ## Usage
65-
66- CRUDAdmin offers a straightforward way to create admin interfaces. Here's how to get started:
67-
68- ### Define Your Models and Schemas
69-
70- ** models.py**
71- ``` python
72- from sqlalchemy.orm import DeclarativeBase
73- from sqlalchemy import Column, Integer, String
74-
75- class Base (DeclarativeBase ):
76- pass
77-
78- class User (Base ):
79- __tablename__ = " users"
80- id = Column(Integer, primary_key = True )
81- username = Column(String, unique = True )
82- email = Column(String)
83- role = Column(String)
53+ uv add " crudadmin[redis]"
8454```
8555
86- ** schemas.py**
87- ``` python
88- from pydantic import BaseModel, EmailStr
89-
90- class UserCreate (BaseModel ):
91- username: str
92- email: EmailStr
93- role: str = " user"
94-
95- class UserUpdate (BaseModel ):
96- email: EmailStr | None = None
97- role: str | None = None
56+ Or using pip and memcached:
57+ ``` sh
58+ pip install " crudadmin[memcached]"
9859```
9960
100- ### Set Up the Admin Interface
61+ ### Basic Setup
10162
102- ** main.py**
10363``` python
10464from contextlib import asynccontextmanager
10565from fastapi import FastAPI
10666from sqlalchemy.ext.asyncio import AsyncSession, create_async_engine
10767from crudadmin import CRUDAdmin
108- import os
68+
69+ from .user import (
70+ User,
71+ UserCreate,
72+ UserUpdate,
73+ )
10974
11075# Database setup
11176engine = create_async_engine(" sqlite+aiosqlite:///app.db" )
@@ -114,7 +79,7 @@ session = AsyncSession(engine)
11479# Create admin interface
11580admin = CRUDAdmin(
11681 session = session,
117- SECRET_KEY = os.environ.get( " ADMIN_SECRET_KEY " ) ,
82+ SECRET_KEY = " your-secret-key-here " ,
11883 initial_admin = {
11984 " username" : " admin" ,
12085 " password" : " secure_password123"
@@ -145,67 +110,74 @@ app = FastAPI(lifespan=lifespan)
145110app.mount(" /admin" , admin.app)
146111```
147112
148- ### Enable Event Tracking
113+ Navigate to ` /admin ` to access your admin interface with:
149114
150- ``` python
151- admin = CRUDAdmin(
152- session = session,
153- SECRET_KEY = SECRET_KEY ,
154- track_events = True ,
155- admin_db_url = " postgresql+asyncpg://user:pass@localhost/admin_logs"
156- )
115+ - User authentication
116+ - CRUD operations for your models
117+ - Responsive UI with dark/light themes
118+ - Built-in security features
157119
158- @asynccontextmanager
159- async def lifespan (app : FastAPI):
160- async with engine.begin() as conn:
161- await conn.run_sync(Base.metadata.create_all)
162- await admin.initialize() # Creates event tracking tables
163- yield
120+ ## Session Backends
121+
122+ ### Development (Default)
123+ ``` python
124+ admin = CRUDAdmin(session = session, SECRET_KEY = " key" ) # Memory backend
164125```
165126
166- ### Configure Security Features
127+ ### Production with Redis
128+ ``` python
129+ admin = CRUDAdmin(session = session, SECRET_KEY = " key" ).use_redis_sessions(
130+ redis_url = " redis://localhost:6379"
131+ )
132+ ```
167133
134+ ### Production with Security Features
168135``` python
169136admin = CRUDAdmin(
170137 session = session,
171138 SECRET_KEY = SECRET_KEY ,
172- # Security settings
139+ # Security features
173140 allowed_ips = [" 10.0.0.1" ],
174141 allowed_networks = [" 192.168.1.0/24" ],
175142 secure_cookies = True ,
176143 enforce_https = True ,
177- # Session settings
178- max_sessions_per_user = 5 ,
179- session_timeout_minutes = 30
180- )
181-
182- @asynccontextmanager
183- async def lifespan (app : FastAPI):
184- async with engine.begin() as conn:
185- await conn.run_sync(Base.metadata.create_all)
186- await admin.initialize() # Initializes security features
187- yield
144+ # Session management
145+ max_sessions_per_user = 3 ,
146+ session_timeout_minutes = 15 ,
147+ # Event tracking
148+ track_events = True
149+ ).use_redis_sessions(redis_url = " redis://localhost:6379" )
188150```
189151
190- ## Current Limitations (coming soon)
152+ ## Backend Options
191153
192- - No file upload support yet
193- - No custom admin views (model-based only)
194- - No custom field widgets
195- - No SQLAlchemy relationship support
196- - No export functionality
154+ | Backend | Use Case | Performance | Persistence | Scalability |
155+ | ---------| ----------| -------------| -------------| -------------|
156+ | ** Memory** | Development/Testing | Fastest | No | Single Instance |
157+ | ** Redis** | Production (Recommended) | Very Fast | Optional | High |
158+ | ** Memcached** | High-Traffic Production | Very Fast | No | High |
159+ | ** Database** | Simple Deployments | Good | Yes | Medium |
160+ | ** Hybrid** | Enterprise/Audit Requirements | Fast | Yes | High |
197161
198- ## Similar Projects
162+ ## What You Get
199163
200- - ** [ Django Admin] ( https://docs.djangoproject.com/en/stable/ref/contrib/admin/ ) ** : The inspiration for this project
201- - ** [ Flask-Admin] ( https://flask-admin.readthedocs.io/ ) ** : Similar project for Flask
202- - ** [ Sqladmin] ( https://github.com/aminalaee/sqladmin ) ** : Another FastAPI admin interface
164+ - ** Secure Authentication** - Login/logout with session management
165+ - ** Auto-Generated Forms** - Create and edit forms built from your Pydantic schemas
166+ - ** Data Tables** - Paginated, sortable tables for viewing your data
167+ - ** CRUD Operations** - Full Create, Read, Update, Delete functionality
168+ - ** Responsive UI** - Works on desktop and mobile devices
169+ - ** Dark/Light Themes** - Toggle between themes
170+ - ** Input Validation** - Built-in validation using your Pydantic schemas
171+ - ** Event Tracking** - Monitor all admin actions with audit trails
172+ - ** Health Monitoring** - Real-time system status and diagnostics
203173
204- ## License
174+ ## Documentation
205175
206- This project is licensed under the MIT License - see the [ LICENSE] ( LICENSE ) file for details.
176+ - ** [ Quick Start] ( https://igorbenav.github.io/crudadmin/quick-start/ ) ** : Get up and running in 5 minutes
177+ - ** [ Usage Guide] ( https://igorbenav.github.io/crudadmin/usage/overview/ ) ** : Complete usage documentation
178+ - ** [ API Reference] ( https://igorbenav.github.io/crudadmin/api/overview/ ) ** : Full API documentation
179+ - ** [ Advanced Topics] ( https://igorbenav.github.io/crudadmin/advanced/overview/ ) ** : Production features and configurations
207180
208- ## Contact
181+ ## License
209182
210- Igor Benav –
[ @igorbenav ] ( https://x.com/igorbenav ) –
[email protected] 211- [ github.com/igorbenav] ( https://github.com/igorbenav/ )
183+ This project is licensed under the MIT License - see the [ LICENSE] ( LICENSE ) file for details.
0 commit comments