This is the Ordering Microservice on the Distributed spike representing a DDD Clean Architecture template.
Guiding principals
- High Cohesion Lose Coupling
- Simple things should be easy, complex things possible
- Don't call us, we'll call you (Hollywood principle)
Setup Instructions
- Clone the repository
- Create an empty "DistroOrdering" database on your local SQL Server instance
- Initialize and update submodules, the below for [Distro.Seedworks.Infrastructure] folder in CMD
git submodule init
git submodule update
git checkout main
git pull
- Open "Package Manager Console" and select "Distro.Ordering.DataAccess" and run
Update-Database - Remove the skip anotation from the 'DatabaseInitializationTests.cs' > InitializeDatabaseWithSampleData and run for population
Not in scope
- Security (Assume OAuth JWT with Identity Server)
- Inter Bounded Context communication (ESB)
- Cloud logging and visualization (Assume ELK)
Clean Architecture Design
- *Use clean Use Case defnitions to show capability of microservice (Application Service Interfaces)
- *Ensure directional implimentation of interfaces with inner boundries unaware of outer implimentations (Onion Architecture)
DDD Design
- *Domain Entities, Behaviors and Aggrigate Root Repositories
- *Domain Services (Entity orchestration and complex domain logic)
- *Domain Event Handeling (Sync/A-Sync with unit of work rollback) [MediatR or RabbitMQ?] Look at the following examples when deciding on a strategy:
- Ardalis Example: Add ToDoItemCompletedEvent from Domain Entity Behaviour
- Udemy Example: Add BasketCheckoutEvent during basket checkout (Looks like external ESB implimentation)
- ABP Framework: Add PersonNameChangedEvent to Domain Entity Behaviours
- *Ensure valid state - Side affects through domain events (Unit of Work Pattern, shared database context)
- *Include basic data population (seed from repo) for local dev and unit testing (Environment configurable)
- Ensure valid state - Use value objects to ensure entities cannot be set in an invalid state, imutable history of values can be a subset of an entity object can have behaviors e.g. Product Code or Invoice Number that requires special formats and sequencing
- CQRS (Command & Query) Data Access Implimentation (Must be able to support standard repo's OR CQRS)
- *Isolate sensitive (domain rule) updates on domain entity from access in application layer i.e. domain entity exposure / value objects
General Microservice Design
- *Specification pattern implimentation (Decouple query construction from Data Access layer)
- Data Services (Crud Rest vs Data Streams)
- Split testing into Functional, Integration and Unit Testing (Decent mocking / Stubbing capability)
- Leverage an async design for non-blocking activities
- Rate throttling
CI/CD & Hosting
- *Self hosted container on Linux image
- *API Gateway orchestration of Application Services REST implimentations (Example Envoy or Ocelot)
- *DevOps Pipeline automated deploy (Unit testing, versioning, certificate)
- Dependancy health check during deployment
Miscellaneous
- Relook at the Unit of Work Pattern service and repository instanciation, check if we can use the DI to inject the same DB context and manage it through configuration
- Clean Architecture Uncle Bob
- Sample Clean Architecture Microservice by Ardalis
- Sample Microservice Git Repository from Microservice .Net Udemy Course
- Example clean architecture from ABP with their Source Code
