|
1 | 1 | # RCommon |
2 | 2 |
|
| 3 | +Open-source .NET infrastructure library providing battle-tested abstractions for persistence, CQRS, event handling, messaging, caching, and more. Swap providers (EF Core, Dapper, MediatR, MassTransit, Wolverine, Redis) without touching your domain code. |
| 4 | + |
| 5 | +[](https://www.nuget.org/profiles/RCommon) |
| 6 | +[](LICENSE) |
| 7 | + |
3 | 8 | ## Overview |
4 | | -RCommon is a cohesive set of libraries with abstractions for widely used implementations of design patterns, and architectural patterns which are common (see what we did there?) to many applications used today. The primary goals of this toolset are: |
5 | | -1. Future proofing applications against changing architectural or infrastructure needs. |
6 | | -2. Solve common problems under the presentation layer. Presentation frameworks are something else entirely. We try to keep everything nice under the hood. Cross cutting concerns, persistence strategies, transaction management, event handling, and messaging is where we want to shine. |
7 | | -3. Code testability. We try to limit the "magic" used. Things like dependency injection are used but in a very straightforward manner. Unit tests, and integration tests should be implemented to the highest degree possible. Afterall, we want the applications you build on top of this to work :) |
8 | | -4. Last but not least - open source using permissive Apache2.0 licensing forever. |
9 | | - |
10 | | -We track bugs, enhancement requests, new feature requests, and general issues on [GitHub Issues](https://github.com/Reactor2Team/RCommon/issues "GitHub Issues") and are very responsive. General "how to" and community support should be managed on [Stack Overflow](https://stackoverflow.com/questions/tagged/rcommon "Stack Overflow"). |
11 | | - |
12 | | -## Patterns & Abstractions Utilized |
13 | | -* Specification |
14 | | -* Mediator |
15 | | -* Command Query Responsbility Segregation (CQRS) |
16 | | -* Validations |
17 | | -* Repository |
18 | | -* Unit Of Work |
19 | | -* Event Sourcing (Coming Soon) |
20 | | -* Event Bus |
21 | | -* Message Bus |
22 | | -* Caching |
23 | | -* Serialization |
24 | | -* Generic Factory |
25 | | -* Guard |
26 | | -* Data Transfer Objects (DTO) |
27 | | - |
28 | | -## Pattern Implementations |
29 | | -* Mediator: MediatR |
30 | | -* Repository: Entity Framework Core, Dapper, Linq2Db |
31 | | -* Message Bus: MassTransit, Wolverine |
32 | | -* Email: SMTP, SendGrid |
33 | | -* Validation: FluentValidation |
34 | | -* Caching: MemoryCache, Redis, Valkey |
35 | | -* Serialization: JSON.NET, System.Text.Json |
| 9 | + |
| 10 | +RCommon is a cohesive set of libraries with abstractions for widely used design patterns and architectural patterns which are common to many .NET applications. The primary goals are: |
| 11 | + |
| 12 | +1. **Future-proof** applications against changing infrastructure needs — swap providers without rewriting domain code. |
| 13 | +2. **Solve common problems** below the presentation layer: persistence, transaction management, event handling, messaging, caching, and cross-cutting concerns. |
| 14 | +3. **Code testability** — straightforward dependency injection, minimal magic, high test coverage. |
| 15 | +4. **Open source** — Apache 2.0 licensed, forever. |
| 16 | + |
| 17 | +**Targets:** .NET 8, .NET 9, .NET 10 |
| 18 | + |
| 19 | +We track bugs, enhancement requests, and feature requests on [GitHub Issues](https://github.com/RCommon-Team/RCommon/issues) and are very responsive. Community support is available on [Stack Overflow](https://stackoverflow.com/questions/tagged/rcommon). |
| 20 | + |
| 21 | +## Abstractions & Implementations |
| 22 | + |
| 23 | +| Abstraction | What It Provides | Implementations | |
| 24 | +|---|---|---| |
| 25 | +| **Persistence** | Repository pattern (`ILinqRepository`, `IGraphRepository`, `ISqlMapperRepository`, `IAggregateRepository`), Unit of Work, Specifications, Transactional Outbox/Inbox, Sagas | Entity Framework Core, Dapper, Linq2Db | |
| 26 | +| **CQRS & Mediator** | Command/Query Bus (`ICommandBus`, `IQueryBus`), Mediator (`IMediatorService`), pipeline behaviors | MediatR, Wolverine | |
| 27 | +| **Event Handling** | In-memory event bus, distributed events, transactional outbox pattern | MediatR, MassTransit, Wolverine | |
| 28 | +| **Messaging** | Message bus for distributed systems, send/publish semantics | MassTransit, Wolverine | |
| 29 | +| **Caching** | Unified read-through cache (`ICacheService`), query-level cache-aside for repositories | MemoryCache, Redis (StackExchange) | |
| 30 | +| **Blob Storage** | Container and blob CRUD, upload/download, presigned URLs, metadata, copy/move | Azure Blob Storage, Amazon S3 | |
| 31 | +| **Domain-Driven Design** | Entities, Aggregate Roots (with optimistic concurrency), Domain Events, Value Objects, Auditing, Soft Delete | Built into `RCommon.Entities` | |
| 32 | +| **Multi-Tenancy** | Tenant resolution and isolation, per-entity tenant markers | Finbuckle.MultiTenant | |
| 33 | +| **State Machines** | Finite state machines (`IStateMachine`), saga state machines | Stateless, MassTransit (Automatonymous) | |
| 34 | +| **Serialization** | Provider-agnostic JSON serialization (`IJsonSerializer`) | Newtonsoft.Json, System.Text.Json | |
| 35 | +| **Validation** | Pluggable validation pipeline (`IValidationService`) | FluentValidation | |
| 36 | +| **Email** | Unified email service (`IEmailService`) | SMTP, SendGrid | |
| 37 | +| **Security** | Current user/tenant context, principal accessors, claims-based tenant resolution | ASP.NET Core, Swagger/Swashbuckle | |
| 38 | + |
| 39 | +## Getting Started |
| 40 | + |
| 41 | +All configuration flows through a single fluent builder chain: |
| 42 | + |
| 43 | +```csharp |
| 44 | +services.AddRCommon() |
| 45 | + .WithPersistence<EFCorePerisistenceBuilder>(ef => ef |
| 46 | + .AddDbContext<MyDbContext>("MyDb", options => ...)) |
| 47 | + .WithMediator<MediatRBuilder>(mediator => mediator |
| 48 | + .AddCommand<MyCommand, MyCommandHandler>()) |
| 49 | + .WithEventHandling<MassTransitEventHandlingBuilder>(events => events |
| 50 | + .AddProducer<PublishWithMassTransitEventProducer>()) |
| 51 | + .WithCaching<MemoryCachingBuilder>() |
| 52 | + .WithSerialization<SystemTextJsonBuilder>(); |
| 53 | +``` |
| 54 | + |
| 55 | +Install only the packages you need: |
| 56 | + |
| 57 | +```bash |
| 58 | +dotnet add package RCommon.Core |
| 59 | +dotnet add package RCommon.EfCore |
| 60 | +dotnet add package RCommon.Mediatr |
| 61 | +# ... and so on |
| 62 | +``` |
36 | 63 |
|
37 | 64 | ## Documentation |
38 | | -We are maintaining and publishing our documentation at [https://docs.rcommon.com](https://docs.rcommon.com) |
| 65 | + |
| 66 | +Full documentation is available at [https://rcommon.com](https://rcommon.com/docs) |
39 | 67 |
|
40 | 68 | ## Stats |
| 69 | + |
41 | 70 |  |
0 commit comments