Solution: ImmutableLedger
-
ImmutableLedger.Domain Project Type: Class Library (.NET Core) Purpose: Contains enterprise-wide logic and types Dependencies: None
-
ImmutableLedger.Application Project Type: Class Library (.NET Core) Purpose: Contains business logic and types Dependencies:
- ImmutableLedger.Domain
-
ImmutableLedger.Infrastructure Project Type: Class Library (.NET Core) Purpose: Contains all external concerns Dependencies:
- ImmutableLedger.Domain
- ImmutableLedger.Application
-
ImmutableLedger.Service (or ImmutableLedger.Api for web applications) Project Type: Worker Service (.NET Core) or ASP.NET Core Web API Purpose: Entry point of the application, composition root Dependencies:
- ImmutableLedger.Domain
- ImmutableLedger.Application
- ImmutableLedger.Infrastructure
-
ImmutableLedger.Domain.Tests Project Type: xUnit Test Project (.NET Core) Purpose: Unit tests for Domain layer Dependencies:
- ImmutableLedger.Domain
-
ImmutableLedger.Application.Tests Project Type: xUnit Test Project (.NET Core) Purpose: Unit tests for Application layer Dependencies:
- ImmutableLedger.Domain
- ImmutableLedger.Application
-
ImmutableLedger.Infrastructure.Tests Project Type: xUnit Test Project (.NET Core) Purpose: Integration tests for Infrastructure layer Dependencies:
- ImmutableLedger.Domain
- ImmutableLedger.Application
- ImmutableLedger.Infrastructure
Project Contents:
-
ImmutableLedger.Domain
- Entities (e.g., LedgerEntry.cs)
- Value Objects
- Enums
- Exceptions
- Interfaces (e.g., ILedgerRepository.cs)
-
ImmutableLedger.Application
- Interfaces (e.g., ILedgerService.cs, IMessageHandler.cs)
- Services (e.g., LedgerService.cs, MessageHandler.cs)
- DTOs (Data Transfer Objects)
- Exceptions
-
ImmutableLedger.Infrastructure
- Data
- Repositories (e.g., ShardedPostgreSqlLedgerRepository.cs)
- Database Contexts
- Sharding
- AdaptiveShardingStrategy.cs
- ShardManager.cs
- Messaging
- SqsClient.cs
- External Services Integrations
- Data
-
ImmutableLedger.Service
- Program.cs (composition root, DI setup)
- LedgerWorker.cs
- appsettings.json
Dependency Flow: Domain <- Application <- Infrastructure <- Service
Key Principles:
- The Domain layer has no dependencies on other layers.
- The Application layer depends only on the Domain layer.
- The Infrastructure layer depends on both Domain and Application layers.
- The Service layer depends on all other layers and composes them.
- All dependencies point inwards, towards the Domain layer.