• Stars
    star
    841
  • Rank 54,194 (Top 2 %)
  • Language
    CSS
  • License
    MIT License
  • Created almost 4 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Sample code for the Pluralsight DDD Fundamentals course by Julie Lerman and Steve "ardalis" Smith

Pluralsight DDD Fundamentals Sample

Sample code for the Pluralsight DDD Fundamentals course (2nd edition) by Julie Lerman and Steve "ardalis" Smith. If you are looking for the .NET Framework sample from the original 2014 DDD Fundamentals course, it's available as the ddd-vet-clinic sample.

Additional exercises from Steve's DDD workshops (separate from Pluralsight course)

Give a Star!

If you like or are using this project to learn, please give it a star. Thanks!!!

Table of Contents

1. Running the Sample

  1.1 Docker

  1.2 Visual Studio and VS Code

2. Student Recommendations

3. Architecture Notes

4. Developer Notes

5. Credits

1. Running the Sample

You can run this sample in Docker or in Visual Studio. Docker is recommended.

Watch how to set up and run the sample app using Docker, Visual Studio, or VS Code here:

image

Running the DDD Fundamentals Sample by Philippe Vaillancourt

1.1 Docker

The easiest way to run the sample is using docker. Download the source and run this command from the root folder:

docker-compose build --parallel
docker-compose up

The build step will take a while. It's way faster if you run it in parallel, assuming you have a fast machine and download speed. The up command is much faster but will also take a moment and you may see some errors as apps try to connect to docker or databases before they're responsive. Give it a minute or two and it should succeed. RabbitMQ errors should go away once that service starts up. If you get SQL Server login errors, I've found it's best to just restart everything (ctrl-c, then docker-compose up again).

This will start RabbitMQ (for messaging between apps) and build and run each of the applications involved in the sample:

  • FrontDesk.Api
  • FrontDesk.Blazor
  • ClinicManagement.Api
  • ClinicManagement.Blazor
  • VetClinicPublic

It also adds the following supporting containers:

  • RabbitMQ with Management
  • FrontDesk SQL Server
  • ClinicManagement SQL Server
  • Test Mailserver (Papercut)

Once running, you should be able to access the various apps using localhost (HTTP not HTTPS because of Kestrel configuration restrictions) and the following ports (you can also find these bindings in the docker-compose.yml file):

Service (in docker) Docker Port Visual Studio Port
FrontDesk (main app) 5100 5150
ClinicManagement 6100 6150
VetClinicPublic 7100 7150
FrontDesk API / Swagger 5200 5250
ClinicManagement API / Swagger 6200 6250
RabbitMQ Management 15673 15672
RabbitMQ Service (5672) 5672
Papercut Management 37409 37408
Papercut SMTP (25) 25

The ports in () are only open inside of docker, not exposed otherwise.

Here are the (localhost) links you should use once the apps are running in docker:

If you want to quickly clean up all of your docker containers (All of them not just the ones you created for this sample!) you can run this command:

docker kill $(docker ps -q)

Note that any data changes you make will not be persisted if you docker remove the SQL Server container. The Docker container for SQL Server will be recreated and seeded on the next docker run. In other scenarios, you might be using Docker volumes to persist or share the database across container instances but that's overkill for this demo.

1.2 Visual Studio and VS Code

You may need to configure a local NuGet server and put this package in it:

/FrontDesk/src/FrontDesk.Blazor/deps/Pluralsight.DDD.Deps/Pluralsight.DDD.Deps.1.0.0.nupkg

Running the sample from Visual Studio (or VS Code or Rider, etc) requires some additional setup. You will need to run multiple solutions side by side. You will also need to run RabbitMQ and PaperCut, ideally as a docker images. You can run RabbitMQ from Docker using this command:

docker run --rm -it --hostname ddd-sample-rabbit -p 15672:15672 -p 5672:5672 rabbitmq:3-management

You should be able to open localhost:15672 to view RabbitMQ management interface (login as guest/guest).

rabbitmq management app

When new appointments are created, confirmation emails are sent out to clients. Start a test mailserver using this command (learn more):

docker run --name=papercut -p 25:25 -p 37408:37408 jijiechen/papercut:latest

You should be able to open localhost:37408 to view Papercut test mailserver management interface, where sent emails will appear.

Papercut management app

You can run individual solutions independently from one another, but obviously you won't see live sync between them when entities are updated, new appointments created, appointment confirmation emails clicked, etc. To get that, you'll need to run all three of the web applications:

  • FrontDesk
  • ClinicManagement
  • VetClinicPublic

Some of the ports may not be set up in config; you may need to adjust them by hand. They assume you'll run primarily in docker to see everything running. If you're trying to get things working outside of docker, you should try with the ports shown in the table above.

2. Student Recommendations

If you're coming here from the Pluralsight Domain-Driven Design Fundamentals course, great! Download this sample and look around. See if you can run it on your machine (docker recommended). Your next assignment is to look at the TODO comments in the code, and see if you can implement any of them. You can view todo comments as tasks in Visual Studio, or there are plugins for VS Code.

Don't worry about submitting a pull request for any TODO comments you fix. They're left there intentionally to help students learn by providing some ways to extend the solution from the course.

3. Architecture Notes

The reference application is built as a small set of related monolithic ASP.NET Core applications. The two Blazor applications are built using a modified version of the CleanArchitecture solution template and also bears a great deal of similiarity to the eShopOnWeb application (also maintained by @ardalis). To learn more about migrating toward a domain-centric architecture from a data-centric one, check out Steve's two courses on N-Tier architecture on Pluralsight. You'll also find videos covering Clean Architecture on Steve's YouTube channel as well as on the eShopOnWeb home page.

If you or your team need help with architecting your .NET application following principles of clean architecture, with or without microservices, Steve and his team and NimblePros have a great deal of experience helping clients do just that. Get in touch.

4. Developer Notes

If you're new to this kind of application development, and you have a Pluralsight subscription, I strongly advise you to learn about SOLID principles and various code smells and refactoring techniques. You'll find the background in these principles informs most of the design decisions used in the individual classes and projects used in the sample code provided here. If you're really serious about learning these topics, watch the original versions of these courses, which were able to go into more depth (more recent courses need to be shorter since Pluralsight found too many students didn't complete longer courses. But not you - you have what it takes to finish the whole thing. Right?). They're available from Steve's author page on Pluralsight.

The sample doesn't include exhaustive test coverage, but does demonstrate some automated tests. If testing is new to you, Julie has a great course on automated testing that you should check out.

4.1 Referenced NuGet Packages

This course uses several NuGet packages that you may find useful.

Ardalis.ApiEndpoints A simple base class that lets you keep your API endpoints small and focused on one endpoint at a time. MVC is replaced with Request-EndPoint-Response (REPR).

Ardalis.GuardClauses Contains common guard clauses so you can use them consistently. Also can be easily extended to apply your own guards for custom/domain exception cases.

Ardalis.Specification An implementation of the Specification design pattern that is well-suited to work with ORMs like Entity Framework (Core).

Ardalis.Specification.EntityFrameworkCore Adds EF Core-specific functionality, including a default implementation of a generic EF repository that supports Specifications.

Ardalis.Result Provides a generic result type that can be returned from application services. Can easily be translated into HTTP status codes or ActionResult types.

Ardalis.HttpClientTestExtensions Removes boilerplate code from ASP.NET Core API integration/functional tests.

Autofac Powerful open source DI/IOC container for .NET that supports more features than built-in ServiceCollection.

Blazored.LocalStorage Blazor utility for accessing browser local storage in Blazor WebAssembly apps.

MediatR Used to implement mediator pattern for commands and events.

Pluralsight.DDD.Deps Includes required trial binaries from Telerik. Currently this includes both Kendo UI and Blazor controls; Kendo should be replaced with just Blazor later in 2021. To build locally you may need to place this package in a local nuget repository. This package and its contents are subject to Telerik's EULA located in the same folder.

PluralsightDdd.SharedKernel An example SharedKernel package used by this sample built just for this course.

RabbitMQ.Client Client for communicating with RabbitMQ.

5. Credits

This sample is from Julie Lerman and Steve Smith's Pluralsight course. The original sample was written for .NET Framework by Steve. The current .NET 5 version was initially ported with the help of Shady Nagy. Progress Software provided the Blazor Scheduler control used to display the clinic's schedule*.

* Initial version is using a Kendo schedule since certain features weren't available at recording time

Additional credits include:

Matheus Penido: Fixing a bug (#36) https://github.com/matheuspenido https://www.linkedin.com/in/matheus-penido-8419a890/

  • Your name could be here...

More Repositories

1

CleanArchitecture

Clean Architecture Solution Template: A starting point for Clean Architecture with ASP.NET Core
C#
16,284
star
2

GuardClauses

A simple package with guard clause extensions.
C#
3,063
star
3

ApiEndpoints

A project for supporting API Endpoints in ASP.NET Core web applications.
C#
2,934
star
4

SmartEnum

A base class for quickly and easily creating strongly typed enum replacements in C#.
C#
2,178
star
5

Specification

Base class with tests for adding specifications to a DDD model
C#
1,922
star
6

Result

A result abstraction that can be mapped to HTTP response codes if needed.
C#
819
star
7

CleanArchitecture.WorkerService

A solution template using Clean Architecture for building a .NET Core Worker Service.
C#
720
star
8

ddd-guestbook

A DDD guestbook example written for ASP.NET Core
C#
691
star
9

kata-catalog

My list of code katas
C#
670
star
10

DesignPatternsInCSharp

Samples associated with Pluralsight design patterns in c# courses.
C#
518
star
11

DDD-NoDuplicates

Some design approaches to enforcing a business rule requiring no duplicates. Domain driven design.
C#
512
star
12

SolidSample

C#
474
star
13

new-software-project-checklist

The ultimate new software project decision/question checklist
443
star
14

ddd-vet-sample

A sample meant to demonstrate domain driven design using a veterinary hospital management system.
C#
305
star
15

OrganizingAspNetCore

Offers several different ways to organize content in ASP.NET Core MVC and Razor Pages projects.
C#
207
star
16

Ardalis.Extensions

Some random C# extension methods I've found useful. Published as Ardalis.Extensions on Nuget.
C#
147
star
17

WebApiBestPractices

Resources related to my Pluralsight course on this topic.
C#
144
star
18

CachedRepository

A sample demonstrating the CachedRepository pattern
C#
104
star
19

HttpClientTestExtensions

Extensions for testing HTTP endpoints and deserializing the results. Currently works with XUnit.
C#
92
star
20

CertExpirationCheck

A simple xUnit C# test showing how to verify a certificate for a domain has at least 30 days before it expires.
C#
79
star
21

DotNetDataAccessTour

A tour of different data access approaches in .NET 8+.
C#
73
star
22

AspNetCoreStartupServices

A simple demo listing all services available to an app at startup
C#
69
star
23

GettingStartedWithFilters

Filters samples associated with MSDN article
C#
67
star
24

AspNetCoreRouteDebugger

An ASP.NET Core Route Debugger implemented as a Razor Page
C#
67
star
25

Ardalis.SharedKernel

Some useful base classes, mainly used with the CleanArchitecture template. Also, a template to make your own SharedKernel nuget package.
C#
56
star
26

MediatRAspNetCore

Sample showing MediatR with ASP.NET Core
C#
50
star
27

DevIQ-gatsby

JavaScript
48
star
28

DomainEventsConsole

A console app showing domain events in action using .NET 5
C#
41
star
29

BuilderTestSample

Show how to use a builder with unit tests.
C#
40
star
30

EFCore.Extensions

Extension methods to make working with EF Core easier.
C#
38
star
31

CSharpGenerics

Some samples using C# generics for a Pluralsight course.
C#
38
star
32

Ardalis.ApiClient

Some classes to make working with APIs easier.
C#
33
star
33

TestPatterns

Examples of approaches to unit testing different kinds of code in C#.
C#
33
star
34

StatePattern

An example of the State design pattern in C#
C#
30
star
35

MinimalWebApi

A minimal Web API for ASP.NET Core
C#
29
star
36

BlazorAuth

A sample showing how to add ASP.NET Core Identity auth options to the basic Blazor app.
C#
27
star
37

EditorConfig

A sample editorconfig file for use with .NET / C# applications
27
star
38

DevResources

A list of links to resources.
26
star
39

NotFoundMiddlewareSample

Middleware for detecting and correcting website 404 errors.
C#
25
star
40

DomainModeling

Some examples showing domain modeling tips and traps
C#
21
star
41

AggregateEvents

A sample showing how to use domain events within aggregates
C#
19
star
42

Specification.EFCore

Some utilities for EF Core to use Specifications
C#
16
star
43

LazyLoading

C#
16
star
44

TestSecureApiSample

A sample showing how to test a secure API endpoint using xunit, identityserver4, and environment variables
JavaScript
15
star
45

EulerCSharpStarter

A starting point for solving Project Euler problems using C#.
C#
14
star
46

EnumAlternative

A sample demonstrating strongly typed C# alternatives to enums.
C#
13
star
47

RouteAndBodyModelBinding

A model binder for ASP.NET Core that supports pulling in values from the route and body of a request.
C#
13
star
48

DoubleDispatchSamples

Some examples of double dispatch in C# and how to use in domain models.
C#
13
star
49

ardalis-com-gatsby

Back end content for ardalis.com running with Netlify and Gatsby.
JavaScript
12
star
50

GildedRoseStarter

A starting point for the Gilded Rose kata using dotnet core, C#, and xunit.
C#
11
star
51

ValueObjectsDemo

C#
10
star
52

MongoDbDotNetHelloWorld

Demonstrating how to get started with MongoDB as quickly as possible in dotnet
C#
10
star
53

TestingLogging

A sample showing how to test logging is working as expected in ASP.NET Core apps.
C#
10
star
54

GuardClauses.Analyzers

A project for holding Roslyn analyzers that leverage Ardalis.GuardClauses
C#
10
star
55

ValidateModel

A very small library/package that includes a model validation attribute for ASP.NET Core projects.
C#
9
star
56

RegExLib.com

Source code for the regexlib.com regular expression library site.
C#
9
star
57

SoftwareQualityWorkshop2020

Public resources supporting private software quality workshops I'm delivering in 2020.
C#
9
star
58

RepoMultiImplementation

C#
8
star
59

MediatREndpointsSample

A sample using MediatR to map endpoints using minimal apis
C#
8
star
60

DomainEventsDemo

A sample project showing how to wire up Domain Events
C#
8
star
61

MessagingDemo

C#
8
star
62

RefactoringKataAttempts2024

C#
8
star
63

AspNetCoreNewIn21

Samples showing what's new in ASP.NET Core 2.1
JavaScript
7
star
64

CSharpPropertiesExamples

Some examples of when and how C# properties work in different application scenarios.
C#
6
star
65

EulerNodeStarter

A starting point for solving Project Euler problems using node.js
JavaScript
6
star
66

RefactoringSamples

C#
6
star
67

UnitTestPerf

Some projects used to demonstrate the performance of different unit testing frameworks for .NET Core
C#
6
star
68

AccessTokenSample

A small sample showing how to create, manage, use access tokens.
C#
6
star
69

IntegrationEventSample

Sample showing Domain Events and Integration Events with Web API 2
C#
6
star
70

azure-cloud-native-book

5
star
71

ExtensionMethodSample

Some simple extension method samples
C#
5
star
72

Cachify

A .NET library to optimize data and reflection-based operations using caching.
PowerShell
5
star
73

Refactoring-To-SOLID-Pluralsight

Resources for my Pluralsight course on Refactoring to SOLID C# Code
C#
5
star
74

CodinGameFall2022

C#
5
star
75

EFCoreOwnedEntityTests

A unit test project that tests owned entities in EF Core
C#
5
star
76

EFCoreStringInterpolationDemo

Showing new EF Core 2.0 feature for raw SQL queries
C#
5
star
77

Diagrams

Text and images from UML and similar diagrams
5
star
78

RedisDotNetHelloWorld

Getting started with Redis in dotnet
C#
5
star
79

WhenAllTest

A simple app showing perf gains of using WhenAll for parallel task execution.
C#
5
star
80

AdventOfCode2022

Working on this: https://adventofcode.com for 2022
C#
4
star
81

ardalis

4
star
82

StructureMapLoggingSample

C#
4
star
83

ConsoleLoggingSample

A sample using NLog to create custom loggers that include app-specific data in the output.
C#
4
star
84

ValidationRules

A collection of validation rules for VS Web Tests
C#
3
star
85

CraftsmanshipCalendarIdeas

Ideas for next year's software craftsmanship calendar
3
star
86

CodinGameSpring2021

C#
3
star
87

Logging

Some logging utilities for .NET Core
C#
3
star
88

MigrateDotNetWithIIS

JavaScript
3
star
89

CastleWindsorSample

A console app showing the basic setup of Castle Windsor for IOC
C#
3
star
90

GeekDinnerSample

An incomplete sample showing clean code and DI in ASP.NET Core
C#
3
star
91

RegExLib

Regexlib.com source
C#
3
star
92

MontyHallMvc

An ASP.NET MVC application that lets users try out the Monty Hall problem and shows their stats.
C#
3
star
93

yarp-passthrough

The simplest YARP ASP.NET Core app that just passes everything through to another domain.
C#
3
star
94

AggregatePatterns

C#
2
star
95

EulerNode

A node.js implementation of Project Euler problems.
JavaScript
2
star
96

TennisGameKatas

C#
2
star
97

AspNetCoreLabs

2
star
98

EFCoreFeatureTests

Tests demonstrating EF Core features across versions.
C#
2
star
99

TestRepo

Just a repo for testing some things
2
star
100

FizzBuzzVS2015

A sample FizzBuzz kata implementation using VS2015
Smalltalk
2
star