Domain.SharedKernel is a clean, reusable shared library tailored for Domain-Driven Design (DDD) applications. It encapsulates core domain logic, base entity definitions, Snowflake ID generation, and abstraction contracts—ideal for use across multiple bounded contexts or microservices.
Install via NuGet:
dotnet add package Andrew.Domain.SharedKernelNuGet\Install-Package Andrew.Domain.SharedKernel"Snowflake": {
"WorkerId": 1
}ℹ️ Use different WorkerIds for each microservice instance or physical machine to avoid ID collisions.
services.AddDomainShardKernelCollection(configuration);A common abstract base class for domain entities, offering:
- Unique identifier with Snowflake ID generation
- Domain event support (using [MediatR])
A utility class for secure hash generation:
SHA256MD5AES
Useful for token generation, password hashing, and more.
Generates globally unique 64-bit IDs based on time and machine identity. Perfect for distributed systems that require high-performance and collision-free ID generation.
Includes key interfaces for domain architecture:
IAggregateRoot– Marks an entity as an aggregate root.ICurrentUser– Access the current user context (UserId,TenantId, etc.).IUnitOfWork– Defines transactional boundaries for your repositories.
Implementing a Shared Kernel brings:
- 🔁 Consistency across bounded contexts
- 🧼 Separation of domain logic from infrastructure concerns
- 🔄 Reusability across projects and microservices
- 📐 Clarity through standard interfaces and patterns
MIT License