Skip to content

v1 complete#1

Merged
ayahaustine merged 12 commits intomainfrom
v0.1
Feb 25, 2026
Merged

v1 complete#1
ayahaustine merged 12 commits intomainfrom
v0.1

Conversation

@ayahaustine
Copy link
Copy Markdown
Owner

@ayahaustine ayahaustine commented Feb 25, 2026

Summary by CodeRabbit

Release Notes

  • New Features

    • Internal Admin framework providing a web-based admin interface for SQLAlchemy models
    • User authentication and login system with session management
    • CRUD operations (create, read, update, delete) for registered models
    • Search and filtering capabilities for list views
    • Permission-based access control for models
    • Bootstrap 5-styled responsive UI
    • Demo applications and example implementations
  • Documentation

    • Project README with setup and usage instructions
    • Architecture and development guides
    • Contributing guidelines and testing documentation
    • MIT License included

…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
@ayahaustine ayahaustine merged commit 2cc56a3 into main Feb 25, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Feb 25, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between dc219d2 and 8b61c2c.

📒 Files selected for processing (39)
  • .gitignore
  • CHANGELOG.md
  • LICENSE
  • README.md
  • create_superuser.py
  • demo.py
  • demo_web.py
  • example.py
  • internal_admin/__init__.py
  • internal_admin/admin/__init__.py
  • internal_admin/admin/filters.py
  • internal_admin/admin/form_engine.py
  • internal_admin/admin/model_admin.py
  • internal_admin/admin/query_engine.py
  • internal_admin/admin/router_factory.py
  • internal_admin/auth/__init__.py
  • internal_admin/auth/models.py
  • internal_admin/auth/permissions.py
  • internal_admin/auth/routes.py
  • internal_admin/auth/security.py
  • internal_admin/config.py
  • internal_admin/database/__init__.py
  • internal_admin/database/engine.py
  • internal_admin/database/session.py
  • internal_admin/registry.py
  • internal_admin/site.py
  • internal_admin/static/css/admin.css
  • internal_admin/static/js/admin.js
  • internal_admin/templates/admin/confirm_delete.html
  • internal_admin/templates/admin/dashboard.html
  • internal_admin/templates/admin/form.html
  • internal_admin/templates/admin/list.html
  • internal_admin/templates/auth/login.html
  • internal_admin/templates/base.html
  • internal_admin/templates/dashboard.html
  • pyproject.toml
  • test_manual.py
  • tests/conftest.py
  • tests/test_admin.py

📝 Walkthrough

Walkthrough

This 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

Cohort / File(s) Summary
Project Configuration & Documentation
.gitignore, LICENSE, README.md, CHANGELOG.md, pyproject.toml
Standard project setup files: ignore list for documentation, MIT license, comprehensive README with installation/usage/architecture, changelog following Keep a Changelog format, and pyproject.toml with dependencies (FastAPI, SQLAlchemy, Jinja2, bcrypt, python-jose) and tool configurations.
Core Configuration & Orchestration
internal_admin/config.py, internal_admin/site.py, internal_admin/registry.py, internal_admin/__init__.py
AdminConfig dataclass with database/secret validation and environment loading; AdminSite orchestrator that registers models, initializes components (engine, session, security, templates), and mounts CRUD routes; ModelRegistry for managing model-to-admin mappings; public API exports (AdminSite, ModelAdmin, AdminConfig).
Database Management
internal_admin/database/engine.py, internal_admin/database/session.py, internal_admin/database/__init__.py
Centralized SQLAlchemy engine creation supporting SQLite and PostgreSQL with appropriate pool/connection settings; SessionManager for lifecycle management; helper functions for initialization and dependency injection in FastAPI.
Admin Components
internal_admin/admin/model_admin.py, internal_admin/admin/query_engine.py, internal_admin/admin/form_engine.py, internal_admin/admin/filters.py, internal_admin/admin/router_factory.py, internal_admin/admin/__init__.py
ModelAdmin base class with configuration (list_display, search_fields, filters, ordering, readonly fields) and lifecycle hooks; QueryEngine for building, filtering, searching, and paginating queries with pagination metadata; FormEngine for generating forms from model columns, validating/converting form data, and populating instances; FilterManager with auto-detection of filter types (FieldFilter, BooleanFilter, DateRangeFilter, ForeignKeyFilter); AdminRouterFactory generating FastAPI CRUD routers with permission checks and template rendering.
Authentication & Security
internal_admin/auth/models.py, internal_admin/auth/security.py, internal_admin/auth/permissions.py, internal_admin/auth/routes.py, internal_admin/auth/__init__.py
AdminUser SQLAlchemy model with required attributes and validation; SecurityManager for password hashing (bcrypt), JWT session tokens, and CSRF tokens; PermissionManager with role-based checks (superuser override, model/object-level permissions); auth router factory with login/logout endpoints and dependency-based authentication for FastAPI.
Frontend - Templates
internal_admin/templates/base.html, internal_admin/templates/dashboard.html, internal_admin/templates/admin/dashboard.html, internal_admin/templates/admin/list.html, internal_admin/templates/admin/form.html, internal_admin/templates/admin/confirm_delete.html, internal_admin/templates/auth/login.html
Bootstrap 5 base layout with responsive navbar/sidebar; dashboard templates showing registered models and quick actions; list template with search, filtering, pagination, empty states, and CRUD action links; dynamic form template supporting multiple field types (text, textarea, number, checkbox, select, date, datetime); delete confirmation template; login page template with error handling.
Frontend - Styling & Scripting
internal_admin/static/css/admin.css, internal_admin/static/js/admin.js
Comprehensive CSS for layout (fixed sidebar, responsive main content), form styling, tables, buttons, alerts, dark mode support, and animations; JavaScript for Bootstrap component initialization (tooltips/popovers), auto-dismiss alerts, delete confirmation dialogs, form validation, search field UI, clickable rows, textarea auto-resize, and global AdminUtils utility for common interactions.
Example & Demo Files
example.py, demo.py, demo_web.py, create_superuser.py
Production-like example with FastAPI, SQLAlchemy models (User, Category, Product), custom ModelAdmin classes with hooks and filtering, and admin registration; CLI demo script showcasing framework initialization, model registration, and configuration retrieval; web demo with no-auth override for testing without credentials; superuser creation utility with password validation and error handling.
Testing
test_manual.py, tests/conftest.py, tests/test_admin.py
Manual testing script validating framework components; comprehensive pytest fixtures (temporary database, AdminConfig, AdminSite, FastAPI app, test models, authenticated client) with test data setup; test suite covering AdminSite lifecycle, ModelAdmin configuration, authentication (login, invalid credentials), CRUD operations (list, create, edit, delete), search, filtering, and permission enforcement.

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
Loading
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
Loading
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/
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes


🐰 A framework springs forth so grand and bright,
With models, forms, and auth in sight!
Admin dashboards dance with Bootstrap grace,
While SQLAlchemy finds its rightful place.
FastAPI routes and templates blend with care—
A complete admin suite, beyond compare! 🎉

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch v0.1

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai bot mentioned this pull request Mar 4, 2026
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant