-
Notifications
You must be signed in to change notification settings - Fork 0
z2019 Combine 'Clean Architecture' and 'Domain Driven Design' (in ASP.Net MVC Core)
The session was about implementing Uncle Bob's Clean Architecture as close as possible and combine it with some Domain Driven Design sugar (not that much yet). All done in a MVC web-application with server-side rendering that makes things like presenters a little cumbersome.
- Slides: https://1drv.ms/p/s!Ahj5CGHRMZaf6kHQv6Gx9nIUf4WM?e=4IHTii
- Repo: https://github.com/mduu/tauchbolde
- Blog-Serie: https://marcduerst.com/2019/09/22/chapter-1-my-journey-in-clean-architecture-and-domain-driven-design/
Sample 1: Write-Usecase without a presenter but with some business-logic
- Controller: https://github.com/mduu/tauchbolde/tree/develop/src/Tauchbolde.Web/Controllers/LogbookController.cs > Publish()
- Interactor: https://github.com/mduu/tauchbolde/tree/develop/src/Tauchbolde.Application/UseCases/Logbook/PublishUseCase/PublishLogbookEntryInteractor.cs
- Domain-Object: https://github.com/mduu/tauchbolde/tree/develop/src/Tauchbolde.Domain/Entities/LogbookEntry.cs > Publish()
- Domain-Event: https://github.com/mduu/tauchbolde/blob/develop/src/Tauchbolde.Domain/Events/LogbookEntry/LogbookEntryPublishedEvent.cs
- Policies: https://github.com/mduu/tauchbolde/tree/develop/src/Tauchbolde.Application/Policies/Logbook/LogbookEntryPublished
Sample 2: Getting a logbook entry's detail screen using use-case interactor, output-port, output, presenter & view-model
- Controller: https://github.com/mduu/tauchbolde/tree/develop/src/Tauchbolde.Web/Controllers/LogbookController.cs > Detail()
- Interactor: https://github.com/mduu/tauchbolde/blob/develop/src/Tauchbolde.Application/UseCases/Logbook/GetDetailsUseCase/GetLogbookEntryDetailsInteractor.cs
- Interactor Output-Port: https://github.com/mduu/tauchbolde/blob/develop/src/Tauchbolde.Application/UseCases/Logbook/GetDetailsUseCase/ILogbookDetailOutputPort.cs
- Interactor Output: https://github.com/mduu/tauchbolde/blob/develop/src/Tauchbolde.Application/UseCases/Logbook/GetDetailsUseCase/GetLogbookEntryDetailOutput.cs
- Presenter: https://github.com/mduu/tauchbolde/blob/develop/src/Tauchbolde.InterfaceAdapters/Logbook/Details/MvcLogbookDetailsOutputPort.cs
- View-Model: https://github.com/mduu/tauchbolde/blob/develop/src/Tauchbolde.InterfaceAdapters/Logbook/Details/LogbookDetailViewModel.cs
Regarding "screaming architecture": you can quickly see the applications use-cases and therefore the applications right to exist:
- Event-Module: https://github.com/mduu/tauchbolde/tree/develop/src/Tauchbolde.Application/UseCases/Event
- Logbook-Module: https://github.com/mduu/tauchbolde/tree/develop/src/Tauchbolde.Application/UseCases/Logbook
I used the following tech in the session and code:
- .Net Core 2.2 on my Mac
- ASP.Net MVC Core 2.2
- C# 7 (latest)
- Jetbrains Rider IDE
- Libraries: ** MediatR (in process message bus for requests and notifications) ** Fluent Validator (used as MediatR pipeline behaviors to validate requests) ** Unit-Testing: *** XUnit *** Fake It Easy *** Fluent Assertions *** ApprovalTest.Net
The live version is fully hosted on Azure including:
- Azure AppService (the core weg app)
- Azure LogicApp (for triggering the email publication on a hourly base)
- Azure Blob Storage (for storing image blobs)
- Azure SQL Server (relational database)
- Azure DevOps for build- and deployment automation
- Azure Application Insights (for logging, telemetry and analytics)
- Azure Portal Dashboards (for cost monitoring)
I have two instances of the app: stage and testing. Always intersting (at least to me) what cloud stuff really costs: the monthly bill of this app is close to CHF 15.-