{"id":25004350,"url":"https://github.com/sabacell/nike","last_synced_at":"2025-04-12T13:51:48.804Z","repository":{"id":41462585,"uuid":"274377651","full_name":"SabaCell/Nike","owner":"SabaCell","description":"A reactive framework for building microservice architecture solution easier","archived":false,"fork":false,"pushed_at":"2024-08-29T10:10:53.000Z","size":530,"stargazers_count":28,"open_issues_count":0,"forks_count":8,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-10T10:41:04.853Z","etag":null,"topics":["cqrs","ddd","event-sourcing","framework","microbus","microservices-architecture","netcore","nike","nuget","rabbitmq","reactive"],"latest_commit_sha":null,"homepage":"","language":"C#","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/SabaCell.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}},"created_at":"2020-06-23T10:32:52.000Z","updated_at":"2025-03-25T13:29:27.000Z","dependencies_parsed_at":"2024-08-22T20:45:09.956Z","dependency_job_id":"ea429ef5-ba55-4f08-b217-ff032efe0fcd","html_url":"https://github.com/SabaCell/Nike","commit_stats":{"total_commits":232,"total_committers":10,"mean_commits":23.2,"dds":0.7370689655172413,"last_synced_commit":"de7e4a9f151b055429bd672e88c17a4871480740"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SabaCell%2FNike","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SabaCell%2FNike/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SabaCell%2FNike/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SabaCell%2FNike/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SabaCell","download_url":"https://codeload.github.com/SabaCell/Nike/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248575794,"owners_count":21127276,"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","ddd","event-sourcing","framework","microbus","microservices-architecture","netcore","nike","nuget","rabbitmq","reactive"],"created_at":"2025-02-04T23:52:17.068Z","updated_at":"2025-04-12T13:51:48.784Z","avatar_url":"https://github.com/SabaCell.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Nike\n\nNike is a set of libraries designed to implement projects based on domain-driven design and micro-service architecture.\n\n### What concepts are covered in Nike?\n\n* [x]  Entity Framework Core\n* [x] Greg Young Event Store\n* [x] RabbitMQ\n* [x] Kafka\n* [x] Event Bus\n  * [x] RabbitMQ\n  * [ ] NServiceBus\n* [x] CQRS + Unit of Work\n  * [x] MicroBus\n  * [ ] MediatR\n* [ ] Saga\n* [ ] Open Tracing\n* [x] RESTapi Documentation Tool\n  * [x] Swagger\n  * [ ] RedDoc\n  * [ ] OpenAPI-GUI\n* [x] Caching\n  * [x] Redis\n  * [ ] NCache\n* [x] DDD\n  * [x] Event Sourcing\n  * [x] Regular (CRUD)\n* [x] Specification Pattern\n* [x] Event Aggregator Pattern\n\nBelow you can find the instruction to use each library in this project.\n\n\n## Nike Domain\n\nNike Domain provides set of base classes to implement DDD in your project. It also supports implementing **Event Sourcing** using DDD.\n\n### What concepts are included:\n* DDD\n  * Aggregate Root\n  * Entity\n  * Value Object\n  * Domain Event\n  * Enumeration\n  * Domain Exceptions\n  * Snapshot (Event Sourcing)\n * Pattern Implementations\n   * Specification\n   * Repository\n   * Unit of Work\n  * Entity Builder *\n\n### What is the Entity Builder? When to use it?\n\nSince domain model properties setters are private and cannot be public, this utility class allows you to set properties ignoring their modifier.\nThis class can is used to implement the **builder pattern** and in **test scenarios** where mocking properties are needed.\n\n### Installation\n\nInstall using NuGet:\n```\nInstall-Package Nike.Framework.Domain\n```\n\n\n\n\n\n## Nike Entity Framework\n\nThis library provides extensions to implement DDD using entity framework core.\n\n### Installation\n\nInstall using NuGet:\n```\nInstall-Package Nike.EntityFramework\n```\n\n\n\nIn case you are using ASP.NET Core, install the package below:\n\n```\nInstall-Package Nike.EntityFramework.Microsoft.DependencyInjection\n```\n\nThen use it the way shown here:\n```\nservices.AddSqlServerDatabaseContext\u003cApplicationDbContext\u003e()\n\t\t.AddEntityFrameworkDefaultRepository()\n\t\t.AddEntityFrameworkUnitOfWork()\n```\n\n\n### What are covered?\n\n* Specification Pattern Application\n* Unit of Work Implementation\n* Generic Repository + Specification Support\n* DbContext Extensions\n\n### Extensions\n\n```c#\nSetAllRelationshipDeleteBehavior(this ModelBuilder builder, DeleteBehavior deleteBehavior)\n```\n\nThis method set delete behavior of all foreign relationships\n\n\n\n```c#\nDisallowTimestampPropertiesUpdate(this ModelBuilder builder)\n```\n\nThis method will prevent the update of properties that are provided by IAuditedEntity interface.\n\n\n\n```c#\nSetTimestampsAutomatically(this DbContext dbContext)\n```\n\nThis method will automatically update the properties that are provided by IAuditedEntity interface.\n\n\n\n```c#\nOnEntityCreate(this DbContext dbContext, Action\u003cobject, EntityTrackedEventArgs\u003e callback)\n\nOnEntityUpdate(this DbContext dbContext, Action\u003cobject, EntityStateChangedEventArgs\u003e callback)\n```\n\nCallback methods on entity update and on entity create.\n\n\n\n## Nike Event Bus\n\nThis library provides abstractions to implement event bus pattern\n\n### Installation\n\nInstall using NuGet:\n\n```\nInstall-Package Nike.EventBus\n```\n\n\n\n### What are covered?\n\n* IEventBusDispatcher.cs\n\n  ```c#\n      public interface IEventBusDispatcher\n      {\n          Task PublishAsync\u003cT\u003e(T message, CancellationToken cancellationToken = default) where T : notnull, IEventBusMessage;\n          Task PublishAsync\u003cT\u003e(T message, string topic, CancellationToken cancellationToken = default) where T : notnull, IEventBusMessage;\n      }\n  ```\n\n* Unit of Work Implementation\n\n  ```c#\n      public interface IEventBusMessage\n      {\n          Dictionary\u003cstring, string\u003e TracingSpan { get; set; }\n      } \n  \n  ```\n\n\n\n**What is TracingSpan in IEventBusMessage.cs?**\n\nIt is based on the concept of [Tracing Span Extraction](https://opentracing.io/specification/). It should be set automatically by event bus provider to allow passing tracing span through event bus. \n\n\n\n## Nike Event Bus RabbitMq\n\nThis library provides implement the event bus pattern. Its implementation is based on Nike Event Bus. This library has a dependency on ASP.Net Core constructs therefore is only usable in this platform.\n\n### Installation\n\nInstall using NuGet:\n\n```\nInstall-Package Nike.EventBus.RabbitMq\n```\n\n\n\nAdd it to your ConfigureServices:\n\n```c#\nservices.AddRabbitMq(rabbitMqConnectionString)\n```\n\n\n\nAdd it to your Configure:\n\n```\napp.UseRabbitMq() \n```\n\n\n\n### What are covered?\n\n* Automatic detection of messages and message handler. It follows the practice of [Auto-Subscriber](https://github.com/EasyNetQ/EasyNetQ/wiki/Auto-Subscriber). In order to make it work you should annotate your message handlers with IConsume/IConsumeAsync interface. These classes are found on application start and are registered into DI container.\n* Automatic extraction \u0026 injection of tracing spans. Event bus dispatcher extracts current tracing span on sending messages and inject them on receiving a message. (Please read the https://opentracing.io/specification/ to understand the concepts of Injection and Extraction).\n* Eventbus dispatcher uses MessagePack which is the fastest and most memory efficient binary serialization library for .NET to Serialize/Deserialize event bus messages.\n* Eventbus dispatcher only uses type short name (e.g, OnUserOrder) for its operation not the full name.\n\n\n\n## Nike Reactive\n\nThis library provides patterns and practices that are implemented using net reactive.\n\n### Installation\n\nInstall using NuGet:\n\n```\nInstall-Package Nike.Reactive\n```\n\n\n\n### Event Aggregator Pattern\n\nAn Event Aggregator is a service which sits between your publishers and subscribers acting as an intermediary pushing your messages (events) from one entity to another. It is mainly used in WPF applications to handle communications between components. It's also used to return any result (e.g, entity id) from commands in CQRS pattern.\n\n\n\n**How to add it in ASP.Net Core application:**\n\nInstall using NuGet:\n\n```\nInstall-Package Nike.Reactive.Microsoft.DependencyInjection\n```\n\n\n\nthen add it to your ConfigureServices:\n\n```\nservices.AddEventAggregator()\n```\n\n\n\n**How to use it:**\n\nYou should inject IEventAggregator to your classes in order to use it. IEventAggregator has the following signature:\n\n```c#\n    public interface IEventAggregator : IDisposable\n    {\n        IDisposable Subscribe\u003cT\u003e(Action\u003cT\u003e action);\n        void Publish\u003cT\u003e(T @event);\n    }\n```\n\nYou may can use Publish method to publish any message with any type as intended. However in order to use the Subscribe method, you should call it before the desired message is sent.\n\n\n\n## Nike Test Utilities\n\nThis library provides utility classes that can be used in both unit and integration testing.\n\n### Installation\n\nInstall using NuGet:\n\n```\nInstall-Package Nike.TestUtilities\n```\n\n\n\n### Faker.cs\n\nThis class exposes many methods and properties to generate random data.\n\n```c#\nBuild\u003cT\u003e() // creates fake object\nRandomString\nRandomStringEnumerable\nRandomInt\nRandomFloat\nNewGuid\nRandomDecimal\n    \nand more...\n```\n\n\n\n### Verify.cs\n\nThis class is a extension to Fluent Assertions library and adds the ability to test the arguments of methods that are called (received).\n\n\n\n**How to use it: **\n\n```c#\nstring productName = \"product1\";\n\nrepository.Received(Times.Once).Add(Verify.That\u003cProduct\u003e(input =\u003e {\n    \n    input.Name.Should.Be(productName);\n    \n}));\n```\n\n\n\n## Nike MicroBus\n\nThis library provides extensions to MicroBus. It adds the ability to handle commands based on the unit of work pattern and to handle domain events without  making domain layer dependent on MicroBus.\n\n\n\n### Installation\n\nInstall using NuGet:\n\n```\nInstall-Package Nike.MicroBus\n```\n\n\n\nFor asp.net core application install the package below:\n\n```\nInstall-Package Nike.MicroBus.Microsoft.DependencyInjection\n```\n\n\n\n### Unit of Work\n\nAfter sending each command, a delegator is run in background to commit the unit of work that has occurred in command. The delegator also publishes all the domain events that have been raised.\n\n**Note:** if you are using this library, you should not commit changes yourself as it violates the unit of work pattern. For example, calling dbContext.SaveChanges().\n\n\n\n### Handling Domain Events:\n\nIn order to keep the separation of concerns, this library provides a base class to handle domain events in your application layer:\n\n\n\n```\nDomainEventHandler\u003cTDomainEvent\u003e : IDomainEventHandler\u003cTDomainEvent\u003e where TDomainEvent : IDomainEvent\n```\n\n\n\nexample:\n\n\n\n```c#\npublic class UserOrderSubmittedDomainEventHandler : DomainEventHandler\u003cUserOrderSubmittedDomainEvent\u003e {\n    public override Task HandleAsync(UserOrderSubmittedDomainEvent domainEvent){\n\n        // handle your domain event\n        \n    }\n}\n```\n\n\n\n**Note:** the handlers are automatically found on application startup.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsabacell%2Fnike","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsabacell%2Fnike","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsabacell%2Fnike/lists"}