# slave-framework
The runtime behind applications created with
[slave](https://crates.io/crates/slave), a Laravel-inspired Rust framework for
MCP-first apps. You normally get it through `slave new` rather than adding it
by hand.
| `server` | `serve(router, host, port)`: an Axum server with graceful shutdown on Ctrl+C / SIGTERM |
| `env` | `.env` loading and typed settings (`var_or`, `parse_or`) |
| `logging` | `tracing` setup driven by `RUST_LOG` |
| `database` (feature `database`) | A [SurrealDB](https://surrealdb.com) connection over WebSocket (`SURREAL_URL`, default `ws://127.0.0.1:8000`; `SURREAL_NS`, `SURREAL_DB`, `SURREAL_USER`, `SURREAL_PASS`, `SURREAL_AUTH_LEVEL`), the `transaction!` macro (commit/cancel, retry on conflicts), and `migrations`: SurrealQL files applied in order, each in one transaction |
| `auth` (feature `auth`) | Passwordless sign-in: `Auth::send_code` / `verify_code` (a 6-digit code by email over SMTP, `SMTP_URL` and `MAIL_FROM`; logged in debug builds without SMTP), passkeys (WebAuthn via `webauthn-rs`, `PASSKEY_RP_ID` and `PASSKEY_ORIGIN`), and server-side sessions (`create_session`, `session`, `end_session`). Only hashes of codes and tokens are stored. Needs OpenSSL. |
| `testing` (feature `testing`) | `TestDatabase`: a fresh database per test on the SurrealDB server in `TEST_SURREAL_URL` |
`database` and `auth` are on by default. Template apps in a slave workspace use
`default-features = false`; the backend turns on `auth` and `database`, and its
tests add `testing`.
```rust
#[tokio::main]
async fn main() -> slave_framework::Result<()> {
slave_framework::env::load_dotenv()?;
slave_framework::logging::init()?;
let router = axum::Router::new();
slave_framework::server::serve(router, "127.0.0.1", 3000).await
}
```
See the [slave README](https://github.com/kewcoder/slave) for the full
framework. License: MIT.