RxFerrix
A reactive backend in Rust that ships as a single binary.
You write your backend as typed Rust functions. Clients subscribe to queries over a WebSocket, and their results update by themselves whenever a write changes the data they read. The database, auth, file storage, scheduler, search and an admin dashboard are built in, and the whole app, frontend included, deploys as one file plus one data directory.
- Live by default.
useQueryresults stay current. There is no cache to invalidate and no refetching to write. - Typed end to end. Rust structs are the schema, and a TypeScript API is generated from your functions.
- One file to run. SQLite is embedded. Copy the binary to a server, or use the Docker image, and start it.
- Safe to change. Deploys and schema changes happen without downtime; a version that can't read the existing data refuses to take over, and the old one keeps serving.
Documentation: https://genesysflow.github.io/rxferrix/
How it works inside, and why: Design.
Quick start
&& && &&
The new app is a Rust crate (it depends on rxferrix) with a sample tasks
table and functions in src/tasks.rs, and a web app in web/ (using
@rxferrix/react or @rxferrix/svelte). serve --dev writes the
TypeScript API to web/src/rxferrix each time it starts, so restart it after you change the functions. The admin
dashboard is at http://127.0.0.1:8090/_/: open the setup link the server prints on first start to create an
administrator.
To work on RxFerrix itself, build the TypeScript packages in a checkout (bun install && bun run build) and install
the command from it (cargo install --path crates/rxferrix-cli): apps it creates then use the checkout's crate and
packages (--published uses crates.io and npm instead, --rxferrix-path DIR another checkout).
What the code looks like
The backend: a table and the functions that use it.
// src/todos.rs
use *;
pub async
pub async
// src/main.rs
The frontend (React; Svelte works the same way):
import { useMutation, useQuery } from "@rxferrix/react";
import { api } from "./rxferrix"; // generated from the functions above
function Todos() {
const todos = useQuery(api.todos.list); // undefined while loading, then always up to date
const add = useMutation(api.todos.add);
return (
<>
<button onClick={() => add({ text: "Buy milk" })}>Add</button>
<ul>{todos?.map((t) => <li key={t._id}>{t.text}</li>)}</ul>
</>
);
}
When anyone adds a todo, every open list updates. There are three kinds of function:
| Kind | Use it to | Guarantees |
|---|---|---|
#[query] |
read data | Reactive and cached: reruns only when something it read changes. |
#[mutation] |
write data | One transaction; runs exactly once, even when a client retries after a reconnect. |
#[action] |
call the outside world (APIs, email) | Not transactional; can call queries and mutations. |
Features
Each one is explained, with examples, in the guide.
| Feature | In short |
|---|---|
| Tables and indexes | Rust structs as tables, typed index queries, pagination, #[object] types for results. |
| Auth | Passwords, magic links, OAuth (GitHub, Google, Discord, Apple, OIDC), or JWTs from Clerk, Auth0, Supabase; two-factor authentication with an authenticator app. |
| File storage | Uploads to disk or S3, thumbnails, signed and presigned URLs. |
| Scheduler and crons | Run functions later or on a schedule (time zones included), with workpools and retries. |
| Workflows | Durable multi-step functions that survive restarts, sleep for days and wait for events. |
| Search | Full-text search (stemming in 18 languages) and vector search, both reactive. |
| Live aggregates | Counts and sums per group, kept current on every write, read without a scan. |
| Environment variables | Set on the dashboard, encrypted; queries rerun when one changes. |
| Analytics | SQL over a columnar copy of the data (DuckDB), for reports and dashboards. |
| Migrations | Change a table's type and migrate documents in the background, without downtime. |
| Admin dashboard | Data, functions, logs, users, files, scheduler, migrations, backups, analytics, settings, audit log. |
Before you build something real, read Things to know: limits, caching, and what makes a query rerun.
Deploying
A RxFerrix app is one binary and one data directory (--dir, default fx_data). The details are in
the operations docs.
- Where to run it: directly (
deploy/rxferrix.servicefor systemd), in Docker (Dockerfile,deploy/docker) or on Kubernetes (deploy/k8s, written for k3s). Put it behind a reverse proxy, or let it get Let's Encrypt certificates itself with--https. - Deploys without downtime:
serve --takeoverstarts the new version next to the running one. It prepares a copy of the data with the new code (indexes, schema check) while the old one keeps serving, then switches over with a pause of well under a second and without losing a write. If the new version can't read the data, it exits and the old one keeps serving. Under systemd this issystemctl reload; with Docker,deploy/docker/deploy.sh; on Kubernetes,kubectl set image. - Backups: scheduled backups to disk or S3 (set up on the dashboard or with
--backup-every), continuous replication with point-in-time restore (--replicate-to), and restores from the dashboard. - Observability: JSON logs, Prometheus metrics (
--metrics), and the dashboard's logs and charts.
Examples
examples/todo: the todo app from above with a Svelte frontend, file uploads, search and a migration.examples/chat-react: a Slack-like chat in React with auth, pagination, uploads, search, scheduled messages, live aggregates and analytics.
Run the todo example:
&&
&&
Open http://localhost:5173 in two tabs and watch them stay in sync. todo-server functions lists the registered
functions, and todo-server codegen --out <dir> writes the TypeScript API once; todo-server --help shows every
command (backups, restores, migrations, export and import, …).
Repository layout
| Path | What |
|---|---|
crates/rxferrix |
The runtime: storage, query engine, reactivity, server, CLI, codegen, test helpers. |
crates/rxferrix-macros |
The #[table], #[query], #[mutation], #[action], #[migration], … macros. |
crates/rxferrix-cli |
The rxferrix command (rxferrix new). |
packages/client |
@rxferrix/client: the TypeScript client (sync, optimistic updates, reconnects). |
packages/react, packages/svelte |
@rxferrix/react and @rxferrix/svelte bindings. |
packages/dashboard |
The admin dashboard (Svelte), embedded in the binary at /_/. |
examples/ |
The todo and chat apps. |
deploy/ |
systemd, Docker Compose and Kubernetes files. |
docs/ |
The documentation site (VitePress): guide, operations, API contract, protocol, design. |
Development
&&
More test suites (.github/workflows/release.yml runs them in CI, except the
longer fuzzing and the three rollout scripts):
FUZZ_SCALE=20 ( && ) # dashboard e2e, after `cargo build -p todo-server`
&&
Benchmarks: cargo test --release -p rxferrix --test it bench_ -- --ignored --nocapture.
The dashboard's built files are committed, so cargo build needs no JavaScript toolchain. After changing
packages/dashboard or the client packages, run bun run build:dashboard and commit crates/rxferrix/dashboard-dist
(cargo test fails while it is out of date). cd packages/dashboard && bun run dev serves it on :5174 for UI work.
The documentation site lives in docs/ (VitePress): bun run docs:dev serves it with live reload, and
bun run docs:build builds it. A push to master that changes docs/ publishes it to GitHub Pages
(.github/workflows/docs.yml).
Releasing
The three crates and the three npm packages share one version. Set it, commit, and push a tag:
&& &&
Once the tag's CI run passes its gates, it publishes the crates to crates.io and the packages to npm (with
provenance), creates the GitHub release with the static binaries, and pushes the Docker image. A version with a
suffix (0.2.0-rc.1) goes to npm under the next tag. A version already published is skipped, so a run that
failed halfway can be rerun.
Publishing uses trusted publishing: no registry token is stored in the repository. Each crate and package names
this repository's release.yml as its trusted publisher, once:
- crates.io: for
rxferrix-macros,rxferrixandrxferrix-cli, Settings → Trusted Publishing → Add: GitHub, ownergenesysflow, repositoryrxferrix, workflowrelease.yml, no environment. - npm: for
@rxferrix/client,@rxferrix/reactand@rxferrix/svelte, Settings → Trusted Publisher → GitHub Actions: organization or usergenesysflow, repositoryrxferrix, workflow filerelease.yml, no environment.