Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

cargo-rustapi: The Architect

Lens: “The Architect”
Philosophy: “Scaffolding best practices from day one.”

The RustAPI CLI (cargo-rustapi) is the productivity layer on top of the framework: project scaffolding, dev server, deployment, MCP tooling, observability helpers, and RustAPI Cloud integration.

Installation

cargo install cargo-rustapi

From source (this repository):

cargo install --path crates/cargo-rustapi

Command reference

Project lifecycle

CommandDescription
cargo rustapi new <name>Create a new project
cargo rustapi new <name> --template apiREST API layout (handlers + models)
cargo rustapi new <name> --template webWeb app with rustapi-view templates
cargo rustapi new <name> --template fullDatabase, auth, Docker scaffolding
cargo rustapi new <name> --preset prod-apiProduction middleware bundle
cargo rustapi new <name> --preset ai-apiTOON + AI-oriented defaults
cargo rustapi new <name> --preset realtime-apiWebSocket defaults
cargo rustapi runRun the dev server
cargo rustapi run --reloadHot-reload via cargo-watch
cargo rustapi watchAlias for reload mode

Code generation

CommandDescription
cargo rustapi generate resource <name>Scaffold model + handlers + tests
cargo rustapi client --spec <path> --language rustClient from OpenAPI (Rust, TS, Python)
cargo rustapi migrate create <name>Create SQL migration
cargo rustapi migrate runApply pending migrations

MCP & AI agents

CommandDescription
cargo rustapi mcp generate --spec <file|url> --target <backend>OpenAPI → live MCP server
cargo rustapi mcp stdioRun MCP over stdio (Claude Desktop, Cursor)

See MCP Integration, MCP In-Process, and OpenAPI to MCP CLI.

Deployment

CommandDescription
cargo rustapi deploy dockerGenerate production Dockerfile
cargo rustapi deploy flyGenerate fly.toml
cargo rustapi deploy railwayGenerate Railway config
cargo rustapi deploy shuttleGenerate Shuttle.rs config
cargo rustapi deploy cloudDeploy to RustAPI Cloud (managed)
cargo rustapi deploy status <id>Poll cloud deploy job

Self-hosted platforms: Deployment recipe.
Managed hosting: RustAPI Cloud recipe.

RustAPI Cloud auth

CommandDescription
cargo rustapi loginDevice-code OAuth (default: https://api.rustapi.cloud)
cargo rustapi login --cloud-url <url>Point at self-hosted cloud backend
cargo rustapi login --no-browserPrint verification URL only
cargo rustapi whoamiShow logged-in user and tier
cargo rustapi logoutClear local credentials

Credentials stored at ~/.rustapi/config.json (override with RUSTAPI_CONFIG_PATH).

Operations & debugging

CommandDescription
cargo rustapi doctor [--strict]Toolchain + production signal scan
cargo rustapi observability [--check]Observability docs and feature recommendations
cargo rustapi benchRun benchmark workflow
cargo rustapi replay list -t <token>List captured replay entries
cargo rustapi replay run <id> -t <token>Replay a captured request
cargo rustapi replay diff <id> -t <token>Diff replay against target URL

See Replay recipe and Production Checklist.


Quick start

cargo rustapi new my-api --template api --preset prod-api
cd my-api
cargo rustapi run --reload

Open http://127.0.0.1:8080/docs for Swagger UI.


Cloud deploy workflow

cargo rustapi login
cargo rustapi whoami
cargo rustapi deploy cloud
cargo rustapi deploy status <deploy-id>

Backend source: github.com/Tuntii/RustAPI-Cloud


Templates

Templates enforce:

  • Modular folder structure
  • State pattern for shared resources
  • Separated error types
TemplateBest for
minimalSmallest possible main.rs
apiREST APIs
webServer-rendered HTML
fullDB + auth + Docker

Feature flag: cloud

Cloud commands require the cloud feature (default-on):

[dependencies]
cargo-rustapi = { version = "0.1.550", default-features = false }

Disabling removes login, deploy cloud, and deploy status — useful for minimal CI builds.