# π RabbitMesh - Message-Driven Microservices Framework
**Zero-port microservices with auto-generated APIs**
RabbitMesh eliminates traditional microservice complexity by using RabbitMQ for all inter-service communication. Write business logic, get REST + GraphQL APIs automatically.
## β¨ Key Features
- **π₯ Zero Port Management** - Services only connect to RabbitMQ
- **β‘ Never Blocks** - Every request spawns async task
- **π― Auto-Generated APIs** - Write service methods, get REST + GraphQL
- **π‘οΈ Production Ready** - Built-in retries, timeouts, load balancing
- **π Deploy Anywhere** - Docker, Kubernetes, bare metal
## π Quick Start
### 1. Define Your Service
```rust
use rabbitmesh_macros::{service_definition, service_method};
#[service_definition]
pub struct UserService;
impl UserService {
#[service_method("GET /users/:id")]
pub async fn get_user(user_id: u32) -> Result<User, String> {
// Your business logic only
Ok(User { id: user_id, name: "John".to_string() })
}
#[service_method("POST /users")]
pub async fn create_user(data: CreateUserRequest) -> Result<User, String> {
// Handle user creation
Ok(User { id: 1, name: data.name })
}
}
```
### 2. Start Your Service
```rust
use rabbitmesh::MicroService;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let service = MicroService::new("amqp://localhost:5672").await?;
service.start().await?; // Never blocks, handles requests concurrently
Ok(())
}
```
### 3. Auto-Generated API Gateway
```rust
use rabbitmesh_gateway::create_auto_router;
#[tokio::main]
async fn main() {
let app = create_auto_router().await;
// Automatically provides:
// GET /api/v1/user-service/users/123
// POST /api/v1/user-service/users
// GraphQL endpoint at /graphql
axum::Server::bind(&"0.0.0.0:3000".parse().unwrap())
.serve(app.into_make_service())
.await
.unwrap();
}
```
## ποΈ Architecture
```
βββββββββββββββ βββββββββββββββ βββββββββββββββββββββββββββββββββββ
β Frontend ββββββ API Gateway ββββββ Service Mesh β
β (NextJS) βHTTPβ (Auto-Gen) βAMQPβ βββββββ βββββββ βββββββ β
β β β β β βUser β βAuth β βOrderβ ... β
βββββββββββββββ βββββββββββββββ β βββββββ βββββββ βββββββ β
β β β
β βββββββββββββββ β
β β RabbitMQ β β
β β Broker β β
βββββββ΄ββββββββββββββ΄βββββββββββββ
```
## π¦ Crates
- **`rabbitmesh`** - Core microservice framework
- **`rabbitmesh-macros`** - Code generation macros
- **`rabbitmesh-gateway`** - Auto-generating API gateway
- **`examples/ecommerce`** - Complete demo application
## π― Why RabbitMesh?
| β Port management hell | β
Zero ports to manage |
| β Manual load balancing | β
Automatic via RabbitMQ |
| β Service discovery complexity | β
Auto-discovery via queues |
| β Blocking request handlers | β
Every request is async |
| β Manual API development | β
Auto-generated REST + GraphQL |
## π Performance
- **Latency**: 3-10ms (vs 1-5ms HTTP direct)
- **Throughput**: Higher than HTTP (persistent connections)
- **Concurrency**: Unlimited (every request = async task)
- **Scalability**: Linear (add instances = proportional capacity)
## π Getting Started
See the [examples/ecommerce](examples/ecommerce) directory for a complete microservices demo with user management, authentication, and API gateway.
## π License
MIT license