โก Performance-equivalent to Axum (152k+ req/sec, 0.6ms latency) - Lightweight, type-safe Rust web framework with automatic TypeScript client generation for type-safe full-stack development.
โจ Key Features
Available Now
- โก Blazing Fast Performance - Matches Axum (Rust's most popular framework): 152k+ req/sec, sub-millisecond latency
- ๐ Automatic TypeScript Generation - RPC endpoints automatically generate type-safe TypeScript clients
- ๐ OpenAPI Support - Generate OpenAPI 3.0 specs from your RPC procedures for Swagger UI, Prism, and OpenAPI Generator
- ๐ Hybrid RPC Modes - Choose between REST (individual endpoints) or JSON-RPC (single endpoint) style
- ๐ง CLI Tools - Build, develop, and generate clients with the
ultimoCLI - ๐ฏ Hybrid API Design - Support both REST endpoints and type-safe RPC procedures
- ๐ก๏ธ Type Safety Everywhere - From Rust backend to TypeScript frontend
- ๐ฅ Developer Experience First - Ergonomic APIs, helpful errors, minimal boilerplate
- ๐ช Production Ready - Built-in validation, authentication, rate limiting, CORS
Coming Soon ๐ง
See the full roadmap for upcoming features:
- ๐๏ธ Database Integration (SQLx & Diesel)
- ๐ WebSocket Support
- ๐ก Streaming & SSE
- ๐ซ Session Management
- ๐งช Testing Utilities
- ๐ Multi-language Client Generation
- And more...
๐ Performance
Ultimo delivers exceptional performance, matching industry-leading frameworks:
| Framework | Throughput | Avg Latency | vs Python |
|---|---|---|---|
| Ultimo | 152k req/sec | 0.6ms | 15x faster |
| Axum (Rust) | 153k req/sec | 0.6ms | 15x faster |
| Hono (Bun) | 132k req/sec | 0.8ms | 13x faster |
| Hono (Node) | 62k req/sec | 1.6ms | 6x faster |
| FastAPI | 10k req/sec | 9.5ms | baseline |
Zero performance penalty for automatic RPC generation, OpenAPI docs, and client SDK generation.
๐ Documentation
๐ Complete documentation available at docs.ultimo.dev โ
Comprehensive guides covering:
- Getting Started & Installation
- Routing & Middleware
- RPC System & TypeScript Clients
- OpenAPI Support
- Database Integration (SQLx/Diesel)
- Testing Patterns
- CLI Tools
- And more...
๐ฏ Quick Examples
Quick Start
Simple REST API
Create a basic REST API with routes and JSON responses:
use *;
use ;
async
Test it:
# List users
# Get specific user
# Create user
1. Add Ultimo to your project
[]
= { = "./ultimo" }
= { = "1.35", = ["full"] }
= { = "1.0", = ["derive"] }
2. Create your API with RPC
Ultimo supports two RPC modes:
REST Mode (Individual Endpoints)
use *;
use RpcMode;
async
JSON-RPC Mode (Single Endpoint)
use *;
async
When to use each mode:
- REST Mode: Public APIs, HTTP caching important, clear URLs in browser DevTools
- JSON-RPC Mode: Internal APIs, simple routing, easy request batching
3. Use the generated TypeScript client
The generated client works the same way regardless of RPC mode:
import { UltimoRpcClient } from "./lib/ultimo-client";
// REST mode: client uses GET/POST to /api/getUser, /api/createUser
// JSON-RPC mode: client uses POST to /rpc with method dispatch
const client = new UltimoRpcClient(); // Uses appropriate base URL
// Same API for both modes - fully type-safe!
const user = await client.getUser({ id: 1 });
console.log(user.name); // โ
TypeScript autocomplete works!
const newUser = await client.createUser({
name: "Bob",
email: "bob@example.com",
});
4. Generate OpenAPI Specification
Automatically generate OpenAPI 3.0 specs from your RPC procedures:
use *;
use RpcMode;
let rpc = new_with_mode;
// Register procedures
rpc.query;
rpc.mutation;
// Generate OpenAPI spec
let openapi = rpc.generate_openapi;
openapi.write_to_file?;
Use with external tools:
# View in Swagger UI
# Run Prism mock server
# Generate clients in any language
๐ง CLI Tools
Install the Ultimo CLI:
Generate TypeScript Client
# Generate client from your Rust backend
# Short form
Coming Soon
๐ฆ Installation & Demo
Quick Demo
Run the included demo script to see everything in action:
This will:
- Build the Ultimo CLI
- Start the backend server (auto-generates TypeScript client)
- Test RPC endpoints
- Verify generated client
- Demonstrate CLI usage
Manual Installation
# Install CLI
# Or build manually
# Verify installation
Run Examples
# Backend with auto-generation
# Frontend
# Generate client manually
๐ Complete Workflow
Backend (Rust)
use *;
async
Frontend (TypeScript/React)
// src/lib/ultimo-client.ts - Auto-generated, don't edit!
export class UltimoRpcClient {
async listUsers(params: {}): Promise<{ users: User[]; total: number }> {
return this.call("listUsers", params);
}
}
// src/App.tsx - Use the generated client
import { UltimoRpcClient } from "./lib/ultimo-client";
import { useQuery } from "@tanstack/react-query";
const client = new UltimoRpcClient("/api/rpc");
function UserList() {
const { data } = useQuery({
queryKey: ["users"],
queryFn: () => client.listUsers({}), // โ
Fully type-safe!
});
return (
<div>
{data?.users.map((user) => (
<div key={user.id}>{user.name}</div>
))}
</div>
);
}
Development Flow
# Terminal 1: Start backend (auto-generates client)
# โ
TypeScript client generated
# Terminal 2: Start frontend
# Terminal 3: Regenerate client manually if needed
Benefits
โ
Single Source of Truth - Types defined in Rust, automatically propagate to TypeScript
โ
No Manual Typing - TypeScript types generated automatically from Rust
โ
Type Safety - Catch API mismatches at compile time
โ
Great DX - Full IDE autocomplete and type checking
โ
Zero Maintenance - Client updates automatically when backend changes
Core Philosophy
- Hybrid API Design: Support both traditional REST endpoints and RPC-style procedures
- Type Safety Everywhere: From Rust backend to TypeScript frontend with automatic type export
- Developer Experience First: Ergonomic APIs, helpful error messages, minimal boilerplate
- Production Ready: Built-in validation, authentication, rate limiting, file uploads
Tech Stack Requirements
- Runtime: Tokio for async execution
- HTTP Server: Hyper for high-performance HTTP handling
- Serialization: Serde for JSON handling
- Validation: validator crate for request validation
- File Uploads: multer for multipart form data
- Type Export: ts-rs for TypeScript type generation
- Logging: tracing for structured logging
- Testing: tokio-test for async testing utilities
Minimum Supported Rust Version (MSRV)
- Rust 1.75.0 or higher
Project Structure
ultimo-rs/
โโโ Cargo.toml (workspace)
โโโ ultimo/
โ โโโ Cargo.toml
โ โโโ src/
โ โโโ lib.rs (public API)
โ โโโ app.rs (main application)
โ โโโ context.rs (request/response context)
โ โโโ error.rs (error handling)
โ โโโ response.rs (response builder)
โ โโโ router.rs (routing engine)
โ โโโ handler.rs (handler traits)
โ โโโ middleware.rs (middleware system)
โ โโโ validation.rs (validation helpers)
โ โโโ upload.rs (file upload handling)
โ โโโ guard.rs (authentication guards)
โ โโโ rpc.rs (RPC system)
โโโ examples/
โโโ basic/
โโโ src/main.rs
Feature Requirements
1. Error Handling System
Create a comprehensive error system that returns structured JSON responses with proper HTTP status codes. Support validation errors with field-level details, authentication errors, authorization errors, and general HTTP errors.
2. Response Builder (via Context)
Provide response methods directly on Context (like Hono's c.json(), c.text(), c.html()). Support for JSON, text, HTML, redirects, custom headers, and status codes. Methods should be chainable where appropriate.
3. Request Context
Wrap incoming HTTP requests with a context object that provides:
- Easy access via
c.req.param()for path parameters c.req.query()for query parametersc.req.json(),c.req.text(),c.req.parse_body()for request bodiesc.req.header()for headersc.set()/c.get()for passing values between middleware- Response methods:
c.json(),c.text(),c.html(),c.redirect() c.status()andc.header()for setting response metadata
4. Fast Router
Implement efficient path-based routing with support for:
- Static paths (
/users) - Path parameters (
/users/:id) - Multiple parameters (
/users/:userId/posts/:postId) - HTTP method matching (GET, POST, PUT, DELETE, etc.)
5. Handler System
Create a trait-based system for request handlers that supports async functions. Handlers receive a Context and return a Result.
6. Middleware Chain
Implement composable middleware that can:
- Execute before and after handlers via
next()await point - Access and modify context with
c.set()/c.get() - Short-circuit by returning early without calling
next() - Access response after handler via
await next()then modifyc.res - Include built-in middleware for:
- Logging (request/response details)
- CORS (configurable origins, methods, headers)
- Request timing
7. Request Validation
Integrate with the validator crate to provide automatic request body validation with custom error messages. Convert validation failures into structured JSON error responses.
8. File Upload Handling
Support multipart form data parsing with:
- Automatic separation of files and text fields
- File metadata (name, size, content type)
- Easy saving to disk
- Type checking helpers (is_image, is_pdf, etc.)
9. Authentication Guards
Create a guard system for protecting routes with:
- Bearer token authentication (validate tokens from Authorization header)
- API key authentication (validate X-API-Key header)
- Custom guard implementations via trait
- Composable guards using middleware pattern
- Multiple guards execute in order (AND logic by default)
- Early return on first failure
- Can implement OR logic via custom guard composition
10. Rate Limiting
Implement rate limiting middleware with:
- Time-window based limiting (sliding window algorithm)
- Per-client tracking (identified by IP address from socket)
- Configurable limits (requests per window duration)
- In-memory storage with automatic cleanup via background task
- Returns 429 (Too Many Requests) when limit exceeded
11. RPC System
Build a type-safe RPC system where:
- Procedures have strongly-typed inputs and outputs
- Automatic JSON serialization/deserialization
- Automatic TypeScript type export (via ts-rs)
- RPC endpoints accessible at
/rpc/{procedure-name}(POST method) - TypeScript types exported to
./bindings/directory - Support for nested namespaces:
/rpc/{namespace}.{procedure}
12. Main Application
Tie everything together in an Ultimo struct that:
- Manages routes and middleware
- Starts an HTTP server
- Handles incoming requests
- Applies middleware chain
- Routes to appropriate handlers
- Returns structured error responses on failures
API Design Patterns
Simple Route Definition (Hono-style)
use *;
// GET request with JSON response
app.get;
// Path parameters
app.get;
// Query parameters
app.get;
Request Body Parsing
app.post;
Middleware Usage
use ;
// Global middleware
app.use_middleware;
app.use_middleware;
// Custom middleware
app.use_middleware;
Authentication Guards
use ;
// Protect specific routes
let auth = bearer_auth;
app.get;
// Or use as middleware for a group
app.use_middleware;
File Uploads
app.post;
RPC Procedures
app.rpc;
// Access at: POST /rpc/calculate
// TypeScript types auto-generated in ./bindings/
Sharing Data Between Middleware
// Set data in middleware
app.use_middleware;
// Access in handler
app.get;
Expected Behavior
Error Responses
All errors return JSON with structure:
Path Parameter Matching
/users/:idmatches/users/123โ{id: "123"}/users/:userId/posts/:postIdmatches/users/1/posts/2โ{userId: "1", postId: "2"}
Middleware Execution
Middleware executes in order, each can call next() to continue the chain or return early to short-circuit.
Rate Limiting
Track requests per client within a time window. Reject requests exceeding the limit with 429 (Too Many Requests) status code.
TypeScript Export
Types decorated with #[ts(export)] automatically generate .ts files in the ./bindings/ directory for frontend use.
Quality Requirements
- Type Safety: Leverage Rust's type system fully
- Async Throughout: All I/O operations must be async
- Error Handling: Use Result types, avoid panics
- Documentation: Public APIs need doc comments
- Testing: Include unit tests for core logic
- Performance: Efficient routing and minimal allocations
Success Criteria
When complete, this code should work:
async
And support curl commands like:
Implementation Guidelines
Phase 1: Core Types
- Error types and Result alias
- Response builder (used internally by Context)
- Request wrapper (HonoRequest-style)
Phase 2: Context & Router
- Context with request/response methods (c.json(), c.text(), etc.)
- Router with path matching and parameter extraction
- Handler trait for async functions
Phase 3: Middleware & App
- Middleware trait and chain execution
- Main Ultimo app struct
- HTTP server integration with Hyper
Phase 4: Features
- Built-in middleware (logger, CORS, rate limiting)
- Validation helpers
- File upload support
- Authentication guards
- RPC system with TypeScript export
Phase 5: Polish
- Comprehensive examples
- Documentation with examples
- Unit and integration tests
Design Principles
- Hono.js-inspired API: Method names and patterns match Hono.js (c.json(), c.req.param(), etc.)
- Type Safety: Leverage Rust's type system, use generics for flexibility
- Async First: All I/O operations are async, handlers return futures
- Zero Panics: Use Result types throughout, no unwrap() in library code
- Composability: Middleware and guards can be chained and combined
- Error Messages: Provide helpful, actionable error messages
- Performance: Efficient routing, minimal allocations, lazy evaluation where possible
Focus on clean abstractions and excellent developer experience. The framework should feel natural to Rust developers while being immediately familiar to those coming from Hono.js or Express.
Development
This project uses Moonrepo for monorepo management. See MOONREPO.md for detailed commands.
Quick Start:
# Install Moonrepo
|
# Install git hooks (recommended)
# Build core framework
# Run all tests
# Check code quality
# Build documentation
Git Hooks
We provide pre-commit and pre-push hooks to ensure code quality:
# Install hooks
What the hooks do:
- pre-commit: Checks code formatting with
cargo fmt - pre-push: Runs tests, clippy, and verifies coverage threshold (60%)
Testing & Coverage
The Ultimo framework maintains high test coverage standards with a custom coverage tool built for security and transparency.
Why Custom Coverage Tool?
We built ultimo-coverage instead of using external tools because:
- ๐ Security First: External tools with low GitHub adoption (< 500 stars) posed trust concerns
- ๐ฏ Project-Only Coverage: Filters out dependency code for accurate metrics
- ๐ Transparent: Simple 200-line Rust tool with only 3 dependencies
- โก Fast: Uses Rust's built-in LLVM instrumentation directly
- ๐ ๏ธ Maintainable: Full control over coverage reporting and thresholds
Quick Start
# Run tests with coverage report
# Or use make
# View HTML report (modern UI with Tailwind CSS)
Current Coverage Stats
Overall: 63.58% โ (exceeds 60% minimum threshold)
| Module | Coverage | Status |
|---|---|---|
| database/error | 100% | โ Excellent |
| validation | 95.12% | โ Excellent |
| response | 92.35% | โ Excellent |
| rpc | 85.07% | โ Excellent |
| router | 82.41% | โ Excellent |
| openapi | 76.21% | โ Good |
| context | 40.18% | โ ๏ธ Improved |
| app | 25.62% | โ ๏ธ Needs work |
Test Stats:
- 89 unit tests across all modules
- All critical paths tested
- Comprehensive middleware, RPC, and OpenAPI coverage
Coverage Standards
- โ Minimum 60% overall coverage required
- โ Core modules (router, RPC, OpenAPI) target 70%+
- โ All new features must include tests
- โ CI fails if coverage drops below threshold
Coverage Tool Details
ultimo-coverage is our custom LLVM-based coverage tool:
# How it works
# The tool:
# 1. Instruments code with LLVM coverage
# 2. Runs tests and collects profiling data
# 3. Merges .profraw files with llvm-profdata
# 4. Generates reports with llvm-cov
# 5. Filters out dependency code (.cargo/registry, .rustup)
Why it's trustworthy:
- โ Only 3 dependencies (serde, serde_json, walkdir)
- โ Uses Rust's official LLVM tools (bundled with rustc)
- โ Auditable source code (~200 lines)
- โ No network access or external data collection
- โ Generates local HTML/JSON reports only
Key Features:
- ๐ HTML report with line-by-line coverage
- ๐ JSON output for CI integration
- ๐ฏ Filters dependency coverage automatically
- ๐ Fast incremental builds
- ๐ Cross-platform (macOS, Linux, Windows)
- ๐จ Modern UI with Tailwind CSS - Beautiful, color-coded coverage visualization
For Contributors
Run tests before submitting PRs:
# Run all tests
# Check coverage
# Ensure coverage meets standards
# Overall must be โฅ60%, new code should increase coverage
Project Structure:
ultimo/- Core frameworkultimo-cli/- CLI tool for project scaffolding and TypeScript generationexamples/- Example projects demonstrating featuresdocs-site/- Documentation website (Vocs)scripts/- Development and testing scripts