Introduction to SeaORM Pro
Relevant source files
The following files were used as context for generating this wiki page:
SeaORM Pro is a full-stack framework and admin panel solution designed to rapidly deploy administrative interfaces for Rust applications. It leverages SeaORM for database interactions and integrates with the Loco.rs framework to provide a pre-built backend, while the frontend is based on Ant Design Pro. The system allows developers to launch professional admin panels without requiring extensive frontend development skills.
Sources: README.md:1-10, pro_admin/dashboard.toml:11-14, pro_admin_frontend/README.md:1-3
System Architecture
The project is structured as a workspace containing a helper library (sea-orm-pro), a backend service, and configuration modules. The backend serves as the bridge between the database (supporting SQLite, MySQL, and PostgreSQL) and the administrative frontend.
Core Components
| Component | Description |
|---|---|
sea-orm-pro | A helper library providing configuration parsing and data structures for the admin panel. |
| Admin Frontend | A pre-compiled asset set based on Ant Design Pro, served by the backend. |
| Loco.rs Backend | The server-side framework managing routing, authentication, and database migrations. |
| Configuration | TOML-based files defining the dashboard layout, raw tables, and composite views. |
Sources: sea-orm-pro/Cargo.toml:1-25, Cargo.toml:1-10, README.md:50-60, pro_admin_frontend/README.md:1-5
Data Flow Overview
The following diagram illustrates how configuration files are parsed and served to the frontend via the API layer.
The ConfigParser reads .toml files from a specific directory (typically pro_admin) and converts them into a JsonCfg structure used by the frontend to render the UI dynamically.
Sources: sea-orm-pro/src/parser.rs:14-50, examples/axum_example/api/src/lib.rs:252-257
Configuration and Customization
SeaORM Pro utilizes a file-based configuration system located in the pro_admin directory to define the visual and functional aspects of the admin panel.
Site and Theme Configuration
General settings such as the panel title, logo, and login banner are managed in config.toml.
| Field | Description | Source |
|---|---|---|
site.theme.title | The display title of the admin panel. | pro_admin/config.toml:3 |
site.theme.logo | Path to the favicon or logo icon. | pro_admin/config.toml:5 |
site.navbar.graphql_playground | Boolean toggle for the GraphQL interface button. | pro_admin/config.toml:10 |
Dashboard Layout
The dashboard is defined in dashboard.toml using info cards and charts organized into rows and columns.
[[row.col]]
span = 12
title = "New Customers By Month"
[row.col.chart]
chart = "new_customer_by_month"
kind = "line"
timescale = "month"
Sources: pro_admin/dashboard.toml:35-45
Composite Tables
Composite tables allow for complex views that link parent and child entities, defining which columns are visible and which CRUD operations are enabled.
Setup and Development Workflow
The development lifecycle involves database initialization, asset acquisition, and entity generation.
- Database Initialization: Uses
.envforDATABASE_URLandcargo run task seed_datato populate tables from CSV/TSV sources. - Frontend Assets: Assets are downloaded via a shell script:
sh build_tools/download_frontend.sh. - Entity Generation: Custom entities are generated using
sea-orm-cliwith the--seaographyflag to ensure GraphQL compatibility.
Sources: README.md:12-45, src/tasks/seed.rs:35-80
Database Connectivity
The project supports multiple backends via Cargo features:
sqlx-sqlite(Default)sqlx-mysqlsqlx-postgres
Sources: Cargo.toml:52-56, README.md:20-25
API and Integration
The backend provides several key endpoints for the admin panel's operation:
GET /api/admin/config: Returns the parsed TOML configurations as JSON.POST /api/auth/login: Handles administrative authentication.POST /api/graphql: Main data entry point for CRUD operations using Seaography.
Sources: examples/axum_example/api/src/lib.rs:55-70, src/graphql/query_root.rs:33-45
GraphQL Integration
The system uses seaography to automatically derive GraphQL schemas from SeaORM entities. In demo modes, a Readonly extension is applied to the GraphQL factory to prevent mutations.
Sources: src/graphql/query_root.rs:50-80
Summary
SeaORM Pro provides a robust, configuration-driven approach to building administrative interfaces in Rust. By combining the power of SeaORM and Seaography with a standardized configuration format, it enables rapid development and deployment of full-featured admin panels with minimal boilerplate.
Sources: README.md:1-5, sea-orm-pro/README.md:1-5