AdminX
AdminX is a powerful, modern admin panel framework for Rust built on top of Actix Web and MongoDB. It provides a complete solution for creating administrative interfaces with minimal boilerplate code, featuring automatic CRUD operations, role-based access control, and a beautiful responsive UI.
โจ Features
๐ Core Functionality
- Zero-Config CRUD Operations - Automatic Create, Read, Update, Delete with sensible defaults
- Schema-Driven Forms - Auto-generate forms from JSON Schema using
schemars - Resource-Centric Architecture - Define resources once, get full admin interface
- Hybrid API/UI - Both REST API and web interface from same resource definitions
- Dynamic Menu Generation - Automatic navigation based on registered resources
๐ Security First
- JWT + Session Authentication - Secure token-based auth with session management
- Role-Based Access Control (RBAC) - Fine-grained permissions per resource
- Rate Limiting - Built-in protection against brute force attacks
- Timing Attack Prevention - Secure password verification
- CSRF Protection - Form-based submission security
๐จ Modern UI/UX
- Responsive Design - Mobile-first TailwindCSS-based interface
- Dark/Light Mode - Built-in theme switching
- Toast Notifications - User feedback with auto-dismiss
- Real-time Validation - Client-side form validation
- Accessibility - WCAG compliant with proper ARIA labels
๐ ๏ธ Developer Experience
- Minimal Boilerplate - Resources work out-of-the-box
- Type Safety - Full Rust type safety throughout
- Embedded Templates - Zero external dependencies
- Comprehensive Logging - Built-in tracing and debugging
- Hot Reload Support - Fast development iteration
๐ Quick Start
Add AdminX to your Cargo.toml:
[]
= "0.1.0"
= "4"
= { = "2.4", = ["tokio-runtime"] }
= { = "1", = ["full"] }
= { = "1.0", = ["derive"] }
= { = "0.8", = ["derive"] }
1. Define Your Resource
use *;
use ;
use JsonSchema;
use ;
;
2. Set up Your Application
use ;
use *;
async
3. Environment Variables
Create a .env file:
JWT_SECRET=your-super-secret-jwt-key-minimum-32-characters
SESSION_SECRET=your-session-secret-key-must-be-at-least-64-characters-long
ENVIRONMENT=development
RUST_LOG=debug
4. Run Your Application
Visit http://localhost:8080/adminx and log in with:
- Email:
admin@example.com - Password:
secure_password
๐ Documentation
Resource Customization
Advanced Configuration
// Custom middleware and advanced setup
use RoleGuardMiddleware;
new
๐ฏ Examples
Check out the examples/ directory for complete working examples:
- Basic CRUD - Simple blog with posts and users
- E-commerce Admin - Products, orders, and customers
- Multi-tenant SaaS - Organizations and user management
- Custom Authentication - OAuth integration
- File Uploads - Image and document management
๐ง Available Features
Resource Trait Methods
| Method | Purpose | Required |
|---|---|---|
resource_name() |
Display name | โ |
base_path() |
URL path segment | โ |
collection_name() |
MongoDB collection | โ |
get_collection() |
Database connection | โ |
clone_box() |
Resource cloning | โ |
permit_params() |
Allowed fields | โช |
allowed_roles() |
RBAC permissions | โช |
form_structure() |
Custom forms | โช |
list_structure() |
Table customization | โช |
custom_actions() |
Additional endpoints | โช |
Built-in Routes
Each registered resource automatically gets:
| Route | Method | Purpose |
|---|---|---|
/adminx/{resource}/list |
GET | List view (HTML) |
/adminx/{resource}/new |
GET | Create form (HTML) |
/adminx/{resource}/view/{id} |
GET | Detail view (HTML) |
/adminx/{resource}/edit/{id} |
GET | Edit form (HTML) |
/adminx/{resource}/create |
POST | Create handler |
/adminx/{resource}/update/{id} |
POST | Update handler |
/adminx/{resource} |
GET | List API (JSON) |
/adminx/{resource} |
POST | Create API (JSON) |
/adminx/{resource}/{id} |
GET | Get API (JSON) |
/adminx/{resource}/{id} |
PUT | Update API (JSON) |
/adminx/{resource}/{id} |
DELETE | Delete API (JSON) |
๐ Security
AdminX includes comprehensive security features:
Authentication & Authorization
// Role-based access control
// Fine-grained permissions
Rate Limiting
Built-in rate limiting protects against brute force attacks:
// Automatic rate limiting in auth controller
// 5 attempts per 15 minutes per email
if is_rate_limited
๐จ UI Customization
Themes and Styling
AdminX uses TailwindCSS with built-in dark mode support:
<!-- Automatic dark mode toggle in header -->
Light
Dark
Custom Templates
Override default templates by providing your own:
// Custom template helper
pub async
๐งช Testing
AdminX includes comprehensive test utilities:
๐ Performance
Database Optimization
// Automatic indexing for common queries
Caching
// Built-in response caching (optional)
๐ Deployment
Docker
FROM rust:1.75 as builder
WORKDIR /app
COPY . .
RUN cargo build --release
FROM debian:bookworm-slim
RUN apt-get update && apt-get install -y ca-certificates
COPY --from=builder /app/target/release/your-app /usr/local/bin/your-app
EXPOSE 8080
CMD ["your-app"]
Environment Variables for Production
JWT_SECRET=your-production-jwt-secret-key-32-chars-minimum
SESSION_SECRET=your-production-session-secret-64-chars-minimum
ENVIRONMENT=production
DATABASE_URL=mongodb://user:pass@mongo-server:27017/dbname
RUST_LOG=info
๐ค Contributing
We welcome contributions! Please see CONTRIBUTING.md for guidelines.
Development Setup
Running Examples
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
๐ Acknowledgments
- Built with Actix Web - Fast, powerful web framework
- UI powered by TailwindCSS - Utility-first CSS framework
- Templates with Tera - Jinja2-inspired template engine
- Database with MongoDB - Document database
- Schemas with Schemars - JSON Schema generation
๐ Support
- ๐ How it works
- ๐ Support
- ๐ Documentation
- ๐ฌ Discussions
- ๐ Issues
- ๐ง Email: sxmmaurya@gmail.com
- ๐ง Email: deepxmaurya@gmail.com
Made with โค๏ธ by the Rustacean360 Team
๐ฅ Contributors
-
Snm Maurya - Creator & Lead Developer
LinkedIn -
Deepak Maurya - Core Developer & Contributor
LinkedIn