GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ddd-4-rust
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles

This view

  • Original page
  • New address

GeezerVison is showing github.com — DDD-4-Rust

README.md

DDD-4-Rust

DDD4R Logo

面向 Rust 的领域驱动设计(DDD)基础构件库 —— 以 idiomatic Rust 重塑 DDD / CQRS / Event Sourcing

Repos Java Counterpart Ecosystem License


关于我们

DDD-4-Rust 是 partme-ai 开源生态旗下的 DDD 架构基础构件组织,专注于为 Rust 生态提供领域驱动设计(DDD)/ CQRS / 事件溯源(Event Sourcing) 的 idiomatic 基础组件。

我们的核心理念是:

让 Rust 强类型 + 所有权模型成为 DDD 的天然盟友,而非障碍。

设计原则

  • 🦀 Rust 优先 — 充分利用类型系统表达领域约束(newtype / phantom type / trait)
  • 🧩 trait-based SPI — 持久化、序列化、消息总线通过 trait 扩展,零运行时开销
  • 📐 与 Java 对齐 — 与 ddd-4-java 保持接口级对等,便于跨语言团队对照
  • ⚡ async-first — 全面拥抱 async-trait / tokio,但提供 sync fallback

构件矩阵

核心仓库

仓库 说明
ddd-4-rust DDD 基础构件 —— DomainEvent、EntityId、AggregateRoot、Repository
cqrs-4-rust CQRS 基类 —— Command、CommandExecutor、Result、View、JpaEventHandler
ddd4r DDD 开发脚手架(port of ddd4j)
ddd-cqrs-4-rust-example DDD + CQRS + Event Sourcing 完整示例(actix-web)

抽象与能力

抽象 trait 提供方
实体标识 EntityId、Identifier ddd-4-rust
聚合根 AggregateRoot、Aggregate ddd-4-rust
领域事件 DomainEvent、DomainEventEnvelope ddd-4-rust
仓储 Repository<T, ID> ddd-4-rust
命令 Command、CommandHandler<C> cqrs-4-rust
查询 Query、QueryHandler<Q, R> cqrs-4-rust
事件处理器 EventHandler<E> cqrs-4-rust
事件存储 EventStore trait cqrs-4-rust

架构概览

┌─────────────────────────────────────────────────────────────┐
│                Interfaces (axum / actix / tonic)             │
└──────────────────────────┬──────────────────────────────────┘
                           │
┌──────────────────────────▼──────────────────────────────────┐
│            Application Layer (cqrs-4-rust)                   │
│   Command · Query · Saga · Projection                       │
└──────────────────────────┬──────────────────────────────────┘
                           │
┌──────────────────────────▼──────────────────────────────────┐
│              Domain Layer (ddd-4-rust)                       │
│   Entity · AggregateRoot · DomainEvent · ValueObject         │
└──────────────────────────┬──────────────────────────────────┘
                           │
┌──────────────────────────▼──────────────────────────────────┐
│         Infrastructure Layer (trait-based SPI)               │
│   Repository · EventStore · SnapshotStore · Bus              │
└─────────────────────────────────────────────────────────────┘

快速开始

添加 ddd-4-rust 依赖

[dependencies]
ddd-4-rust = "0.1"
cqrs-4-rust = "0.1"
async-trait = "0.1"
tokio = { version = "1", features = ["full"] }

定义聚合根

use ddd_4_rust::prelude::*;

#[derive(DomainEvent)]
pub enum OrderEvent {
    Created { id: OrderId, total: Money },
    Paid    { id: OrderId, at: chrono::DateTime<Utc> },
    Shipped { id: OrderId, tracking: String },
}

#[derive(AggregateRoot)]
#[aggregate(event = OrderEvent, id = OrderId)]
pub struct Order { /* ... */ }

定义命令处理器

use cqrs_4_rust::prelude::*;

#[derive(Command)]
pub struct PlaceOrder { pub id: OrderId, pub total: Money }

#[async_trait]
impl CommandHandler<PlaceOrder> for Order {
    type Error = OrderError;

    async fn handle(&self, cmd: PlaceOrder) -> Result<Vec<OrderEvent>, Self::Error> {
        Ok(vec![OrderEvent::Created { id: cmd.id, total: cmd.total }])
    }
}

完整可运行示例:ddd-cqrs-4-rust-example


相关生态

组织 说明
🏛️ ddd-4-java Java 版本,接口级对齐
🧰 easy-4-rust 业务工具集(Rust)
🧰 easy-4-java 业务工具集(Java)
💾 rbatis-plus ORM 生态(Repository 实现层)
🧠 partme-ai 顶层 AI 智能体生态

贡献指南

欢迎贡献 DDD 基础构件!

  1. Fork 目标仓库
  2. 创建特性分支(feat/xxx 或 fix/xxx)
  3. 遵循既有 trait 设计风格
  4. 补充单元测试与领域示例
  5. 提交 Pull Request

重大设计变更请先在 Discussions 发起 RFC。


联系我们

  • Email: [email protected]
  • GitHub: github.com/ddd-4-rust

让 Rust 强类型成为 DDD 的天然盟友

Made with ❤️ by PartMe AI Team

Popular repositories Loading

  1. ddd-4-rust ddd-4-rust Public

    DDD building blocks for Rust: Event, DomainEvent, EntityId, AggregateRoot, Repository

    Rust

  2. cqrs-4-rust cqrs-4-rust Public

    CQRS base classes for Rust: Command, CommandExecutor, Result, View, JpaEventHandler

    Rust

  3. ddd-cqrs-4-rust-example ddd-cqrs-4-rust-example Public

    DDD + CQRS + Event Sourcing example in Rust with actix-web

    Rust

  4. ddd4r ddd4r Public

    Rust DDD development scaffold ported from ddd4j

    Rust

  5. .github .github Public

    🏛️ DDD architecture for Rust — Organization profile

  6. ddd-4-rust.github.io ddd-4-rust.github.io Public

    🦀 DDD architecture for Rust — organization documentation site

    TypeScript

Repositories

Loading
Type
Language
Sort
Showing 6 of 6 repositories
  • cqrs-4-rust Public

    CQRS base classes for Rust: Command, CommandExecutor, Result, View, JpaEventHandler

    Uh oh!

    There was an error while loading. Please reload this page.

    ddd-4-rust/cqrs-4-rust's past year of commit activity
    Rust 0 0 40 0 Updated Aug 12, 2026
  • ddd-4-rust Public

    DDD building blocks for Rust: Event, DomainEvent, EntityId, AggregateRoot, Repository

    Uh oh!

    There was an error while loading. Please reload this page.

    ddd-4-rust/ddd-4-rust's past year of commit activity
    Rust 0 0 0 0 Updated Aug 12, 2026
  • ddd-4-rust.github.io Public

    🦀 DDD architecture for Rust — organization documentation site

    Uh oh!

    There was an error while loading. Please reload this page.

    ddd-4-rust/ddd-4-rust.github.io's past year of commit activity
    TypeScript 0 0 0 0 Updated Aug 6, 2026
  • ddd-cqrs-4-rust-example Public

    DDD + CQRS + Event Sourcing example in Rust with actix-web

    Uh oh!

    There was an error while loading. Please reload this page.

    ddd-4-rust/ddd-cqrs-4-rust-example's past year of commit activity
    Rust 0 0 0 0 Updated Aug 3, 2026
  • .github Public

    🏛️ DDD architecture for Rust — Organization profile

    Uh oh!

    There was an error while loading. Please reload this page.

    ddd-4-rust/.github's past year of commit activity
    0 Apache-2.0 0 0 0 Updated Aug 2, 2026
  • ddd4r Public

    Rust DDD development scaffold ported from ddd4j

    Uh oh!

    There was an error while loading. Please reload this page.

    ddd-4-rust/ddd4r's past year of commit activity
    Rust 0 Apache-2.0 0 0 0 Updated Jul 24, 2026

People

This organization has no public members. You must be a member to see who’s a part of this organization.

Top languages

Loading…

Uh oh!

There was an error while loading. Please reload this page.

Most used topics

Loading…

Uh oh!

There was an error while loading. Please reload this page.

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.