Kay.SharedKernel.Infrastructure
1.0.0
dotnet add package Kay.SharedKernel.Infrastructure --version 1.0.0
NuGet\Install-Package Kay.SharedKernel.Infrastructure -Version 1.0.0
<PackageReference Include="Kay.SharedKernel.Infrastructure" Version="1.0.0" />
<PackageVersion Include="Kay.SharedKernel.Infrastructure" Version="1.0.0" />
<PackageReference Include="Kay.SharedKernel.Infrastructure" />
paket add Kay.SharedKernel.Infrastructure --version 1.0.0
#r "nuget: Kay.SharedKernel.Infrastructure, 1.0.0"
#:package Kay.SharedKernel.Infrastructure@1.0.0
#addin nuget:?package=Kay.SharedKernel.Infrastructure&version=1.0.0
#tool nuget:?package=Kay.SharedKernel.Infrastructure&version=1.0.0
Kay
Overview
Welcome to the .NET 8 C# microservices project, leveraging various industry best practices and design patterns to ensure a robust, scalable, and maintainable solution. This project embraces technologies like Entity Framework Core 8, C# 12, Clean Architecture, Domain-Driven Design (DDD), Event-Driven Design, and follows industry standards such as CQRS, Specification Pattern, SOLID principles, Gang of Four Design Patterns, Outbox Pattern, and more.
Project Structure
Follows Clean Architecture and Domain-Driven Design principles, separating bounded contexts into individual microservices. This ensures a clear separation of concerns, scalability, and maintainability.
Key Technologies
- .NET 8
- C# 12
- Entity Framework Core 8
- MediatR and FluentValidation for validation
- Polly for fault handling
- Moq, Fluent Assertion, and xUnit for unit testing
- Dapper for faster SQL queries
- Marten Document Database with PostgreSQL for NoSQL requirements
- RabbitMQ and MassTransit for message queue
- Redis for distributed caching
- Docker, Docker Compose, and Kubernetes for containerization and orchestration
Design Patterns and Practices
- CQRS (Command Query Responsibility Segregation)
- Specification Pattern
- SOLID Principles
- Gang of Four Design Patterns
- Outbox Pattern
- Domain Event Pattern
- DDD CAP Theorem
- Unit of Work pattern with EF Core
- Smart Enums with rich behavior
- Materialized View for speeding up queries
- Event-Driven Architecture
- API Idempotency to prevent duplicate requests
Testing
Unit testing is done using Moq, Fluent Assertion, and xUnit. This ensures the reliability and correctness of the codebase.
Data Access
EF Core is used for relational databases, while Dapper is employed for faster SQL queries. Marten Document Database with PostgreSQL is chosen for microservices requiring a NoSQL solution.
Observability
Logging is treated as a cross-cutting concern and is addressed using MediatR. Message queues (RabbitMQ and MassTransit) enhance observability by facilitating asynchronous communication.
Idempotency and Saga
Idempotency is ensured through API design, preventing the execution of duplicate requests. The system employs Domain Events to build a decoupled architecture that scales. Sagas are implemented to manage long-running processes.
Deployment
The project is containerized using Docker, orchestrated with Docker Compose, and can be scaled using Kubernetes for efficient deployment and management.
Additional Best Practices
- Follow principles of OOP
- Use Value Objects to overcome Primitive Obsession
- Aggregate Root design for maintaining consistency
- Handle duplicate messages and API calls with idempotent strategies
- Implement distributed caching with Redis for performance optimization
API Gateway
Introducing the API Gateway using YARP (Yet Another Reverse Proxy). YARP provides a flexible and efficient way to route, load balance, and secure traffic to the microservices. It acts as the entry point to the system, managing requests and distributing them to the appropriate microservices. This enhances the system's scalability, resilience, and security.
Feel free to explore the codebase and contribute to this well-architected, industry-standard microservices project. Happy coding!
References
- Clean Architecture Folder Structure https://www.milanjovanovic.tech/blog/clean-architecture-folder-structure?utm_source=LinkedIn&utm_medium=social&utm_campaign=25.12.2023
- CAP Theorem https://www.educative.io/blog/what-is-cap-theorem
- Important Component of System Design and Architecture https://www.educative.io/blog/components-of-system-design
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net9.0
- AWSSDK.S3 (>= 3.7.416.13)
- Google.Protobuf (>= 3.30.2)
- Grpc.AspNetCore (>= 2.70.0)
- Grpc.AspNetCore.HealthChecks (>= 2.70.0)
- Grpc.AspNetCore.Server.Reflection (>= 2.70.0)
- Grpc.Net.Client (>= 2.70.0)
- Hangfire.AspNetCore (>= 1.8.18)
- Hangfire.Core (>= 1.8.18)
- HangFire.Redis (>= 2.0.1)
- Hangfire.Redis.StackExchange (>= 1.12.0)
- Kay.SharedKernel.Persistence (>= 1.0.0)
- Microsoft.AspNetCore.Authentication.JwtBearer (>= 9.0.4)
- Microsoft.AspNetCore.Http (>= 2.3.0)
- Microsoft.AspNetCore.Http.Abstractions (>= 2.3.0)
- Microsoft.Extensions.Caching.Abstractions (>= 9.0.4)
- Microsoft.Extensions.Configuration.Abstractions (>= 9.0.4)
- Newtonsoft.Json (>= 13.0.3)
- OpenTelemetry.Exporter.OpenTelemetryProtocol (>= 1.11.2)
- OpenTelemetry.Extensions.Hosting (>= 1.11.2)
- OpenTelemetry.Instrumentation.AspNetCore (>= 1.11.1)
- OpenTelemetry.Instrumentation.EntityFrameworkCore (>= 1.0.0-beta.12)
- OpenTelemetry.Instrumentation.Hangfire (>= 1.6.0-beta.1)
- OpenTelemetry.Instrumentation.Http (>= 1.11.1)
- OpenTelemetry.Instrumentation.SqlClient (>= 1.9.0-beta.1)
- Polly (>= 8.5.2)
- Sentry (>= 5.5.1)
- StackExchange.Redis (>= 2.8.31)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Kay.SharedKernel.Infrastructure:
| Package | Downloads |
|---|---|
|
Kay.SharedKernel.Presentation
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0 | 159 | 1/21/2026 |