Making Rust productive for backend, AI systems, data engineering, and distributed systems.
SwordAI is more than a framework — it's a growing ecosystem of libraries and tools designed to bring both performance and productivity to backend development, AI systems, data engineering, and distributed systems in Rust.
Rust offers unmatched performance and safety, but building production systems often requires stitching together many crates with significant boilerplate. SwordAI aims to change that by providing:
- Batteries-included libraries for common backend, distributed systems, AI, and data engineering patterns
- A CLI that scaffolds production-ready projects in seconds
- Opinionated defaults that let you focus on business logic
- 🚀 REST APIs with Axum
- 🗄️ PostgreSQL with SeaORM
- 📦 Clean architecture scaffolding (controllers, services, repositories)
- 🐳 Docker-ready setup out of the box
- 🤖 AI/ML integration primitives
- 📨 Event-driven architecture (message queues, pub/sub)
- ⚙️ Background jobs and workers
- 🔌 gRPC support
- ☁️ Cloud storage integrations (S3, GCP Storage, Azure Blob)
- 📊 Observability and metrics
- 🔐 Authentication and authorization primitives
- 🔄 Distributed systems patterns
This repository contains:
crates/sword-ai- The SwordAI framework library with server configuration, database connection, and tracing utilitiescrates/sword-cli- CLI tool to generate new projects using the SwordAI framework
Download the latest release for your platform from GitHub Releases.
# Linux/macOS - move to PATH
chmod +x sword
sudo mv sword /usr/local/bin/
# Or add to your local bin
mv sword ~/.local/bin/git clone https://github.com/mattramostech/sword-ai.git
cd sword
cargo build --releaseThe binary will be available at target/release/sword.
# Interactive mode (will prompt for project name)
sword new
# With project name
sword new my-api
# Specify output directory (defaults to parent directory)
sword new my-api --out-dir /path/to/projects
# Non-interactive mode
sword new my-api --no-interactiveThe generated project includes:
my-api/
├── src/
│ ├── main.rs
│ ├── app/
│ │ ├── mod.rs
│ │ ├── routes.rs
│ │ └── controllers/
│ │ ├── mod.rs
│ │ └── users_controller.rs
│ ├── domain/
│ │ ├── mod.rs
│ │ ├── entities/
│ │ │ ├── mod.rs
│ │ │ └── user.rs
│ │ ├── services/
│ │ │ ├── mod.rs
│ │ │ └── user_service.rs
│ │ └── repositories/
│ │ ├── mod.rs
│ │ └── user_repository.rs
│ └── infrastructure/
│ ├── mod.rs
│ └── database/
│ ├── mod.rs
│ ├── models/
│ │ ├── mod.rs
│ │ └── users.rs
│ └── migration/
│ ├── mod.rs
│ └── m20220101_000001_create_user.rs
├── Cargo.toml
├── Dockerfile
├── docker-compose.yml
├── .env
└── .gitignore
-
Navigate to your project:
cd my-api -
Start PostgreSQL:
docker compose up -d db
-
Run the application (migrations run automatically):
cargo run
-
Test the endpoints:
# Create a user curl -X POST http://localhost:3000/users \ -H "Content-Type: application/json" \ -d '{"name": "John Doe", "email": "john@example.com"}' # Get a user curl http://localhost:3000/users/1
-
Run integration tests:
cargo test
The SwordAI framework provides:
- Server Setup: Pre-configured Axum server with tracing
- Database: SeaORM integration with PostgreSQL
- Migrations: Automatic database migration support
- Project Structure: Clean architecture with separation of concerns
app/- HTTP controllers and routesdomain/- Business logic, entities, services, and repository traitsinfrastructure/- Database implementations and migrationstests/- Integration tests
Generated projects include example user management endpoints:
POST /users- Create a new userGET /users/:id- Get a user by ID
To work on the SwordAI framework itself:
# Build the workspace
cargo build
# Run tests
cargo test
# Format code
cargo fmt
# Run clippy
cargo clippyWhen releasing a new version:
- Update
sword-aicrate version incrates/sword-ai/Cargo.toml - Run
cargo publish -p sword-ai - Update
SWORD_VERSIONconstant incrates/sword-cli/src/commands/new.rs - Build CLI binaries for each platform and create a GitHub Release
When contributing, if you modify the sword-ai library in a way that requires a version bump:
- Update the version in
crates/sword-ai/Cargo.toml - Update
SWORD_VERSIONincrates/sword-cli/src/commands/new.rsto match
MIT