Conversation
…nterface - Add AdminSite orchestrator for model registration and FastAPI integration - Implement ModelAdmin with configurable list_display, search, filters, permissions - Create database engine with SQLite/PostgreSQL support and session management - Build authentication system with AdminUser contract and session-based auth - Add query engine for dynamic filtering, search, and pagination - Implement form engine with validation and type conversion - Create router factory for automatic CRUD route generation - Add Bootstrap 5 templates with responsive admin interface - Include static assets (CSS/JS) for admin styling and interactions
…ctionality tests - Add conftest.py with database session fixtures and test models - Implement tests for AdminSite, ModelAdmin, Authentication, CRUD operations - Include test cases for search, filtering, permissions, and route generation - Add test isolation with proper registry cleanup between tests
…egration - Create Category, Product, and User models with SQLAlchemy relationships - Implement custom ModelAdmin classes with search, filtering, and permissions - Show proper AdminSite setup and model registration patterns - Include development server with hot reload for testing
- Interactive CLI for creating admin accounts with proper password validation - Initialize security manager with AdminConfig for password hashing - Include input validation and error handling for user creation - Support for optional fields (email, first_name, last_name)
- Show AdminSite creation, configuration, and model registration - Display ModelAdmin configuration examples with formatted output - Demonstrate framework architecture and generated route structure - Include feature overview and next steps for users
- Create demo models (DemoUser, DemoCategory, DemoProduct) for testing - Override authentication to bypass login for immediate UI testing - Generate sample data automatically for interactive demonstration - Provide no-auth version of admin interface on port 8080
- Test core components without dependency issues (AdminSite, ModelAdmin, Config) - Validate model registration and admin configuration systems - Provide immediate feedback on framework functionality - Include testing recommendations and troubleshooting guide
|
Caution Review failedThe pull request is closed. ℹ️ Recent review infoConfiguration used: defaults Review profile: CHILL Plan: Pro 📒 Files selected for processing (39)
📝 WalkthroughWalkthroughThis pull request introduces the Internal Admin framework—a complete Python package that provides a lightweight admin interface generator for SQLAlchemy models built on FastAPI. It includes database management, authentication/authorization, dynamic form and query engines, CRUD route generation, Bootstrap 5 templates, and supporting utilities with comprehensive documentation and examples. Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant FastAPI as FastAPI App
participant AuthRouter as Auth Router
participant SecurityMgr as SecurityManager
participant Database as Database
participant Session as Session
Client->>FastAPI: POST /admin/login (username, password)
FastAPI->>AuthRouter: Route to login handler
AuthRouter->>Database: Query user by username/email
Database->>Session: Fetch AdminUser
Session-->>AuthRouter: Return user
AuthRouter->>SecurityMgr: verify_password(input, hash)
SecurityMgr-->>AuthRouter: Boolean result
alt Password valid & user active
AuthRouter->>SecurityMgr: create_session_token(user_id)
SecurityMgr-->>AuthRouter: JWT token
AuthRouter->>Database: Update last_login
AuthRouter-->>Client: Set session cookie + redirect /admin/
else Invalid credentials
AuthRouter-->>Client: Redirect /admin/login?error=invalid
end
sequenceDiagram
participant Client
participant FastAPI as FastAPI App
participant ModelRouter as Model CRUD Router
participant PermMgr as PermissionManager
participant QueryEngine as QueryEngine
participant Database as Database
participant Session as Session
Client->>FastAPI: GET /admin/testmodel/
FastAPI->>ModelRouter: List view handler
ModelRouter->>PermMgr: check_permission(user, TestModel, VIEW)
PermMgr-->>ModelRouter: Permission result
alt User has permission
ModelRouter->>QueryEngine: execute_query(session, search, filters, page)
QueryEngine->>Database: Build & execute query
Database->>Session: Fetch paginated results
Session-->>QueryEngine: QueryResult with items & pagination
QueryEngine-->>ModelRouter: Return QueryResult
ModelRouter->>ModelRouter: Render list.html template
ModelRouter-->>Client: HTML list view
else No permission
ModelRouter-->>Client: HTTP 403 Forbidden
end
sequenceDiagram
participant Client
participant FastAPI as FastAPI App
participant ModelRouter as Model CRUD Router
participant FormEngine as FormEngine
participant ModelAdmin as ModelAdmin
participant Database as Database
participant Session as Session
Client->>FastAPI: GET /admin/testmodel/create/
FastAPI->>ModelRouter: Create form handler
ModelRouter->>FormEngine: generate_form_fields(session)
FormEngine->>ModelAdmin: get_readonly_fields()
ModelAdmin-->>FormEngine: List of readonly fields
FormEngine->>Database: Get column metadata
FormEngine-->>ModelRouter: List[FormField]
ModelRouter->>ModelRouter: Render form.html template
ModelRouter-->>Client: HTML form
Client->>FastAPI: POST /admin/testmodel/create/ (form data)
FastAPI->>ModelRouter: Create submission handler
ModelRouter->>FormEngine: validate_form_data(form_data)
FormEngine-->>ModelRouter: Validated data dict
ModelRouter->>ModelAdmin: before_save(instance, is_create=True)
ModelAdmin-->>ModelRouter: Hook executed
ModelRouter->>Database: Add & commit instance
Database->>Session: Insert & commit
Session-->>ModelRouter: Success
ModelRouter->>ModelAdmin: after_save(instance, is_create=True)
ModelRouter-->>Client: Redirect /admin/testmodel/
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes
✨ Finishing Touches
🧪 Generate unit tests (beta)
Tip Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs). Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary by CodeRabbit
Release Notes
New Features
Documentation