Plate 01 · Overview
Declare a resource once. The panel checks it at mount and serves it fail-closed.
Tablo is an admin toolkit for Rust. An app declares one Resource per Toasty model; a Panel turns those declarations into list, create, edit, detail and delete pages, rendered on the server by Topcoat. There is no SPA and no client build step.
- Sheet
- tablo 0.10.0, experimental: a minor version may break the API
- Built on
- Topcoat 0.12.1 (router, views, runtime) · Toasty 0.11 (ORM) · Rust 1.99
- Extent
- 7 crates · tablo-core holds 464 source files, about 96,000 lines
- Survey
- 26 design records in docs/adr · vocabulary in CONTEXT.md
The system in one picture
Boxes contain what they own. Select any part to read what it is and where it lives. Colours follow the legend: the layer of tablo-core the part belongs to.
Three ideas that explain most of the code
A resource is a type; its settings are one value
Resource::declare() returns a ResourceDef and takes no request. Each panel builds its own copy when it mounts, so one resource type can be read-only in one panel and writable in another.
Compile time, then mount time, then the request
Typed lenses and derives turn a renamed field into a compile error. What types cannot say, the mount refuses at startup, listing every mistake. What remains is refused per request, never served under a laxer default.
One loader seam, one write tail
Every read starts from scoped_query and every record write ends in the same commit tail, commit_write. Inline cell edits, CSV import and creatable choices reuse the create and edit routes, so a check added once applies everywhere.
The smallest panel
#[derive(Debug, Clone, toasty::Model, tablo::PanelModel, tablo::ModelForm)]
pub struct Book {
#[key]
#[auto]
pub id: uuid::Uuid,
pub title: String,
}
pub struct BookResource;
impl Resource for BookResource {
type Model = Book;
type Form = BookForm; // written by ModelForm
fn declare() -> ResourceDef<Self> {
ResourceDef::new().policy(Allow) // the default policy denies everything
}
}
let mut builder = Router::builder().discover().with(db);
builder.panel(Panel::new("admin").resource::<BookResource>())?;
let router = builder.build();
PanelModel is the read side: it derives the default table and detail page from the model's fields.
ModelForm is the write side: it writes a BookForm struct that create and edit submissions parse into.
declare names what differs from the defaults. A policy is the one thing every useful resource must state, because the default is Deny.
builder.panel(..) is the mount. It checks the declarations against the database schema, registers routes and layers, and returns a PanelHandle for jobs and tests. Sign-in is on unless the panel says Auth::disabled().
The workspace
| Crate | Role | Workspace deps |
|---|---|---|
tablo | The facade an app names: tablo-core at its root, ui, testing, audit, the prelude, and the driver features (sqlite, postgresql, mysql, turso). No library crate enables a driver itself. | core, ui, test, audit |
tablo-core | Everything in the picture above: Panel, Resource, Table, Schema, policy, auth, tenancy, uploads. | macros, ui |
tablo-macros | Six derives: PanelModel, RecordForm, ModelForm, EmbeddedForm, FormInput, Options. | none |
tablo-ui | primitives/, a verbatim synced copy of topcoat-ui-registry; composites/, owned here; the control scripts and the prebuilt stylesheet. | none |
tablo-test | An in-memory HTTP client that carries cookies, CSRF, tenant and host, and waits for the mail a request leaves behind, with queries over data- hooks (rows, field_error, notification). | core |
tablo-audit | The audit log, built on the public API alone to prove an app could build it too. | core |
tablo-build | tailwind() for an app's build.rs: scans Tablo's sources, published through Cargo links metadata. | none |
Around them: examples/showcase (the runnable admin and the request-level suite over it), integration (test-local models the showcase does not reach), examples/guide (the guide's compiled snippets) and xtask (the check runner, the primitives sync and the repo guards).