# π¦
buzzard
> A lightweight, DDD-first message bus framework for Rust β orchestrate commands, events, and projections with confidence.
---
**buzzard** is a strongly typed, domain-driven orchestration framework for message-based applications in Rust. Inspired by hexagonal and DDD patterns, it lets you model business flows with explicit **Command**, **Event**, and **Projection** types while remaining infrastructure-agnostic.
---
## β¨ Features
- π§ Domain-driven: Clean separation of Commands, Events, and Projections
- π Fully asynchronous and `Send + Sync + Clone` safe
- π¦ Broker-agnostic (`Redis`, `Postgres`, `NATS`, etc.)
- π§± Extensible via `MessageBusDriver`, `CommandHandler`, `Policy`, and `Projector`
- π Easy to integrate into web servers, CLI apps, and background workers
---
## π¦ Quickstart Example
```rust
#[tokio::main]
async fn main() -> Result<()> {
let driver = MyDriver::init().await?;
let bus = MessageBus::from(&driver);
// Run bus in the background
let background = tokio::spawn(bus.clone().start());
// Dispatch a command from a web handler, CLI, etc.
let cmd = MyCommand { sku: "ABC-123".into() };
let response = bus.dispatch(cmd).await?;
background.await??;
Ok(())
}
```
---
## π§ Message Flow
ββββββββββββββββββββββββββ
β Message Bus β
ββββββββββββββ¬ββββββββββββ
β
ββββββββββββββββββββββββββββββββββΌβββββββββββββββββββββββββββββββββ
β β β
βΌ βΌ βΌ
βββββββββββββββββ βββββββββββββββββββββββ ββββββββββββββββββββββ
β Command Msg β β Event Msg β β Projection Msg β
ββββββββ¬βββββββββ βββββββββββ¬ββββββββββββ ββββββββββββ¬ββββββββββ
β β β
βΌ βΌ βΌ
βββββββββββββββββ ββββββββββββββββββββββ ββββββββββββββββββββββββββ
β CommandHandlerβ β Policy β β Projector β
ββββββββ¬βββββββββ ββββββββββ¬ββββββββββββ βββββββββββββ¬βββββββββββββ
β domain mutation β maps event to side effects β
βΌ βΌ β
ββββββββββββββββββββββ ββββββββββββββββββββββββββββββ β
β UnitOfWork β β Vec<SideEffect<Cmd, Proj>> β β
β - apply mutations β βββββββββββββββ¬βββββββββββββββ β
β - capture events β β β
β - commit/rollback β β β
βββββββββββ¬βββββββββββ β β
β commits β publishes β
βΌ βΌ βΌ
ββββββββββββββββ ββββββββββββββββββββββββββββββ βββββββββββββββββββββββββββββββ
β Event Msg(s) βββββββββΊβ Message Bus (loopback) β β Projection Msgs from Policy β
ββββββββββββββββ ββββββββββββββββββββββββββββββ βββββββββββββββββββββββββββββββ
---
## π Traits You Implement
| `MessageBusDriver`| Declares domain types + infrastructure |
| `CommandHandler` | Executes domain logic with mutation |
| `Policy` | Reacts to events with follow-up messages |
| `Projector` | Handles read model and infra updates |
---
## π Lifecycle Summary
1. `dispatch(command)` β handled in `UnitOfWork`
2. Domain events are emitted and published
3. Events trigger `Policy` logic β follow-up messages
4. Messages include new commands or projections
5. Projections handled by external-side `Projector`
---
## β
When to Use
- You want a clean, extensible message-processing runtime
- You use DDD / CQRS and want to model each message explicitly
- You want to test your business logic independently of infrastructure
---
## π Built With
- `futures`, `anyhow`
- Your backend: PostgreSQL, Redis, NATS, MeiliSearch...