Roots.Framework is a modular .NET library providing foundational building blocks for enterprise applications, including CQRS, unit of work, repository patterns, middleware, JWT authentication, HTTP/RabbitMQ clients, and more.
- CQRS Support: Command and Query interfaces, MediatR integration, pipeline behaviors (logging, trace ID, exception handling).
- Persistence Layer: Generic repository and unit of work patterns for Entity Framework Core.
- Middleware: Error handling, logging with transaction IDs, and request culture support.
- Security: JWT token generation/validation and cryptographic helpers.
- External Integrations: HTTP client abstraction (RestSharp) and RabbitMQ messaging client.
- Configuration Extensions: Easy DI registration for all features.
Roots.Framework/
├── Common/Exceptions/ # Custom exception types
├── Configuration/ # Service registration extensions
├── CQRS/ # CQRS interfaces and pipeline behaviors
├── Externals/
│ ├── Http/ # HTTP client abstraction
│ └── Messaging/ # RabbitMQ client abstraction
├── Middleware/ # ASP.NET Core middleware
├── Persistence/ # Repository and UnitOfWork patterns
├── Security/ # JWT and crypto helpers
├── Settings/ # Strongly-typed settings classes
- Install NuGet Package
(Publish the package to your NuGet feed and install it in your project.)
- Register Services in
Startup.csor Program
// Add to your DI container
services.AddUnitOfWork(Configuration);
services.AddRootMediatr(cfg => { /* MediatR config */ });
services.AddRootsHttpClient(Configuration);
services.AddRootsMessaging(Configuration);
services.AddRootsJWT(Configuration);- Configure Middleware
app.UseRootErrorHandling();
app.UseRootLogging();
app.UseRequestCulture();- Configure Settings
Add relevant sections to your appsettings.json:
{
"JwtSettings": {
"SecretKey": "your-secret",
"Issuer": "your-issuer",
"Audience": "your-audience",
"TokenExpiryInHours": 1
},
"RabbitMQSettings": {
"HostName": "localhost",
"Username": "guest",
"Password": "guest"
},
"Roots": {
"BaseUrl": "https://api.example.com"
}
}- CQRS: See
Roots.Framework.CQRSforICommand,IQuery, and pipeline behaviors. - Repositories: See
Roots.Framework.Persistence.Repository.IRepositoryandBaseRepository. - Unit of Work: See
Roots.Framework.Persistence.UnitOfWork.IUnitOfWorkandUnitOfWork. - JWT: See
Roots.Framework.Security.Jwt.TokenServiceandJwtSettings. - RabbitMQ: See
Roots.Framework.Externals.Messaging.IRootsRabbitMqClientandRootsRabbitMqClient. - HTTP Client: See
Roots.Framework.Externals.Http.IRootsHttpClientandRootsHttpClient. - Middleware: See
Roots.Framework.Middleware.
- Build:
dotnet build
- Test:
dotnet test
Contributions are welcome! Please open issues or submit pull requests.
License: MIT