Skip to content

Introduction ​

RustCMS is a Rust framework for admin panels, back-offices and headless CMS backends. You describe your data in Rust; RustCMS serves an authorized admin panel and a JSON API for it, compiled into one binary. It takes its ideas from Laravel (applications, service providers, an artisan-like console, migrations, testing helpers) and Filament (resources that describe forms, tables and actions, rendered as a complete admin panel).

The posts table of a RustCMS admin panel

RBlog, a blog built on RustCMS: the posts table.

A resource in a few lines ​

A resource names a SeaORM entity and declares which columns the panel shows and how:

rs
fn meta() -> ResourceMeta {
    ResourceMeta::new("Post")
        .title("title")
        .icon("file-text")
        .group("Content")
        .soft_deletes()
        .exportable()
        // Categories edit their posts in their form (a relationship repeater):
        // every write of a post locks its category first.
        .lock_parent("category_id", "categories")
}

fn fields() -> Vec<Field> {
    vec![
        Field::column(post::Column::Title).required().searchable().sortable().max_length(200),
        Field::column(post::Column::Body),
        Field::column(post::Column::CategoryId).belongs_to("categories").filterable(),
        Field::column(post::Column::AuthorId).guarded().readable(|_| true),
        Field::column(post::Column::Published).filterable().sortable(),
        Field::column(post::Column::PublishedAt).sortable().filterable(),
        Field::column(post::Column::Cover).media().accept(&["image/*"]).collection("post-covers"),
        // Rich text that may hold the elements declared in the admin provider.
        Field::column(post::Column::Content)
            .rich_text()
            .nodes(["app.kbd", "app.note_ref"])
            .collection("post-content"),
        Field::column(post::Column::Attributes).key_value().max_items(20).max_length(200),
    ]
}

From these declarations RustCMS builds the list (search, filters, sorting, export), validation, and the permissions posts.view_any, posts.create, … . The layout of the form (tabs, the cover picker, the rich-text and key/value editors) is declared in form():

rs
fn form() -> Form {
    Form::new().schema(components![Tabs::make().schema(components![
        Tab::make("Content").schema(components![
            TextInput::make("title").placeholder("A catchy title"),
            Textarea::make("body"),
            FileUpload::make("cover"),
            RichEditor::make("content"),
        ]),
        Tab::make("Publishing").columns(2).schema(components![
            SelectInput::make("category_id"),
            Toggle::make("published"),
            // Only for published posts: hidden (and not saved) while unpublished.
            DateTimePicker::make("published_at").shown_when(when("published").is_true()),
            // Linked from the form too, not only on the post's page.
            BelongsToManySelect::make("tags"),
        ]),
        Tab::make("Attributes").schema(components![
            KeyValue::make("attributes").help("Extra details shown with the post, e.g. reading_time = 5 min"),
        ]),
    ])])
}

Only declared fields the user may read appear in the record data the panel receives (the record's key is sent beside them), and the panel's own forms only accept declared fields the user may write. Rules can depend on the user:

rust
Field::column(post::Column::Published).updatable(|ctx| ctx.can("posts.publish"))

The post form

RBlog: a post form with publishing sections, a cover-image picker and rich text.

No Node, PHP or separate frontend is deployed: the panel is built into the binary. Start with Installation.

What you get ​

  • Admin panel: resources with lists (search, filters, sorting, row and bulk actions, count columns) and forms (sections, tabs, relationships, file uploads, rich text, key/value inputs, number bounds, inputs shown under conditions, repeaters of JSON rows or of a relation's records); view pages with infolists and computed values; soft deletes; has-many and belongs-to-many relationships; custom field widgets; dashboard widgets; CSV import and export; a media library; settings edited in the panel; users, roles and account pages, with a Roles page you can organize (Users & roles); English and Vietnamese (Languages).
  • Your own screens in the panel: custom pages and slots from HTML templates, a theme and runtime branding, React pages, JSON routes on the admin session, and realtime event streams and WebSockets.
  • Security by default: everything is denied until a permission grants it. The panel's resource operations (lists, forms, relationships, exports, actions) enforce resource and record authorization, scopes (tenancy, ownership) and the field restrictions you configure, on the server. Custom action handlers and your own API handlers write with your code: they must enforce their own field and business rules. Admin sessions with CSRF and origin checks; API tokens and JWT with immediate revocation; rate limits (Authentication).
  • Application layer: typed configuration, service providers and a container, an HTTP stack with limits on body size and time, JSON APIs where every route declares its access (Routing), validation and pagination; SQLite, PostgreSQL and MySQL; file storage on disk or S3-compatible; several instances with Redis.
  • Background work and records: queues and jobs and schedules, each with its page under System; mail; an audit log of the changes made through the panel (on by default per resource; writes from your API, jobs and services are recorded when your code records them); and encrypted columns for your secrets.
  • Tooling: rustcms new, generators (make:model, make:resource, make:api, make:page, …), rustcms serve --watch (rebuilds on changes), migrations, and a testing kit that runs every database test on SQLite, and on PostgreSQL and MySQL when RUSTCMS_TEST_PG / RUSTCMS_TEST_MYSQL name a server.

The dashboard of the admin panel

The demo application: a dashboard with a stat, a chart and the latest posts.

Coming from Laravel and Filament ​

Laravel / FilamentRustCMS
laravel newrustcms new
php artisan …rustcms … (or cargo run -- …, or your app's binary)
config/*.php + .envconfig/*.toml + .env
Service providers, containerServiceProvider (register / boot), AppBuilder::bind, Inject<T>
Routes, controllers, form requests, API resourcesApiRoutes + handlers, Validated<T>, JSON structs
Eloquent models, migrationsSeaORM entities, migrations (make:model, make:migration)
Gates, policies, Spatie permissionsGate, Policy, roles and permissions per guard
Filament resources, forms, tables, actionsResource, Form, Table, Action
Filament relation managersRelation::has_many, Relation::belongs_to_many (and BelongsToManySelect)
Filament ->visible(fn …), Repeater, infolists.shown_when(when(…)), Repeater::make(…) (.relationship(…)), infolist()
php artisan serve with a file watcherrustcms serve --watch
Filament custom pagesmake:page: an HTML template, a script or a React component
Scheduler (schedule:run)AppBuilder::schedule, run by serve
Illuminate\Testingrustcms-testing (TestApp, db_test!, factories)

Status ​

RustCMS is pre-1.0: APIs may change between minor versions; the upgrade guide lists what to change. See Limitations for what is not supported yet.

RustCMS 0.17.0 · source cfb82fa33fab · MIT OR Apache-2.0