Hey friends, Because it was mentioned in the comments, I want to talk about why I chose to show the presentation layer directly referencing the infrastructure layer for service registration in this tutorial. This is a practical approach I picked to keep things simple, especially for educational purposes. It's something you'll see in a lot of .NET projects because it makes setting up services straightforward, thanks to ASP.NET Core's dependency injection. I aim to make my tutorials helpful for developers at any level, and sometimes that means choosing simplicity over strict adherence to principles like Clean Architecture. However, I get the concerns about layer separation and plan to explore more about Clean Architecture in future videos. Thanks to everyone for the feedback. It really helps guide what I cover next and makes our discussions here richer. Appreciate all of you being part of this community and helping each other learn and grow. Take care & happy coding, Patrick
Patrick, could you extend this video and discuss the next steps like adding authentication + db + EF, which project those belong in, and how they can be used in the Application layer. Thanks mate.
EF Core is integrated really easily, you usually put it in the infrastructure project or a separate Data Layer. You register the Database and DbContext in the middleware inside Program.cs using the built-in dependency injection. Then in the application layer, make yourself a bootstrapper class that uses the IServiceCollection and IServiceProvider interfaces. The former to map the instances to an interface or on their own, and the former to use them in your main execution path. And for testing purposes you make a Repository, which is a bit redundant since it's EF-core, but that repository then makes unit and integration testing much easier due to the fact that you can write stubs and mocks much more easily with it.
I think it would be great to see more real world examples using blazor, clean architecture with CQRS etc. Everyone is doing the basic out of the box type videos on .net 8 blazor. It would be great if you would go more in depth and to see an actual enterprise level application with UI customization. It would also be great to see how to structure nested components when you are using interactive blazor with something like mudblazor theming etc. Thanks @PatrickGod!
Great video it would be good if you could create a longer video on this with Mediatr etc. and show how we can make it into a template so it’s easier to start new projects
@@PatrickGod Yes, I also agree. I'm also new to Blazor and I found this video interesting, and inspired me how to start working with Blazor applications.
Very informative video as usual Patrick, I'd love to see more videos about Clean Architecture in Blazor 8, I'm still having some issues with that, especially on auto render mode with .Client and .Server projects. Thanks for all your work and help to the Blazor community.
For most projects CQRS & mediator are just over cooking for no benefit. In fact I've yet to see any benefit, happy to be corrected, I mean it must work for some for it to still exist...
Hey Patrick, I hope I did not miss this, but could you please make a video about login and user management in Blazor SSR? I really enjoyed your video about the CRUD system in SSR, but I need a login for that. Thank you really much for all your amazing courses! Have a nice weekend!
Sorry to be late to the comments. How would your Architecture work with MS Identity? Its heavily tied to both AspNet and EF. So how can you create a DataContext inside the Infrastructure Layer that has all these AspNet dependencies?
@PatrickGod Congrats on another great video! It would be even better if you show us a sample from presentation layer through mediatr showing how you would do a query and a command through the domain and infrastructure. Really just a CRUD sample, i really get everything you showed us here but i believe a jr might need more clues
I'm curious as to why Infrastructure wouldn't just be a layer on it's own? Why on the same level as the UI? To me, it would seem to make sense to keep services (in the infrastructure) below the UIs (the UI could then be for any UI system - web, desktop, mobile, etc)
This is a great video, I recently upgraded my project from .net 6 to .net 8 and due to the massive amount of changes, I had to almost build most of it over.. Not to mention moving to MudBlazor or any other UI Framework. My question is : 1. Would you suggest to have a the foundation in place like in the video, do a Git checkin and then work on top of it with branches? 2. Would you suggest to make use of Git Submodules to split out the project each in their own life cycle so that you can make an update to lets say the domain project and it will be updated on the other modules that might be a legacy blazor application and the latest .Net Blazor version?
I think devs get into a lot of navel gazing when it comes to architecture/design patterns, etc. I would like to see comparison videos discussing PRACTICAL scenarios between the patterns. When it is worth my time as a developer to implement one pattern over another? Where is the point of diminishing returns when introducing more complexity?
Great starting point. In a real-world scenario, I would create a folder for the Infrastructure layer and add in this folder several infrastructure projects like Persistence, FileProvider, ecc. Keep it going!
Idk, don't love folders other than src, test, doc, top level whatever. Also, solution folders aren't "real" folders, so I tend to use real folders, so people using vs code still have the same folder instruction as the solution explorer has. I also don't include the solution name as part of the project name, but in the proj file I add it to the DLL name that is created on build. So, I might have projects named: Domain Application Contracts Web or Api Infra.Persistence Infra.Integration.Twitter Infra.Integration.GitHub But you know to each his own.
@@dondaniel7643 in structured solutions I don't like to have a single infrastructure project for everything. For example, I usually separate data persistence and files management in different projects (both of them are into the infrastructure folder).
I've been struggling with EF in Blazor, I have a base page that creates the context from IDbContextFactory and stored as Db on a base property. I find at times its disposed before I can use it. I've restored to injecting the context on to each page or component instead create a using statement to create the context each time. Is this best practice? The EF documentation isn't clear to me. Also should I use IDbConextFactory on DI service constructors or a Context again unclear. Thanks.
Clean Architecture is a classic solution looking for a problem. It'll certainly soak up all those man hours of developers having meetings discussing it and working out what it does, rather than working :DDD
Exactly. In the domain layer, you put your entities (like customer, order, article, player, item) and the interfaces for services or repositories. This means you define how things work and the main rules here, keeping your app organized and easy to work with.
@PatrickGod Hi, I used to create an Web Api with a clean architecture as backend and React as frontend for example. However, with the new hybrid model (Server and Client), it is worth to separate the backend with the server project? It is also recommanded to create an API on server side and call it with a http client in client project. I have a to create a MVP for my startup and I'd like to go with Blazor as Frontend technology but don't practise frontend since 2 years (last time react, but I used Blazor in 2020). For a MVP context, it is better tu create a third project Web API as backend and call it in Blazor server project or I should simplify and create my clean architecture directly in Blazor server project?
Thanks, that was very interesting. I since i would also have a corresponding webui project would you say that the api and ui can share the domain layer, or sould each of them have its own domain layer (also if this would mean duplicate code)?
Hello, my Program.c from my blazor web app not recognize the dependecy injection class method (AddApplication), all is equal to the video the only difference is my Blazor project is a Auto render so i have a client project to. What could be the problem? Best Regards
Great video! I have been struggling with where to put the API I will need to expose. Based on what you said (and what is probably coming in the more in-depth video) but I assume it would be a folder in the WebUI.Server project? Which references a Repository in the Application project which in turn references a Service in the Infrastructure project?
Excellent video, however to short video. I would definitely like to see more of this, especially in regards to CQRS and Mediator pattern inside a Blazor app. I feel like my architecture skills are more or less stuck at n-tier pattern, and i would like to learn about clean archtecture (incl. vertical slice). By the way will you be dealing with this kind of subjects in your dotnet academy. Would you kindly provide a detailed list of the subjects that you will be touching in your dotnet academy.
Thank you so much for your feedback, Mohammad! Yes, the second masterclass dives into more advanced topics such as Clean Architecture, CQRS, and the Mediator pattern. It's currently in early access, but the basics of these topics are already available. I'd be thrilled to have you join us at the .NET Web Academy! 😊
Hi, I am beginner but I wrote my first Blazor Web App and I want to ask how can I upload it to internet? Which type of hosting should I buy and which program to transfer files. I really have no idea where to start
Hi Patrick first of all you are awesome and please please extend that video with mediatR and CQRS I really need it and if it is possible please use .net 8 blazor auto mode. I am trying to create an application using and since I am quite a beginner in this I am having a really hard time.
Is there a special reason why the Solution name is dublicated to all the projects? - I find it cumbersome to have to have these long names. Like having a solution called "ThisIsMyVeryCumbersomeAndLongName" and then have to repeat that in every project like "ThisIsMyVeryCumbersomeAndLongName.Application" and "ThisIsMyVeryCumbersomeAndLongName.Infrastructure" etc etc...
Hey Patrick, it's wonderful video tutorial, I was wondering if you have some course where learn master-details, pattern repository, mudblazor or any other with blazor server 8. I try to subscribe me in academy but unfortunately is so expensive for me because our divisa is lower than respect to usd, however if you have some course on udemy with cupon and include the topics before mentioned, I'll appreciate so much. Tks DC
U don't need to replicate the application name in the projects like that. You can just call the projects domain or application then set the app name and namespace in the properties. Looks much cleaner
What a way to give developers blue balls =). I was so ready to keep building the project as im still a little confused how to provide services to my client WASM without the use of controllers on a separate server project.
who invented those layers? they are mega confusing. theres always business logic and data structure controlled by UI wasn't dependency injection created just to avoid that confusion of layers you present?
I have understood all your other videos, but this was way too advanced. Could you make a longer video, perhaps more beginner-friendly? Explaining the purpose of Application, Domain and Infrastructure projects etc...
Don't waste time on architecture. Build a monolith first and thing on the simplest possible terms. By time if you see your app become too complex to handle, do something about it. What and how is difficult to say. There is no magic bullet! Easier said than done! :)
Thought for a second that I finally found a proper video for .net 8 on this topic, since I really liked your other tutorials. But the moment I saw the presentation layer having a direct dependency to infrastructure layer, immediately turned it off. Following clean architecture, dependencies should go only inwards, otherwise it makes the application tightly coupled, when they should be independant from one another. If you personally are making shortcuts, at least do not guide others to a bad direction. Just mention that this is not a 100% correct way.
Hey there, thanks for your feedback. The approach I showed in the tutorial, where the presentation layer references the infrastructure layer for service registration, is a practical choice for simplicity and educational purposes. It's a common method in .NET, especially with ASP.NET Core's dependency injection, to make service registration straightforward. This approach is often used in the industry for its simplicity and maintainability, considering the specific trade-offs. The goal of my tutorials is to simplify complex concepts for developers at all levels. I value your feedback and plan to explore the nuances of Clean Architecture more in future videos. Your insights contribute to a deeper, more nuanced discussion on architectural practices. Thanks for watching and pointing this out!
@@PatrickGod thank you for clarifying. I agree that this concept is simpler and easier to understand. I still think that mentioning in the video about making a shortcut would have been nice. Sorry for being too harsh though. I like your content and the way of explaining. (In my opinion, having a video on more decoupled version of clean architecture would be beneficial - there is absolutely no videos about it on youtube).
Hey friends,
Because it was mentioned in the comments, I want to talk about why I chose to show the presentation layer directly referencing the infrastructure layer for service registration in this tutorial. This is a practical approach I picked to keep things simple, especially for educational purposes. It's something you'll see in a lot of .NET projects because it makes setting up services straightforward, thanks to ASP.NET Core's dependency injection.
I aim to make my tutorials helpful for developers at any level, and sometimes that means choosing simplicity over strict adherence to principles like Clean Architecture. However, I get the concerns about layer separation and plan to explore more about Clean Architecture in future videos.
Thanks to everyone for the feedback. It really helps guide what I cover next and makes our discussions here richer. Appreciate all of you being part of this community and helping each other learn and grow.
Take care & happy coding,
Patrick
It would be nice to see a project example, I am new to this architecture. If you have time....
Patrick, could you extend this video and discuss the next steps like adding authentication + db + EF, which project those belong in, and how they can be used in the Application layer. Thanks mate.
EF Core is integrated really easily, you usually put it in the infrastructure project or a separate Data Layer. You register the Database and DbContext in the middleware inside Program.cs using the built-in dependency injection. Then in the application layer, make yourself a bootstrapper class that uses the IServiceCollection and IServiceProvider interfaces. The former to map the instances to an interface or on their own, and the former to use them in your main execution path.
And for testing purposes you make a Repository, which is a bit redundant since it's EF-core, but that repository then makes unit and integration testing much easier due to the fact that you can write stubs and mocks much more easily with it.
I think it would be great to see more real world examples using blazor, clean architecture with CQRS etc. Everyone is doing the basic out of the box type videos on .net 8 blazor. It would be great if you would go more in depth and to see an actual enterprise level application with UI customization. It would also be great to see how to structure nested components when you are using interactive blazor with something like mudblazor theming etc. Thanks @PatrickGod!
Great video it would be good if you could create a longer video on this with Mediatr etc. and show how we can make it into a template so it’s easier to start new projects
Great suggestion! Thanks for your feedback!
@@PatrickGod Yes, I also agree. I'm also new to Blazor and I found this video interesting, and inspired me how to start working with Blazor applications.
It be nice to see an extended video using services and dapper please
YES! Exactly what was going to request.
I'm watching 12 minutes and I have 7 left. I don't want them to run out!!! Please continue with this video!!!
Very informative video as usual Patrick, I'd love to see more videos about Clean Architecture in Blazor 8, I'm still having some issues with that, especially on auto render mode with .Client and .Server projects.
Thanks for all your work and help to the Blazor community.
Noted! Thank you very much for your feedback!
Thx, a very good video ! Is it possible to do one with mediatr and a CRUD to see how all the layers work together. Thx
For most projects CQRS & mediator are just over cooking for no benefit. In fact I've yet to see any benefit, happy to be corrected, I mean it must work for some for it to still exist...
Hey Patrick, I hope I did not miss this, but could you please make a video about login and user management in Blazor SSR? I really enjoyed your video about the CRUD system in SSR, but I need a login for that. Thank you really much for all your amazing courses! Have a nice weekend!
Sorry to be late to the comments. How would your Architecture work with MS Identity? Its heavily tied to both AspNet and EF. So how can you create a DataContext inside the Infrastructure Layer that has all these AspNet dependencies?
I appreciate a lot your explanations of a technology which includes a view on the architecture whose is too often forgotten
@PatrickGod Congrats on another great video! It would be even better if you show us a sample from presentation layer through mediatr showing how you would do a query and a command through the domain and infrastructure. Really just a CRUD sample, i really get everything you showed us here but i believe a jr might need more clues
Thank you for the video! Now I would like to see part 2 using CQRS and MediatR
I'm curious as to why Infrastructure wouldn't just be a layer on it's own? Why on the same level as the UI?
To me, it would seem to make sense to keep services (in the infrastructure) below the UIs (the UI could then be for any UI system - web, desktop, mobile, etc)
This is a great video, I recently upgraded my project from .net 6 to .net 8 and due to the massive amount of changes, I had to almost build most of it over.. Not to mention moving to MudBlazor or any other UI Framework. My question is :
1. Would you suggest to have a the foundation in place like in the video, do a Git checkin and then work on top of it with branches?
2. Would you suggest to make use of Git Submodules to split out the project each in their own life cycle so that you can make an update to lets say the domain project and it will be updated on the other modules that might be a legacy blazor application and the latest .Net Blazor version?
Great work and very important topic may you have to extend the video. Thanks
Thank you, I will
Nice, Great topic Architecture for Blazor, would be awesome if you continue with CQRS.
Thanks, will do!
Thanks for this very interesting video!! You explain even difficult topics in a simple way. A video on CQRS and Mediator would also be very helpful
I think devs get into a lot of navel gazing when it comes to architecture/design patterns, etc. I would like to see comparison videos discussing PRACTICAL scenarios between the patterns. When it is worth my time as a developer to implement one pattern over another? Where is the point of diminishing returns when introducing more complexity?
Great starting point. In a real-world scenario, I would create a folder for the Infrastructure layer and add in this folder several infrastructure projects like Persistence, FileProvider, ecc. Keep it going!
Idk, don't love folders other than src, test, doc, top level whatever.
Also, solution folders aren't "real" folders, so I tend to use real folders, so people using vs code still have the same folder instruction as the solution explorer has.
I also don't include the solution name as part of the project name, but in the proj file I add it to the DLL name that is created on build.
So, I might have projects named:
Domain
Application
Contracts
Web or Api
Infra.Persistence
Infra.Integration.Twitter
Infra.Integration.GitHub
But you know to each his own.
What are the benefits of that? Why not structure your Infrastructure project?
@@dondaniel7643 in structured solutions I don't like to have a single infrastructure project for everything. For example, I usually separate data persistence and files management in different projects (both of them are into the infrastructure folder).
Hi Patrick, hello from Portugal.
What color theme do you use in visual studio 2022?
It would be good to see this in action to get a clearer picture of what goes where and how it all works with a real example. Thanks!
I've been struggling with EF in Blazor, I have a base page that creates the context from IDbContextFactory and stored as Db on a base property. I find at times its disposed before I can use it. I've restored to injecting the context on to each page or component instead create a using statement to create the context each time. Is this best practice? The EF documentation isn't clear to me. Also should I use IDbConextFactory on DI service constructors or a Context again unclear. Thanks.
Clean Architecture is a classic solution looking for a problem.
It'll certainly soak up all those man hours of developers having meetings discussing it and working out what it does, rather than working :DDD
As always a informative video. One question that I don't think you mentioned - what goes in the domain layer?
I believe it’s all of your entities.
Exactly. In the domain layer, you put your entities (like customer, order, article, player, item) and the interfaces for services or repositories. This means you define how things work and the main rules here, keeping your app organized and easy to work with.
Hi Patrick thank you for the video! Please can u make an extended video about CQRS and MediatR.
@PatrickGod
Hi, I used to create an Web Api with a clean architecture as backend and React as frontend for example. However, with the new hybrid model (Server and Client), it is worth to separate the backend with the server project? It is also recommanded to create an API on server side and call it with a http client in client project.
I have a to create a MVP for my startup and I'd like to go with Blazor as Frontend technology but don't practise frontend since 2 years (last time react, but I used Blazor in 2020). For a MVP context, it is better tu create a third project Web API as backend and call it in Blazor server project or I should simplify and create my clean architecture directly in Blazor server project?
Thanks, that was very interesting. I since i would also have a corresponding webui project would you say that the api and ui can share the domain layer, or sould each of them have its own domain layer (also if this would mean duplicate code)?
I would like to see more on CQRS and mediatR
Noted! Thanks for your feedback!
Hello, my Program.c from my blazor web app not recognize the dependecy injection class method (AddApplication), all is equal to the video the only difference is my Blazor project is a Auto render so i have a client project to. What could be the problem? Best Regards
Hey Patrick, will you be covering this in detail in your course site? Cheers and thanks.
Great video! I have been struggling with where to put the API I will need to expose. Based on what you said (and what is probably coming in the more in-depth video) but I assume it would be a folder in the WebUI.Server project? Which references a Repository in the Application project which in turn references a Service in the Infrastructure project?
Any suggestions @PatrickGod
Right, api will be in server.ui
Is there a follow up to this video to show how to bring data from a database into the blazor component
I have been waiting for this vid!
Excellent video, however to short video.
I would definitely like to see more of this, especially in regards to CQRS and Mediator pattern inside a Blazor app.
I feel like my architecture skills are more or less stuck at n-tier pattern, and i would like to learn about clean archtecture (incl. vertical slice).
By the way will you be dealing with this kind of subjects in your dotnet academy. Would you kindly provide a detailed list of the subjects that you will be touching in your dotnet academy.
Thank you so much for your feedback, Mohammad!
Yes, the second masterclass dives into more advanced topics such as Clean Architecture, CQRS, and the Mediator pattern. It's currently in early access, but the basics of these topics are already available. I'd be thrilled to have you join us at the .NET Web Academy! 😊
@@PatrickGod Thanks for your answer, I would gladly join you dotnet academy.
@@mohammadmz1058Awesome! Looking forward to seeing you in the academy! If you have any more questions, drop me a message at mail@patrickgod.com.🎉
Do we need to use such a long names? I would like it make it shorter but maybe I am too primitive.
Would be nice to see UOW / Mediatr worked in the template. Good video, very clear and simple explained!
Hi, I am beginner but I wrote my first Blazor Web App and I want to ask how can I upload it to internet? Which type of hosting should I buy and which program to transfer files. I really have no idea where to start
I used myAsp hosting and was able to publish from VS directly.
This is insane, thank you for the content🔥🔥🔥🔥
My pleasure!😊
So we cant host WASM apps anymore on github pages?
Thank you, I enjoyed it, it was very good, simple and informative
Hi Patrick first of all you are awesome and please please extend that video with mediatR and CQRS I really need it and if it is possible please use .net 8 blazor auto mode. I am trying to create an application using and since I am quite a beginner in this I am having a really hard time.
Nice Patric but I want these CQRS pattern, love your content ❤
Is there a special reason why the Solution name is dublicated to all the projects? - I find it cumbersome to have to have these long names. Like having a solution called "ThisIsMyVeryCumbersomeAndLongName" and then have to repeat that in every project like "ThisIsMyVeryCumbersomeAndLongName.Application" and "ThisIsMyVeryCumbersomeAndLongName.Infrastructure" etc etc...
That was helpful - just about the right level.
I would love to see Mediatr pattern please show it to us thanks for all your efforts
I'd like a part 2
Great video! I love these
Thanks so much! Glad you like them!
you are the best
you are!
Could you please give us a real world example how to benefit from this architecture ? I can not see any advantages using your Extension-Methods...
Hey Patrick, it's wonderful video tutorial, I was wondering if you have some course where learn master-details, pattern repository, mudblazor or any other with blazor server 8. I try to subscribe me in academy but unfortunately is so expensive for me because our divisa is lower than respect to usd, however if you have some course on udemy with cupon and include the topics before mentioned, I'll appreciate so much. Tks DC
U don't need to replicate the application name in the projects like that. You can just call the projects domain or application then set the app name and namespace in the properties. Looks much cleaner
What a way to give developers blue balls =). I was so ready to keep building the project as im still a little confused how to provide services to my client WASM without the use of controllers on a separate server project.
It was great🤩😍, thank you, Please continue this video😢😭
Patrick, please continue. BUT without CQRS and Mediator👌
Very useful
Thanks so much.
I'd love to see more in depth videos regarding Blazor architecture
Noted! Thanks for your feedback!
Please CQRS pattern also
Could you please raise you voice sound in the next videos?
CQRS please...
Noted!
Mean comment, mean comment :)
who invented those layers? they are mega confusing. theres always business logic and data structure controlled by UI
wasn't dependency injection created just to avoid that confusion of layers you present?
awesome
I have understood all your other videos, but this was way too advanced. Could you make a longer video, perhaps more beginner-friendly? Explaining the purpose of Application, Domain and Infrastructure projects etc...
@PatrickGod Bro please add a more detail video about this
20 minutes and you said nothing, how is that even possible?
Ntier is simply better.
Don't waste time on architecture.
Build a monolith first and thing on the simplest possible terms.
By time if you see your app become too complex to handle, do something about it. What and how is difficult to say. There is no magic bullet!
Easier said than done! :)
Thought for a second that I finally found a proper video for .net 8 on this topic, since I really liked your other tutorials. But the moment I saw the presentation layer having a direct dependency to infrastructure layer, immediately turned it off. Following clean architecture, dependencies should go only inwards, otherwise it makes the application tightly coupled, when they should be independant from one another. If you personally are making shortcuts, at least do not guide others to a bad direction. Just mention that this is not a 100% correct way.
Hey there, thanks for your feedback. The approach I showed in the tutorial, where the presentation layer references the infrastructure layer for service registration, is a practical choice for simplicity and educational purposes. It's a common method in .NET, especially with ASP.NET Core's dependency injection, to make service registration straightforward. This approach is often used in the industry for its simplicity and maintainability, considering the specific trade-offs.
The goal of my tutorials is to simplify complex concepts for developers at all levels. I value your feedback and plan to explore the nuances of Clean Architecture more in future videos. Your insights contribute to a deeper, more nuanced discussion on architectural practices. Thanks for watching and pointing this out!
@@PatrickGod thank you for clarifying. I agree that this concept is simpler and easier to understand. I still think that mentioning in the video about making a shortcut would have been nice. Sorry for being too harsh though. I like your content and the way of explaining. (In my opinion, having a video on more decoupled version of clean architecture would be beneficial - there is absolutely no videos about it on youtube).