{"id":13879703,"url":"https://github.com/RailsEventStore/aggregates","last_synced_at":"2025-07-16T15:32:55.621Z","repository":{"id":38891093,"uuid":"162846853","full_name":"RailsEventStore/aggregates","owner":"RailsEventStore","description":null,"archived":false,"fork":false,"pushed_at":"2025-03-03T22:12:45.000Z","size":319,"stargazers_count":81,"open_issues_count":1,"forks_count":11,"subscribers_count":18,"default_branch":"master","last_synced_at":"2025-06-07T15:54:26.050Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/RailsEventStore.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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,"zenodo":null}},"created_at":"2018-12-22T22:31:04.000Z","updated_at":"2024-11-20T23:44:32.000Z","dependencies_parsed_at":"2023-10-20T16:52:56.596Z","dependency_job_id":"378f277f-d94f-48e2-ae1c-6e7548f1e309","html_url":"https://github.com/RailsEventStore/aggregates","commit_stats":null,"previous_names":["railseventstore/aggregates","arkency/aggregates"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/RailsEventStore/aggregates","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RailsEventStore%2Faggregates","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RailsEventStore%2Faggregates/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RailsEventStore%2Faggregates/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RailsEventStore%2Faggregates/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RailsEventStore","download_url":"https://codeload.github.com/RailsEventStore/aggregates/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RailsEventStore%2Faggregates/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265521498,"owners_count":23781522,"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":[],"created_at":"2024-08-06T08:02:29.658Z","updated_at":"2025-07-16T15:32:55.611Z","avatar_url":"https://github.com/RailsEventStore.png","language":"Ruby","readme":"# Aggregates\n\nAn experiment of different aggregate implementations. All implementations must pass same test suite: arranged with commands, asserted with events.\n\n## Experiment subject\n\nQuite typical workflow of an issue in a popular task tracking software (Jira).\n\n![workflow](https://confluence.atlassian.com/adminjiraserver072/files/828787890/828787899/1/1456788407758/JIRA+Workflow.png)\n\n## Existing experiments\n\n### Classical example\n\n[source](examples/aggregate_root)\n\n- probably most recognized implementation (appeared in [Greg Young's CQRS example](https://github.com/gregoryyoung/m-r/blob/31d315faf272182d7567a038bbe832a73b879737/SimpleCQRS/Domain.cs#L63-L96))\n- does not expose its internal state via reader methods\n- testability without persistence (just check if operation yields correct event)\n\nModule source: https://github.com/RailsEventStore/rails_event_store/tree/5378b343dbf427f5ea68f7ddfc66d6a449a6ff82/aggregate_root/lib\n\n### Aggregate with exposed queries\n\n[source](examples/query_based)\n\n- clear separation of state sourcing (with projection)\n- aggregate not aware of events\n- handler queries aggregate whether particular action is possible\n\n### Aggregate with extracted state\n\n[source](examples/extracted_state)\n\n- aggregate initialized with already sourced state\n\n### Functional aggregate\n\n[source](examples/functional)\n\n- no single aggregate, just functions that take state and return events\n\n### Polymorphic\n\n[source](examples/polymorphic)\n\n- domain classes per each state\n- no messaging in domain classes\n- no id in domain class\n- invalid state transition cared by raising exception\n\nMore: https://blog.arkency.com/make-your-ruby-code-more-modular-and-functional-with-polymorphic-aggregate-classes/\n\n### Duck typing\n\n[source](examples/duck_typing)\n\n- domain classes per each state\n- no messaging in domain classes\n- no id in domain class\n- invalid state transition cared by not having such methods on objects (duck)\n\n### Aggregate with yield\n\n[source](examples/yield_based)\n\n- yield is used to publish events (no unpublished_events in aggregate)\n- aggregate repository separated from logic\n\n### Aggregate with repository\n\n[source](examples/repository)\n\n- aggregate is unware of infrastructure\n- aggregate can built itself from events (but it could be recreated in any way)\n- aggregate keeps the state in PORO way\n- aggregate registers events aka changes\n- aggregate provides API to read registered events\n- Infrastructure (through repository in this case) is responsible for building/saving the aggregate so it could be done in any way - Event Sourcing, serialization etc\n\n### Roles/DCI\n\n[source](examples/roles)\n- better mental model by not having separate classes per state\n- one object which changes roles\n- `extend(Role.clone)` is used as Ruby ignores subsequent extend with the same module\n\n### PORO with attributes\n\n[source](examples/poro)\n\n- clear separation of state sourcing (with projection)\n- aggregate not aware of events\n- aggregate object is still responsible for holding invariants\n- no id in domain class\n\n### Decider\n\n[source](examples/decider)\n\n- clear separation of state sourcing (with projection)\n- aggregate with decider pattern\n\n### Decider with decide.rb gem\n\n[source](examples/decide.rb)\n\n- clear separation of state sourcing (with projection) with expected version\n- aggregate with decider pattern and decide.rb DSL\n- mapping between infra (RES) events and domain events used inside decider\n","funding_links":[],"categories":["Ruby"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FRailsEventStore%2Faggregates","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FRailsEventStore%2Faggregates","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FRailsEventStore%2Faggregates/lists"}