Pro Admin Panel
Relevant source files
The following files were used as context for generating this wiki page:
The Pro Admin Panel is a full-stack framework integrated with SeaORM, designed to allow developers to rapidly launch professional administration interfaces for their applications. It operates by parsing TOML configuration files to define the site structure, dashboard visuals, and data table behaviors, significantly reducing the need for manual frontend development.
Sources: README.md:1-5, sea-orm-pro/README.md:1-5
The system acts as a helper layer for SeaORM, providing a standardized API for the frontend (based on Ant Design Pro) to consume. It supports multiple database backends including SQLite, MySQL, and PostgreSQL, and features built-in support for GraphQL via Seaography.
Sources: README.md:10-18, Cargo.toml:44-48, pro_admin_frontend/README.md:1-3
System Architecture and Data Flow
The Pro Admin Panel architecture consists of a Rust backend that serves as a configuration provider and a data API. The backend parses local TOML files to build a JsonCfg object, which describes the entire UI layout and capabilities to the frontend.
The diagram above illustrates how TOML configurations and database entities are transformed into a functional UI through the Admin Controller and GraphQL layers.
Sources: sea-orm-pro/src/parser.rs:11-44, src/controllers/admin.rs:136-146, examples/axum_example/api/src/lib.rs:55-75
Config Parsing Logic
The ConfigParser is responsible for loading configurations from a designated root folder (usually pro_admin). It performs a walk of the directory to aggregate raw table and composite table definitions into a unified configuration object.
Sources: sea-orm-pro/src/parser.rs:15-44, src/controllers/admin.rs:13-15
Configuration Structure
The admin panel is driven by a hierarchical configuration model defined in sea-orm-pro/src/config.rs. This model is split into several key components:
Site and Theme Configuration
Defines the visual identity of the panel, including the title, logo, and login banner, as well as navigation features like the GraphQL playground toggle.
| Field | Type | Description |
|---|---|---|
site.theme.title | String | The display name of the admin panel. |
site.theme.logo | String | Path or URL to the panel logo. |
site.navbar.graphql_playground | Boolean | Whether to show the GraphQL interface link. |
site.rbac.enable | Boolean | Controls if Role-Based Access Control is active. |
Sources: sea-orm-pro/src/config.rs:20-66, pro_admin/config.toml:1-12
Dashboard and Charts
The dashboard is composed of info cards and rows of charts. Charts are identified by unique keys that the backend uses to fetch aggregated data.
Sources: sea-orm-pro/src/config.rs:80-117, pro_admin/dashboard.toml:1-85
Sources: sea-orm-pro/src/config.rs:80-106
Data Management
Raw and Composite Tables
The panel distinguishes between simple "Raw Tables" (direct entity mapping) and "Composite Tables" (parent-child relationships).
- Raw Tables: Defined with
RawTableCfg, allowing configuration for filtering, sorting, and CRUD permissions. - Composite Tables: Defined with a
parenttable and multiplechildrenrelations, enabling complex views like Sales Orders with line items.
Sources: sea-orm-pro/src/config.rs:120-145, pro_admin/composite_tables/sales_order.toml:1-100
API Endpoints
The backend provides specific routes for the admin panel under the /admin prefix (or /api/admin in some implementations).
| Endpoint | Method | Purpose |
|---|---|---|
/admin/config | GET | Returns the full JsonCfg for UI rendering. |
/admin/dashboard | POST | Returns data points for dashboard charts based on a date range. |
/api/graphql | POST | Handles complex data queries and mutations. |
Sources: src/controllers/admin.rs:136-146, examples/axum_example/api/src/lib.rs:60-65
Dashboard Data Flow
When the frontend renders a chart, it sends a DashboardBody to the backend. The backend matches the graph string to a specific SQL query, often involving time-based casting and aggregation.
Sources: src/controllers/admin.rs:46-110
The backend utilizes helper functions like cast_as_year_month and cast_as_day to handle database-specific SQL dialects (MySQL, Postgres, SQLite) for date formatting during these queries.
Sources: src/controllers/admin.rs:113-134
Security and Authentication
The panel includes a demonstration authentication flow. In the provided examples, a JWT is required for dashboard data, and a specific check_user_auth helper verifies tokens for current user info and GraphQL operations.
Sources: examples/axum_example/api/src/lib.rs:188-210, src/controllers/admin.rs:47
Summary
The Pro Admin Panel serves as a configuration-driven interface for SeaORM-based applications. By leveraging TOML files to define metadata and the Admin Controller to provide both structural configuration and aggregated data, it enables the creation of complex admin interfaces with minimal manual coding. It integrates deeply with Seaography for GraphQL capabilities and supports flexible deployment through its multi-database backend compatibility.