What Floor is
What Floor gives a product, what you write, and what Floor runs for you.
Floor is an open platform for connected products. Each product is a project on Floor, and the project gets the services a product needs: a Postgres database, a key-value store, file storage, job queues, devices over MQTT, realtime channels, email and WhatsApp messages, sign-in and AI. You write the product's backend, its dashboard and its device firmware. Floor runs the rest.
This page explains the parts. To start building, go to Install, then Build your first backend.
A backend is one Rust crate
A product's backend is one Rust crate that uses the floor crate. Its files say what it does:
gate/
├── Cargo.toml floor, serde, serde_json, sqlx
├── build.rs fn main() { floor::build::generate(); }
├── src/lib.rs floor::app!();
├── src/main.rs fn main() -> std::process::ExitCode { floor::run(gate::app()) }
├── api/visits/index.rs GET /api/visits
├── api/visits/[id].rs GET /api/visits/{id}
├── api/gates/[lane]/open.rs POST /api/gates/{lane}/open
├── on/mqtt/events.rs #[mqtt("+/events")]: plate reads from the gate's devices
├── jobs/sweep.rs #[every("30s")]: close visits with a missed exit
├── permissions.rs which roles may do what
├── channels.rs realtime channels the dashboard listens to
└── db/migrations/ 0001_gate.sql …- Routes are files in
api/. The file's path is the URL path. - Triggers are files in
on/andjobs/: MQTT messages, device events, ticks, cron schedules, queue jobs. - Migrations are SQL and Rust files in
db/migrations/.
A handler is a plain async fn. It takes Cx first, the handle to the project's database and Floor's services:
// api/gates/[lane]/open.rs → POST /api/gates/{lane}/open
use floor::prelude::*;
#[post(can = "gates:open")]
pub async fn post(cx: Cx, Path(lane): Path<i64>) -> Result<Json<String>> {
let device: String = sqlx::query_scalar("select device from lanes where id = $1 and organization = $2")
.bind(lane)
.bind(cx.org()?)
.fetch_optional(cx.db())
.await?
.or_not_found()?;
let command = cx.command(&device, "open_gate", &serde_json::json!({ "lane": lane })).await?;
Ok(Json(command))
}Every route says who may call it. can = "gates:open" lets in the roles that permissions.rs allows to open gates; anyone else gets a 403 before the handler runs.
What Floor does with it
floord is Floor's server. It runs your backend as a native process and connects to it over the Floor link. Through the link, floord:
- feeds it triggers: MQTT messages on its filters, device events, ticks, cron runs and queue jobs, each delivered at least once;
- checks callers' tokens: a request's bearer token must be Floor's, unexpired, and for this project;
- answers its calls: realtime publishes, device commands, KV, queues, secrets, messages, signed file URLs and AI, always for its own project only;
- swaps versions: a new version starts next to the old one, takes over when it's ready, and the old one finishes what it was doing.
HTTP reaches the backend through Floor's gateway, on a hostname and path the project owns (gate.example.com/api).
The pieces you use
| Piece | What it is |
|---|---|
The floor crate | The framework your backend depends on. It comes from Floor's own Cargo registry |
The floor CLI | Makes backends, runs them while you edit, tests and deploys them, and manages projects |
| The console | usefloor.dev: projects, deployments, devices, logs, tokens |
| The dashboard client | A typed TypeScript client the backend writes for its dashboard, so the two can't drift |
Backends are Rust only. Dashboards and apps talk to them through the generated TypeScript client.
How a change ships
- You edit with
floor devrunning: it rebuilds and restarts the backend on every save, against a development project on Floor. floor testruns the backend's tests against a real Postgres and a fake Floor.- A push to a linked branch deploys it. Floor runs the migrations, starts the new version, waits for its health path, then switches traffic to it. A failed migration or a version that doesn't start leaves the old one serving.
See The dev loop, Testing and Deploy.