Code Monkey home page Code Monkey logo

rcommon-team / rcommon Goto Github PK

View Code? Open in Web Editor NEW
10.0 3.0 3.0 7.98 MB

A cohesive set of .NET 6, 7, 8+ infrastructure libraries that utilizes abstractions for persistence, unit of work/transactions, distributed event handling, CQRS, and more.

Home Page: https://rcommon.com

License: Apache License 2.0

C# 98.12% TSQL 1.00% Batchfile 0.03% PowerShell 0.47% Shell 0.38%
repository-pattern dotnet6 masstransit entity-framework-core unit-of-work-pattern design-patterns distributed-transactions linq2db mediator dapper

rcommon's Introduction

RCommon

Overview

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:

  1. Future proofing applications against changing architectural or infrastructure needs.
  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.
  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 :)
  4. Last but not least - open source forever.

We track bugs, enhancement requests, new feature requests, and general issues on GitHub Issues and are very responsive. General "how to" and community support should be managed on Stack Overflow.

Patterns & Abstractions Utilized

  • Specification
  • Mediator
  • Command Query Responsbility Segregation (CQRS)
  • Validations
  • Repository
  • Unit Of Work
  • Event Sourcing (Coming Soon)
  • Event Bus
  • Message Bus
  • Generic Factory
  • Guard
  • Data Transfer Objects (DTO)

Pattern Implementations

  • Mediator: MediatR
  • Repository: Entity Framework Core, Dapper, Linq2Db
  • Message Bus: MassTransit, Wolverine
  • Email: SMTP, SendGrid
  • Validation: FluentValidation

Documentation

We have begun maintaining and publishing our documentation at https://docs.rcommon.com

Stats

Alt

rcommon's People

Contributors

jasonmwebb avatar jasonmwebb-lv avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

rcommon's Issues

Rework Unit of Work Pattern

The Unit of work pattern is needlessly complex. State management can be moved to cache, or scoped object collection. DataProvider is wildly inefficient. Since .NET 6 only allows TransactionSCope to participate in one database transaction at a time, there is not currently a need for multiple transaction providers. The exception to that rule would be if Mongo db client requires a different provider. In that case though, we should be able to detect the DataStore type and dynanically switch transaction providers when using IUnitOfWorkScopeFactory.

EFCoreRepository Attach Method

Attach method needs to ensure that object graph is populated prior to attaching, otherwise it will assume it is already done and then attempt to attach which will generate errors with identity inserts, foreign keys and such. Something along the lines of Find(key) needs to be used first.

Sample Code for Console App

Create sample code for a simple console application. Sample code should include configuration, basic Crud operations via repository pattern, transactions via unit of work pattern, and exception handling.

Create template abstractions

Create template abstractions for common implementations:

  • Theming
  • Email templates

Will need to take into account some sort of database driven templates for Razor and maybe another mainstream provider.

Add MassTransit Wrappers

Add wrappers for MassTransit interface and messaging abstractions to support distributed architecture.

Clean Architecture CQRS Sample

Need a simple CA/CQRS sample to assist with demonstrating how to use RCommon. Scenarios that should be covered:

  • Dependency Injection via Adapters
  • Mediator
  • Repositories w/ EF
  • Business Entities base classes
  • Model/DTO base classes
  • Unit of Work pattern & behavior
  • DTO validation

Multitenancy Support

Add multitenancy support for entities, and persistence operations. Needs to include tenant resolver for the following scenarios:

  • Web/identity claims
  • Web/session
  • Web/Cookie
  • Web/Domain Http Header or URI
  • LocalThreadContext

Tenancy Models to support:

  • Single Tenant (One Data Store per Tenant)
  • Multi Tenant (One Data Store per Multiple Tenants)
  • Mixed Mode (Possibility to separate certain Tenants from multi tenant data store based on criteria)

Will also need to create connection string factory to support dynamically changing connection strings based on tenancy model.

Add SendGrid Email API Implementation

We currently have an SMTP implementation but need to implement SendGrid Email API as it tends to perform better and is generally excepted by the community.

SMS Abstractions

Create a SMS abstraction with the following implementations:

  • Twilio
  • Null

Soft Delete Support

Need to add the ability to perform soft deletes vs. hard deletes. Things to consider:

  • Configuration to be applied at global level with default set to hard delete.
  • Configuration to be applied at Repository level where parameter can be used to ignore/override global configuration

Change Tracking Support for Repositories

Need to create ChangeTracking abstractions for generically capturing entity changes and properly persisting them. Each individual repository implmentation (EF Core, NHibernate, etc.) has their own strategy for change tracking with various pros/cons. This makes creating a pattern around those libraries difficult so it makes more sense to abstract out the implementations. There are various libraries that can handle this sufficiently.

Event Sourcing Support

Need to implement basic support for event sourcing. The majority of the functionality already exists via the local/distributed events but we'll need to ensure we're capturing new/previous state in all local/distributed events and we'll need to add some configuration/extensions which allow us to determine storage queue for events.

Candidate Implementations:

  • EventStore
  • MongoDb
  • EF (Transactional RDBMS)

MongoDb Support

Add support for MongoDb using IGraphRepository interface. Full integration test suite should be included.

Create high level API usage documentation

Create the documentation neccesary for a developer that is new to the framework to easily and successfully implement the framework in a few minutes. Sample code should be referenced for continuity.

Remove requirement for defining datastore when repository is instantiated

All repositories currently are required to have "DataStoreName" property set at instantiation. There should be a mechanism for defining a default data store in options through DI. Also, factories would be a nice addition during options to allow repository to dynamically figure out what datastore to use based on certain conditions.

Implement Generic Change Tracking for Mongo Db

MongoDb does not appear to have a native in-process change tracking solution such as EF or NHibernate. We'll need to implement something in order to satisfy the IGraphRepository requirement.

Need blob storage abstractions

Create blog storage abstraction with the following implementations:

  • Azure
  • AWS
  • File System
  • Minio
  • Aliyun

Consider using ABP for much of the plumbing code.

ChangeTracker Should be Redesigned to EventTracker

Currently the RCommon.BusinessEntities.ChangeTracker implementation is geared more towards eventing of the business entities rather than the changes being made to them. While there is a fine line, the prevailing wisdom is that changetracking has more to do with state of the entity and the ability to capture changes in state, whereas the current implementation of RCommon ChangeTracker deals more with the event capturing - an event repository of sorts. There is a clear separation of responsibilities here.

Migrate towards IServiceCollection

Serious consideration should be put into migration all dependency injection registration to the IServiceCollection interface. The community seems to have adopted that pretty heavily. Most DI container providers have to adopt this at some level. It may make sense for RCommon DI to adopt that as well and let the DI providers drive adoption of their specific interface and features separately. RCommon doesn't gain anything from allowing architects to use a consolidated interface for DI registration. Architects don't gain anything from being able to consolidate a DI registration interfaces unless it has the benefit of wide community adoption. Lastly, architects are forced to adopt at least the version of RCommon DI abstraction that has been implemented which may be the biggest reason for inability to adopt.

Validation Abstractions

Need to either create validation abstractions or promote Fluent Validation library to first class citizen. There are currently two conflicting sets of validation classes in play 1) Original NCommon/native validations 2) Fluent Validations. Fluent Validations obviously has a lot of support, while the native validations support more generic validations via specifications supported by RCommon.

Look into:

  • See if we can implement specification based validation in Fluent validations and tie that to a generic interface/abstraction
  • Decide if carrying around native validations is worth it assuming we'll have to create some consistency between libraries.

Entity Audit Support

Add ability to fully audit all entities persisted in data store. Basic functionality should include:

  • Track who executed action
  • Track what action was affected
  • Track when the action occured
  • Track previous state

Localization Support

Need to add localization abstractions with support for the following configuration providers:

  • Resx
  • Json File
  • Data Store

This should also consider how localization is resolved:

  • Config/Options
  • Url resolver
  • Cookie
  • Session
  • Tenant

Concurrency Support

Add optimistic and pessimistic concurrency support to entities and persistence.

Add Basic Support for Audited Entities

There is not currently a way to add audited entities to RCommon data stores as there is not currently the ability to acquire data such as "user" from a given context. Audited data stores should allow:

  • LastModfifiedDate
  • LastModifiedBy (user)
  • DateCreated
  • CreatedBy (user)

User info should be acquired through a factory (default should be identity). Also consider using change tracking to discover whether or not entities are new vs. updated to auto-populate properties.

Options pattern should be used to determine rules for how audited entities get populated.

Distributed Unit of Work behavior Doesn't Fire when UoW Not Present

Currently, unit of work does not fire unless one has already been created. There is no need to detect unit of work since all transactions are ambient at this level and will auto subscribe. Also, the behavior will ensure that only one unit of work is created per request scope....though we can continue to create new ones (suppressed or otherwise) if needed in the pipeline.

Remove LGPL code references.

There are a number of references to LGPL code references - primarily related to ABP. This limits commercial adoption.

Create EF Core integration tests

Create a full suite of integration tests for EF core which will ensure this EF Core implementation works from the top down. Tests should include CRUD functions, transactions, web based and non web based tests.

1.0.1.75 Release cleanup

To meet the standards of our release criteria, we can only release code which has been adequately unit tested. As a result, we should remove NHibernate and defer it's release to a future version. Additionally, we should smoke test the samples to ensure all functionality works. Documentation also needs to be updated to ensure at least a minimal amount of samples for each section.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.