{"id":17077088,"url":"https://github.com/andreapavoni/mini_cqrs_es","last_synced_at":"2025-04-12T20:22:14.123Z","repository":{"id":185794109,"uuid":"615542462","full_name":"andreapavoni/mini_cqrs_es","owner":"andreapavoni","description":"Simple, minimal, opinionated building blocks to implement CQRS/ES in Rust","archived":false,"fork":false,"pushed_at":"2025-04-02T20:20:06.000Z","size":116,"stargazers_count":9,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-02T21:27:10.974Z","etag":null,"topics":["cqrs","cqrs-es","ddd","event-sourcing","microframework","rust-lang"],"latest_commit_sha":null,"homepage":"https://crates.io/crates/mini_cqrs_es","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/andreapavoni.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-03-18T00:15:00.000Z","updated_at":"2025-04-02T20:20:10.000Z","dependencies_parsed_at":"2025-04-02T21:24:18.748Z","dependency_job_id":"89825c83-96e8-43ff-8695-d13c97e48942","html_url":"https://github.com/andreapavoni/mini_cqrs_es","commit_stats":null,"previous_names":["andreapavoni/mini_cqrs","andreapavoni/mini_cqrs_es"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andreapavoni%2Fmini_cqrs_es","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andreapavoni%2Fmini_cqrs_es/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andreapavoni%2Fmini_cqrs_es/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andreapavoni%2Fmini_cqrs_es/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/andreapavoni","download_url":"https://codeload.github.com/andreapavoni/mini_cqrs_es/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248626385,"owners_count":21135654,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cqrs","cqrs-es","ddd","event-sourcing","microframework","rust-lang"],"created_at":"2024-10-14T12:12:20.846Z","updated_at":"2025-04-12T20:22:14.090Z","avatar_url":"https://github.com/andreapavoni.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MiniCQRS/ES - Simplifying CQRS for Rust\n\nSimple, minimal, opinionated micro-framework to implement CQRS/ES in Rust. There are already a lot of opinionated libraries to do that but, in fact, I didn't agree with their\nopinions and I've seen an opportunity to improve my knowledge and practice with Rust.\n\nThis lightweight library offers the necessary components abstractions and minimal glue to streamline the implementation of CQRS architecture, making it a breeze to manage your application's data flow.\n\n## Features\n\n- It's a microframework, so _micro_ that you mostly get only the _frame_, the _work_ is on you:\n  - you write your own implementations;\n  - you chose the libraries, storage engines and other external tools;\n  - you can pick only the pieces you need (aggregate, command, events, queries, etc...).\n\n- Almost everything is async using Tokio runtime.\n\n### Architecture\n\n- **Aggregates:** Define your domain entities as aggregates, handle state changes, and apply events with straightforward traits.\n\n- **Commands:** Implement custom commands to change the state of your aggregates with minimal effort.\n\n- **Event Store:** Store and retrieve your events efficiently for seamless event-sourcing.\n\n- **Snapshot Store:** Optionally use snapshots to speed up aggregate state recovery.\n\n- **Event Handling:** Easily manage and consume events generated by your aggregates, to execute actions and real-time updates.\n\n- **Queries:** Implement custom queries to retrieve data from your read models.\n\n## Status\n\nThe library is somewhat usable for experimenting on some real use cases, but I wouldn't recommend\nit for production use yet, API can't be considered stable, hence it's still **under active development, sudden breaking changes can be introduced**.\n\n## Installation\n\nRun the following Cargo command in your project directory:\n\n```sh\ncargo add mini_cqrs_es\n```\n\nOr add the following line to your `Cargo.toml`:\n\n```toml\n[dependencies]\nmini_cqrs_es = \"0.7.0\"\n```\n\n## Usage\n\nOnce you have added the library to your project's dependencies, you can start using it by importing the library:\n\n```\nuse mini_cqrs_es::*;\n// or importing single components:\n// use mini_cqrs_es::{Aggregate, etc...};\n```\n\nBeing made almost entirely of traits, MiniCQRS/ES is very flexible but, of course,\nit also requires some boilerplate. For this reason, you can check out the\n[examples directory](https://github.com/andreapavoni/mini_cqrs_es/tree/master/examples) for more details.\n\nWhen you have implemented the various traits from the library, you can finally build your CQRS architecture.\n\nHere's a snippet inspired by the [game example](https://github.com/andreapavoni/mini_cqrs_es/tree/master/examples/game.rs):\n\n```rust\n// An implementation of the EvenStore trait\nlet event_store = InMemoryEventStore::new();\n// An implementation of the SnapshotStore trait\nlet snapshot_store = InMemorySnapshotStore::\u003cGameAggregate\u003e::new();\n// An AggregateManager that supports the SnapshotStore is already implemented by MiniCQRS/ES\nlet aggregate_manager = SnapshotAggregateManager::new(snapshot_store);\n// An implementation of the Repository trait to handle read models\nlet repo = Arc::new(Mutex::new(InMemoryRepository::new()));\n// A set of event consumers\nlet event_consumers = GameEventConsumersGroup {\n    main: GameMainConsumer::new(repo.clone()),\n    print: PrintEventConsumer {},\n};\n\n// The Cqrs type is provided by MiniCQRS/ES and wraps the previous components\nlet mut cqrs = Cqrs::new(aggregate_manager, event_store, event_consumers);\n\n// Build a Command along with some arguments\nlet player_1 = Player { id: \"player_1\".to_string(), points: 0, };\nlet player_2 = Player { id: \"player_2\".to_string(), points: 0, };\nlet aggregate_id = Uuid::new_v4();\n// every Command implementation knows the type of the target Aggregate\nlet cmd = CmdStartGame { player_1: player_1, player_2: player_2, goal: 3, };\n\n// Execute the Command \ncqrs.execute(aggregate_id, \u0026cmd).await?;\n\n// Query the read model\n// every Query implementation can have its own shape, initialization logic and read model type as output\nlet query = GetGameQuery::new(aggregate_id, repo.clone());\nlet result = cqrs.query(\u0026query).await?.unwrap();\n```\n\nPlease note that, except for the `Cqrs` and `SnapshotAggregateManager` types, everything else is an implementation of some trait.\nIn particular, the `InMemory*` types have been implemented to simulate _storage_. In a real use case scenario you will probably build wrappers around\nsome database clients or other storage solutions.\n\n## Documentation\n\nCode is documented and is being improved whenever is needed. To see a complete implementation you can check the\n[examples](https://github.com/andreapavoni/mini_cqrs_es/tree/master/examples).\n\n## Testing\n\nConsidering that this library is made of traits, the only way to check they work is to run the examples.\n\n## Contributing\n\nIf you find any bugs or have any suggestions, please [open an issue](https://github.com/andreapavoni/mini_cqrs_es/issues).\n\n## License\n\nThis project is open-source and available under the [MIT License](LICENSE).\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandreapavoni%2Fmini_cqrs_es","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandreapavoni%2Fmini_cqrs_es","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandreapavoni%2Fmini_cqrs_es/lists"}