System Architecture
Relevant source files
The following files were used as context for generating this wiki page:
The SeaORM Pro system architecture is designed as a full-stack admin panel framework that bridges database entities with a professional management interface. It leverages a configuration-driven approach where the layout, tables, and dashboards are defined in TOML files and served via a Rust backend, typically built using frameworks like Axum or Loco.rs.
The core architecture consists of three primary layers: the configuration layer (TOML-based), the service layer (Rust backend with SeaORM and Seaography), and the presentation layer (Admin Frontend). The system automates the generation of GraphQL endpoints for data manipulation and provides a structured way to define complex data relationships through "Composite Tables."
Sources: README.md:14-16, sea-orm-pro/src/config.rs:7-19
Core Components and Modules
The system is partitioned into several key modules that handle configuration parsing, database interaction, and API exposure.
Configuration Engine
The ConfigParser is responsible for loading the system's state from the filesystem. It aggregates site-wide settings, dashboard layouts, and table definitions into a unified JsonCfg structure.
The parser traverses specific directories to build the admin panel's metadata.
Sources: sea-orm-pro/src/parser.rs:13-48
API and Routing Layer
The backend exposes specific endpoints to facilitate admin panel operations. In an Axum-based implementation, this includes routes for configuration fetching, authentication, and GraphQL execution.
| Endpoint | Method | Description |
|---|---|---|
/api/admin/config | GET | Returns the parsed JsonCfg for frontend rendering |
/api/admin/dashboard | POST | Returns specific graph data (line, pie) based on query parameters |
/api/graphql | POST | Main entry point for Seaography-generated data operations |
/admin | GET | Serves the static assets for the admin frontend |
Sources: examples/axum_example/api/src/lib.rs:55-75, src/controllers/admin.rs:163-172
Data Flow and GraphQL Integration
SeaORM Pro utilizes Seaography to dynamically generate a GraphQL schema based on SeaORM entities. This allows the admin panel to perform CRUD operations without manually defining every API endpoint.
A specialized Readonly extension can be injected into the GraphQL pipeline to restrict mutations in demo environments.
Sources: src/graphql/query_root.rs:32-45, examples/axum_example/api/src/lib.rs:242-257
Dashboard and Analytics System
The dashboard is structured into rows and columns using a grid system. Each column can contain an "Info Card" or a "Chart."
Chart Data Processing
The backend handles complex SQL aggregations for dashboard components. For example, it calculates "New Customers By Month" or "Sales Value" by performing database-specific date formatting (e.g., STRFTIME for SQLite, DATE_FORMAT for MySQL).
Configuration Schema
The system is highly customizable via the SiteCfg and RawTableCfg structures. These define the visual appearance and behavioral constraints of the admin interface.
Table Configuration Features
- Raw Tables: Map directly to database entities with control over hidden columns and pagination.
- Composite Tables: Define Parent-Child relationships (e.g.,
SalesOrderHeaderas parent andSalesOrderDetailas child), allowing nested management within a single view. - RBAC: A boolean toggle in
RbacCfgdetermines if Role-Based Access Control logic is applied.
Sources: sea-orm-pro/src/config.rs:88-100, pro_admin/composite_tables/sales_order.toml:1-15
Summary
The SeaORM Pro architecture centers on a configuration-as-code philosophy. By using TOML files to define the administrative domain model, it decouples the UI layout from the underlying database schema. The backend acts as a coordinator, providing a GraphQL interface via Seaography and specialized REST endpoints for dashboard analytics and metadata retrieval. This structure enables rapid deployment of admin interfaces that are both flexible and typed via Rust's safety guarantees.
Sources: sea-orm-pro/src/lib.rs, sea-orm-pro/src/parser.rs:51-66