Skip to content
memranPublic

About

Rust-powered web engine for Lua business apps.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

Bolt

Rust-powered business web application engine.

Rust owns the infrastructure. Lua owns the business logic. You get Rust performance without a Rust rebuild for every business change.

Website · Documentation · User Guide · Developer Docs · Releases · Example App

Rust 2021 Lua 5.4 License MIT Latest release

Why Bolt?

Most web frameworks make you choose between compile-time infrastructure and fast iteration on business rules. Bolt splits them:

  • Rust handles the durable layer — HTTP, routing dispatch, templates, database access, cache, sessions, static files, logging, and runtime plumbing.
  • Lua handles the changing layer — routes, controllers, services, validation, middleware, jobs, and business workflows.

Business logic can change without rebuilding the Rust server. Lua 5.4 is embedded through mlua; no system Lua installation is required.

Features

  • Axum HTTP server with a Lua request bridge and tower-http static files.
  • Per-worker Lua VM pool — long-lived Lua runtimes, one per worker, with round-robin request dispatch.
  • Routing — GET/POST/PUT/DELETE, :param paths, named routes, and route-level middleware.
  • Database — SQLx-backed Postgres, SQLite, and MySQL/MariaDB support; raw SQL, a fluent query builder, transactions, and pagination.
  • Views — Tera templates with layouts, macros, custom filters/functions, and asset helpers.
  • Sessions and auth — server-side sessions, signed cookies, memory or SQLite stores, and Session/Auth Lua APIs.
  • Cache — in-memory or Redis/Valkey-backed shared cache.
  • Storage — file APIs for app, public, and storage directories, including multipart uploads.
  • App plumbing — validation, structured logging, in-process job queues, and scheduled tasks.
  • CLI and profiles — scaffold, run, dev reload, route inspection, migrations, and custom commands with bolt.toml, bolt.dev.toml, and bolt.bench.toml.

Performance

Bolt's hello-world benchmark suite, measured from a release build on a 12-thread desktop:

Endpoint Path Requests/sec Avg P99
Rust only /api/ping 81,708 0.6 ms 1.6 ms
Lua handler /api/ping-lua 37,178 1.3 ms 7.3 ms
Lua + view / 26,555 1.9 ms 11.1 ms
Rust + SQLite /db-rust 52,815 0.9 ms 3.7 ms
Lua + SQLite /db-lua 26,576 1.9 ms 17.0 ms
Lua + Tera /bench/template 29,682 1.7 ms 11.3 ms
Lua + cache /bench/cache 35,863 1.4 ms 7.9 ms
Lua + file I/O /bench/file 1,556 0.6 ms 1.9 ms
Static asset /assets/css/app.css 11,717 4.3 ms 8.1 ms

Method: hey over loopback, 5-second runs, 3 runs per endpoint, medians reported, 50 concurrent connections. The file route used one connection because every request shares one path.

Environment: Windows 11, Intel i5-12500 (6 cores / 12 threads), 12 workers and 12 Lua VMs, SQLite, in-memory cache, logging off, sessions skipped in benchmark mode. The load generator and server shared the same CPU, so these are single-machine, loopback numbers rather than network capacity claims. Static asset throughput reflects Windows filesystem overhead; serve static files through a CDN or reverse proxy in production.

Install

Prebuilt binaries for Linux, macOS, and Windows are published on every v* tag. No Rust toolchain or system Lua is required.

macOS / Linux

curl -fsSL https://memran.github.io/bolt/install.sh | sh

Windows (PowerShell)

irm https://memran.github.io/bolt/install.ps1 | iex

The installers place bolt in ~/.local/bin (macOS/Linux) or %LOCALAPPDATA%\Programs\bolt\bin (Windows) and verify the release checksum. Set BOLT_VERSION=v0.1.0 to pin a release, or BOLT_INSTALL_DIR to change the destination.

Then scaffold and run your first app:

bolt new myapp
cd myapp
bolt run

Open http://127.0.0.1:3000.

Build from source

Prerequisites: a Rust toolchain. No system Lua is needed.

# From the repository root
cargo install --path crates/bolt-cli

# Create and run a new app
bolt new myapp
cd myapp
bolt run

bolt new creates a plain Bolt application directory — not a Cargo crate. The bolt binary always operates on the current directory.

To run the bundled example without installing the CLI:

cd examples/hello-world
cargo run -p bolt-cli -- run

A taste of Bolt

routes/web.lua

local Home = require("app.controllers.home_controller")

Route:get("/", Home.index, "controllers.home.index")

Route:get("/api/hello/:name", function(req)
    return json({ hello = req.params.name })
end, "api.hello")

app/controllers/home_controller.lua

local Home = {}

function Home.index(req)
    return view("home.html", {
        title = "Bolt",
        message = "Rust infrastructure. Lua business logic.",
    })
end

return Home

resources/views/home.html

<h1>{{ data.title }}</h1>
<p>{{ data.message }}</p>

Architecture

Client
  │
  ▼
Axum / tower-http (Rust)
  │  static files · health · metrics · sessions
  ▼
Route registry
  │
  ▼
Lua runtime pool (Lua 5.4)
  ├── SQLx       Postgres · SQLite · MySQL
  ├── Tera       templates
  ├── Cache      memory · Redis/Valkey
  └── Storage    app · public · uploads
  │
  ▼
Response: text · JSON · HTML · view · redirect · download

Each worker owns an isolated Lua VM. Requests are distributed round-robin, so Lua globals and VM state are not shared across workers. The in-memory cache is shared within the process; use Redis or the database to share state across processes.

Workspace

Crate Responsibility
bolt Embeddable entrypoint for Bolt applications
bolt-core Configuration, logging, metrics, and shared types
bolt-http Axum server, static files, sessions, and Lua request dispatch
bolt-lua Lua runtime, globals, route registry, cache, storage, and helpers
bolt-db SQLx pool and Rust-side query builder
bolt-view Tera view engine integration
bolt-dev Filesystem watcher for dev mode
bolt-cli The bolt command-line tool

CLI

bolt new <name>          # scaffold a new app
bolt run                 # start using bolt.toml (prod)
bolt run --profile dev   # run a specific profile
bolt run --daemon        # run in the background
bolt dev                 # watch files and restart the server
bolt routes              # list registered routes
bolt check               # load config and Lua routes without serving
bolt migrate             # apply migrations/*.sql or schema.sql
bolt custom <name>       # run app/commands/<name>.lua
bolt start|stop|restart|reload

Configuration

Apps use profile files at the project root:

  • bolt.toml — production defaults
  • bolt.dev.toml — development
  • bolt.bench.toml — benchmarks
[app]
name = "myapp"
env = "prod"

[server]
host = "127.0.0.1"
port = 3000
workers = "auto"

[database]
driver = "sqlite"
url_env = "DATABASE_URL"

[session]
driver = "sqlite"
cookie_name = "bolt_session"
http_only = true
same_site = "Lax"

[views]
path = "resources/views"

[static]
prefix = "/assets"
dir = "public"

.env is loaded automatically at startup. Lua reads environment variables through Env:get("KEY"):

DATABASE_URL=storage/db.sqlite
REDIS_URL=redis://127.0.0.1:6379

Documentation

Development

cargo check
cargo test --workspace
cargo fmt --all
cargo clippy --workspace --all-targets

Tests use temporary directories and SQLite; no external database or Redis is required.

Run a single integration test:

cargo test -p bolt-lua --test api_surface route_builder_supports_middleware_chaining_and_names

Status

Bolt is at 0.1.x and under active development. The core HTTP, Lua runtime, database, view, session, cache, storage, and CLI paths are implemented and covered by tests.

License

Bolt is released under the MIT License. See LICENSE.

About

Rust-powered web engine for Lua business apps.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages