Expand description
§AllFrame Core
The Composable Rust API Framework - Protocol-agnostic routing, CQRS/ES, resilience patterns, and beautiful API documentation.
AllFrame is the first Rust web framework designed, built, and evolved exclusively through Test-Driven Development (TDD) with 450+ tests.
§Features at a Glance
| Feature | Description |
|---|---|
| 🔀 Protocol-Agnostic | Write once, expose via REST, GraphQL, and gRPC |
| 📖 Auto Documentation | Scalar UI, GraphiQL, gRPC Explorer built-in |
| 🔄 CQRS/Event Sourcing | 85% boilerplate reduction with CommandBus, Projections, Sagas |
| 🛡️ Resilience Patterns | Retry, Circuit Breaker, Rate Limiting |
| 🔒 Security Utilities | Safe logging, credential obfuscation |
| 💉 Compile-time DI | Dependency injection resolved at compile time |
| 📊 OpenTelemetry | Automatic tracing and metrics |
§Quick Start
Add to your Cargo.toml:
[dependencies]
allframe = "0.1"
tokio = { version = "1", features = ["full"] }§Basic Router Example
use allframe_core::router::{Router, RestAdapter, ProtocolAdapter};
#[tokio::main]
async fn main() {
// Create a router
let mut router = Router::new();
// Register handlers - works with any protocol!
router.register("get_users", || async {
r#"[{"id": 1, "name": "Alice"}]"#.to_string()
});
router.register("create_user", || async {
r#"{"id": 2, "name": "Bob"}"#.to_string()
});
// Expose via REST
let mut rest = RestAdapter::new();
rest.route("GET", "/users", "get_users");
rest.route("POST", "/users", "create_user");
println!("Router configured with {} handlers", 2);
}§Protocol-Agnostic Handler
use allframe_core::router::{Router, RestAdapter, GraphQLAdapter, GrpcAdapter};
// Same handler, multiple protocols!
let mut router = Router::new();
router.register("get_user", || async {
r#"{"id": 42, "name": "John"}"#.to_string()
});
// REST: GET /users/42
let mut rest = RestAdapter::new();
rest.route("GET", "/users/:id", "get_user");
// GraphQL: query { user(id: 42) { name } }
let mut graphql = GraphQLAdapter::new();
graphql.query("user", "get_user");
// gRPC: UserService.GetUser
let mut grpc = GrpcAdapter::new();
grpc.unary("UserService", "GetUser", "get_user");§Feature Flags
AllFrame uses feature flags to minimize binary size. Only enable what you need:
| Feature | Description | Default |
|---|---|---|
router | Protocol-agnostic routing | ✅ |
router-graphql | GraphQL adapter with async-graphql | ❌ |
router-grpc | gRPC adapter with tonic | ❌ |
di | Compile-time dependency injection | ✅ |
cqrs | CQRS + Event Sourcing infrastructure | ✅ |
otel | OpenTelemetry tracing | ✅ |
health | Health check endpoints | ✅ |
resilience | Retry, Circuit Breaker, Rate Limiting | ❌ |
security | Safe logging, credential obfuscation | ❌ |
§Feature Examples
# Minimal REST API
allframe = { version = "0.1", default-features = false, features = ["router"] }
# Full-stack with resilience
allframe = { version = "0.1", features = ["resilience", "security"] }
# Multi-protocol gateway
allframe = { version = "0.1", features = ["router-graphql", "router-grpc"] }§Module Overview
router- Protocol-agnostic request routing (REST, GraphQL, gRPC)shutdown- Graceful shutdown utilitiescache- Caching infrastructurecqrs- CQRS + Event Sourcing (requirescqrsfeature)resilience- Retry, Circuit Breaker, Rate Limiting (requiresresiliencefeature)security- Safe logging and credential obfuscation (requiressecurityfeature)di- Compile-time dependency injection (requiresdifeature)otel- OpenTelemetry instrumentation (requiresotelfeature)health- Health check infrastructure (requireshealthfeature)
§Examples
See the examples directory for complete working examples:
scalar_docs.rs- REST API with Scalar documentationgraphql_docs.rs- GraphQL API with GraphiQL playgroundresilience.rs- Retry, Circuit Breaker, Rate Limitinggraceful_shutdown.rs- Production shutdown handling
§Learn More
Re-exports§
pub use async_graphql;router-graphqlpub use async_graphql_parser;router-graphqlpub use async_trait;pub use backoff;resiliencepub use chrono;utilspub use dashmap;cache-memorypub use futures;router-grpcpub use governor;rate-limitpub use hyper;healthpub use moka;cache-memorypub use opentelemetry;otel-otlppub use opentelemetry_otlp;otel-otlppub use opentelemetry_sdk;otel-otlppub use parking_lot;utilspub use prometheus;metricspub use prost;router-grpcpub use prost_types;router-grpcpub use rand;utilspub use redis;cache-redispub use reqwest;http-clientpub use serde;pub use serde_json;pub use tokio;pub use tokio_stream;router-grpcpub use tonic;router-grpcpub use tonic_reflection;router-grpcpub use tracing;otelpub use tracing_opentelemetry;otel-otlppub use tracing_subscriber;otel-otlppub use url;utils
Modules§
- arch
di - Clean Architecture enforcement with compile-time dependency injection.
- auth
auth - Authentication primitives with layered feature flags.
- cache
- Cache abstraction with in-memory and Redis backends.
- cqrs
cqrs - CQRS + Event Sourcing infrastructure with 85% boilerplate reduction.
- di
di - Compile-time dependency injection infrastructure.
- grpc
router-grpc - gRPC server infrastructure with TLS support.
- health
health - Health check infrastructure for Kubernetes-ready services.
- otel
otel - OpenTelemetry automatic instrumentation for distributed tracing.
- prelude
- Prelude module for convenient imports
- resilience
resilience - Resilience patterns: Retry, Circuit Breaker, and Rate Limiting.
- router
- Protocol-agnostic request routing for REST, GraphQL, and gRPC.
- security
security - Security utilities for safe logging and credential obfuscation.
- shutdown
- Graceful shutdown utilities for production services.
Attribute Macros§
- circuit_
breaker resilience - Re-export circuit_breaker attribute macro Attribute macro for circuit breaker pattern
- rate_
limited resilience - Re-export rate_limited attribute macro Attribute macro for rate limiting
- retry
resilience - Re-export retry attribute macro Attribute macro for automatic retry with exponential backoff
Derive Macros§
- Grpc
Error router-grpc - Re-export GrpcError derive macro for automatic tonic::Status conversion Derive macro for automatic gRPC status conversion
- Health
Check di - Re-export HealthCheck derive macro for automatic health check implementation Derive macro for automatic HealthCheck implementation
- Obfuscate
security - Re-export Obfuscate derive macro for safe logging Derive macro for automatic Obfuscate implementation