The ULTIMATE Clean Architecture Project Template for .NET

Поделиться
HTML-код
  • Опубликовано: 3 дек 2024

Комментарии • 77

  • @nickchapsas
    @nickchapsas 10 месяцев назад +38

    Good to see you back man ❤

  • @indeem1507
    @indeem1507 10 месяцев назад +3

    I actually love how the Authentication is done Here. I have a quite similar Solution Template where much more things are Automated, especially the repository with caching, but authentication is a Part i am missing currently.

  • @liordagan5098
    @liordagan5098 10 месяцев назад +12

    FYI, I don’t need a reminder to tell you I love you 🤣

    • @amantinband
      @amantinband  10 месяцев назад +8

      Oops I put your name? wrong wife

    • @vikashplayer
      @vikashplayer 10 месяцев назад

      What a tribute

    • @chungpunng7516
      @chungpunng7516 7 месяцев назад

      😅😅wow​@@amantinband

  • @danielolajumoke4389
    @danielolajumoke4389 10 месяцев назад

    Hello Ami, it's great to have you back man. Just to be sure and for the sake of other viewers who will be watching this, the step involving the conversion of incoming requests into commands or queries does not necessarily imply the usage of the CQRS architectural pattern. Does it?

  • @xelaksal6690
    @xelaksal6690 5 месяцев назад

    Thanks, one of the most clear templates on internet!

  • @thedude6810
    @thedude6810 5 месяцев назад

    so many clean architecture templates out there, i will take a look

  • @brunocandia703
    @brunocandia703 5 месяцев назад

    nice video, I have a question, if I have some azure durable functions with service bus triggers that handle business processes, where would you locate them?

  • @ahmad.mozaffar
    @ahmad.mozaffar 10 месяцев назад +2

    Thanks,
    What do you think about using the domain models directly as the database entities or creating a persistence model for the database and then mapping them back and forth between domain to db entity and vice versa?
    I saw it as a challenge in real-world apps when having a complicated domain entity to be used directly as a database entity, at the same time, the mapping between domain models/persistence models also a challenge sometimes

    • @amantinband
      @amantinband  10 месяцев назад

      Configuring the mapping between domain objects and the database is very flexible with EF Core. Personally, I dislike creating and maintaining another set set of persistence models.

  • @pazzuto
    @pazzuto 10 месяцев назад +2

    Great template! Very close to Jason Taylor's with a few tweaks. One thing I'm surprised about the sample code is the Amichai allows Entities to be created in an invalid state. I can create a Reminder with a NULL text field, or a user with NULL first, last, and email. Obviously not an issue with the template, just an observation of the sample code.

    • @amantinband
      @amantinband  10 месяцев назад

      Yep our templates have many similarities and I reused a few of his great ideas. Regarding entity construction, you can definitely re-validate the validations done early up stream if you think it adds value to your project/team.

  • @zachedo3538
    @zachedo3538 6 месяцев назад

    That's great video Amichai 🙂

  • @ayalamac
    @ayalamac 8 месяцев назад

    Hey Amichai, I am having a lot of trouble trying to deploy this demo on K8s. Can you give a couple of tips? I am just trying to create an image based on your docker file but it is not working. I want to show my boss that this should be how to work properly. But still, no luck deploying

  • @nareshyalagala
    @nareshyalagala 9 месяцев назад

    Help. My authorization not working. Did anyone has same issue ?I implementing IAuthorizable on one of the request and added Authorize attribute. I did register openbehaviour Authorization. What am I missing. IAuthorizable should be added somewhere ?

  • @pok7835
    @pok7835 7 дней назад

    Logic in the domain ?
    I though that the logic was suposed to be in the application layer, can you please give me a insight brother?
    Thank you and sorry for the poor english. Im trying to improve it.

  • @MarvijoSoftware
    @MarvijoSoftware 5 месяцев назад

    Nice one Amichai. I review such templates. Heads up: I noticed the short name clashes with Steve "Ardalis" Smith's template (clean-arch), so they don't work on the same machine in parallel unless you specify the full name.
    I'm especially interested in how you handle repository querying/specifications; Ardalis' Specifications library being on my lookout.
    I'll give a proper review after trying this out in use cases

  • @munirmohamed1494
    @munirmohamed1494 7 месяцев назад

    Thanks Amichai, wish to make a playlist for real-time in .Net

  • @nareshyalagala
    @nareshyalagala 10 месяцев назад

    In your clean architecture tutorial playlist you used Aggregator pattern. Here you dont have that. any specific reason for that ?

  • @hakanakdag9491
    @hakanakdag9491 10 месяцев назад +2

    too sad that such monolithic architectures era is ending. I wonder how we can apply this to a microservice approach.

  • @tunchy
    @tunchy 8 месяцев назад

    Can you provide a quick comment on why you are seperating the API requests and responses in an other class lib.? It looks neat but is it the only reason?

  • @davidjiang7929
    @davidjiang7929 10 месяцев назад

    great to see you making another video!😊

  • @mohandassselvakumar5557
    @mohandassselvakumar5557 8 месяцев назад

    May I know how the AppDbContext works in Repository without constructor?

  • @HomeSlize
    @HomeSlize 10 месяцев назад

    Good content. Thanks! Definitely some nuggets of information that I can use in my Clean Architecture journey.

  • @gzdoggie
    @gzdoggie 10 месяцев назад

    Cool template, mine's pretty close, but I learned some new stuff to add to mine from yours! Thank you

  • @LoZioIAR
    @LoZioIAR 10 месяцев назад

    Welcome back!!

  • @kmcdo
    @kmcdo 10 месяцев назад +1

    We came up with an almost identical project arrangement in a new solution recently. I remember a lot of discussion around having separate Domain and Application project layers. We ended up having a single project for domain and application because it didn’t seem like having two added much value. Obviously every project has different needs, but when do you think it makes sense to truly separate the Domain from Application?

    • @alissoncandatem1896
      @alissoncandatem1896 10 месяцев назад +2

      I think the commands and everything else should only be on the application layer since the domain does not need to be concerned about that. The domain should be only concerned about business rules.

    • @amantinband
      @amantinband  10 месяцев назад +1

      Both are good approaches, and there are multiple templates that have a single project (usually named "core") for both the Application and Domain logic.
      Personally, I much prefer the separation. As Alisson said, the domain should contain the business logic and rules, while the application layer is just the orchestrator of the various domain objects and services. The project separation forces this separation of concerns and limits the domain layer from having access to all the various application layer interfaces

    • @kmcdo
      @kmcdo 10 месяцев назад +1

      Makes sense. For our solution, the “domain” is largely dumb models for state and business logic Action (or “service”) classes. But if CQRS or DDD come into the picture, I can see some value in having separate projects

  • @kinax2
    @kinax2 10 месяцев назад

    אחלה ווידאו :) , אני ממליץ לך להשתמש ב minimal api, זה נכנס חזק עכשיו

  • @ghaiath-altrabulsi
    @ghaiath-altrabulsi 10 месяцев назад

    Nice video. Thanks. May I ask, how do you make these explanations, arrows and boxes in live video?

    • @amantinband
      @amantinband  10 месяцев назад

      Thanks. I use Presentify (macOS only)

  • @MohamedOmar-zw2bq
    @MohamedOmar-zw2bq 10 месяцев назад +1

    Very cool and organized structure 👍, I will check it in my next projects.
    Could you please tell me what this tool that you used to highlight and write on screen, I like it.

  • @yunietpiloto4425
    @yunietpiloto4425 10 месяцев назад

    Thanks for sharing. This is great!

  • @ahdbenkheder
    @ahdbenkheder 10 месяцев назад

    Great video 🎉 you are using wich tool to draw arrow and box on your screen ?

    • @amantinband
      @amantinband  10 месяцев назад +1

      Thanks. I use Presentify (available only on macOS)

  • @boring91
    @boring91 10 месяцев назад

    I noticed that the logic of the commands is in the domain class User (e.g., DismissReminder). I'm a little confused now, isn't the application's layer job to handle the logic? Why do we have that in the domain layer instead?

    • @amantinband
      @amantinband  10 месяцев назад +2

      No. Taking the method you gave as an example:
      public ErrorOr DismissReminder(Guid reminderId)
      {
      if (Subscription == Subscription.Canceled)
      {
      return Error.NotFound(description: "Subscription not found");
      }
      if (!_reminderIds.Contains(reminderId))
      {
      return Error.NotFound(description: "Reminder not found");
      }
      if (_dismissedReminderIds.Contains(reminderId))
      {
      return Error.Conflict(description: "Reminder already dismissed");
      }
      _dismissedReminderIds.Add(reminderId);
      _domainEvents.Add(new ReminderDismissedEvent(reminderId));
      return Result.Success;
      }
      The application layer's responsibility is to orchestrate the domain objects (i.e. fetch the user domain object from the database and invoking the DismissReminder method).
      The actual decision if the reminder can be dismissed, is the responsibility of the domain. All the various actions that change the underlying state of domain objects is considered domain logic and is encapsulated inside the domain objects or services.

    • @boring91
      @boring91 9 месяцев назад

      ​@@amantinband Thanks, that cleared some of the confusion regarding the role of the application layer. I still have some concerns that putting the logic inside the domain layer might cause some issues (for instance, what if we needed to access a service using dependency injection?)

  • @indeem1507
    @indeem1507 10 месяцев назад

    How do you Return a qualified not authenticated http response for your Controllers when using mediatr middleware to check

    • @amantinband
      @amantinband  10 месяцев назад +1

      Authentication is done using the built in middleware. Authorization is done via the mediatr middleware, and there is a mapping between the ErrorOr.Unauthorized error type to the Forbidden status code in the base controller

  • @bobek8030
    @bobek8030 10 месяцев назад

    Where would you locate hubs from signalr?

    • @amantinband
      @amantinband  10 месяцев назад +2

      src/CleanArchitecture.Api/Hubs/YourHub.cs

  • @ricardoribeiro4560
    @ricardoribeiro4560 10 месяцев назад

    Just one question, I saw that the permission goes in the claims, when the project scales this could be a problem because it could end up with too many permissions, slowing down all requests because the token is very large. Will it be possible to change it so that it is validated in the persistense or identity, based on a userid from the claims?

    • @amantinband
      @amantinband  10 месяцев назад

      This would work only if you are also the identity provider. Otherwise, you don't hold or manage the user's permission/roles. If you're also the identity provider, then yeah sure, you have access to all the data you need to authorize or forbid access based on the user id

    • @theHenrik
      @theHenrik 10 месяцев назад +1

      @@amantinband that might not be entirely true. I have a project where Azure AD B2C is responsible for authentication, and then an implementation internally in the API is responsible for managing users' permissions. This separation between authentication and authorization is preferable, in my opinion. My project don't need to be the identity provider for that to work, I only need to manage the authorization part.
      This also makes the permission evaluation perform well also for larger projects where a single user potentially ends up with thousands of granular permissions on different resources (e.g. a user has "manage" permission on one resource, but only "read" on another resource, etc).

    • @amantinband
      @amantinband  10 месяцев назад +1

      You're right, I said "if you're also the identity provider" and should have said "if you also manage the user's permissions". Thanks for the correction 🙂

  • @andresisas6915
    @andresisas6915 10 месяцев назад

    You are the best!

  • @thijsvandervegt3377
    @thijsvandervegt3377 10 месяцев назад

    Does anyone know how Amichai draws those arrows/ boxes? Is that a program or smth?

    • @amantinband
      @amantinband  10 месяцев назад

      Presentify (macos only though). If you're on windows, check out zoomit

  • @theHenrik
    @theHenrik 10 месяцев назад

    Thanks for both the video and source code! 🙌
    Do you happen to have any other videos / good resources more specifically on the policy implementation and how policies can be structured for scalability, simplicity and maintainability?

    • @amantinband
      @amantinband  10 месяцев назад +1

      Thanks. Didn't create one yet. I have it planned for the future but it's not prioritizing since I think it's more niche than others planned

  • @timur2887
    @timur2887 10 месяцев назад

    Thank you!

  • @quicoll14
    @quicoll14 9 месяцев назад

    Why do you place your repository interfaces in Application instead of Domain layer?

    • @meetingattender8132
      @meetingattender8132 8 месяцев назад

      B/c that's the correct think to do

    • @quicoll14
      @quicoll14 8 месяцев назад

      I do not think so. If you see the books they place it in the domain because repository operations should come from the ubiquitous language, contained by the domain. Also, putting them in your domain makes you able to use the interfaces in domain services.

  • @ashil816
    @ashil816 10 месяцев назад

    Great content🙂! I'm curious, will there be a sequel to your DDD and Clean Architecture courses on DomeTrain? It feels like some key pieces are still missing, particularly on the unhappy path
    1) Eventual consistency within the domain while processing the domain events goes wrong(just sending an email is not realistic, what if we need to roll back) 2.Integration events handling and transactions between microservices(MassTransit with Outbox and Saga patterns?)

    • @amantinband
      @amantinband  10 месяцев назад

      Thanks Omid! Yep, there will hopefully be two follow up courses on the DDD course.

  • @punkouter24
    @punkouter24 10 месяцев назад

    would love a simple blazor frontend

  • @kennethcanet1633
    @kennethcanet1633 4 месяца назад

    discount code invalid.

  • @shayvt
    @shayvt 10 месяцев назад

    Great courses in dometrain 🔥

  • @edfsoft
    @edfsoft 10 месяцев назад

    I wonder why most authors expose foreign keys in entities when representing relationships.
    For example:
    Why not
    private readonly List _reminders = [];
    Instead of
    private readonly List _reminderIds = [];

    • @jeffreyvdb
      @jeffreyvdb 10 месяцев назад +3

      The .NET Microservices: Architecture for Containerized .NET Applications ebook says:
      A DDD domain model is composed from aggregates, an aggregate can have just one entity or more, and can include value objects as well.
      In order to maintain seperation of aggregates and keep clear boundaries between them, it is a good practice in a DDD domain model to disallow direct navigation between aggregates and only having the foregin key (FK) field.

    • @edfsoft
      @edfsoft 10 месяцев назад

      @@jeffreyvdb Thanks for your answer.
      Another thing that called my attention in several examples, is the use of the foreign key, and also the entity, to represent a relationship.
      For example:
      public class TodoItem
      {
      public int Id { get; set; }
      public int ListId { get; set; }
      public TodoList List { get; set; } = null!;
      }
      I wouldn't add ListId property. It sounds more like a database concept to me.
      What is the advantage of adding the foreign key in this case?

  • @Tony-dp1rl
    @Tony-dp1rl 10 месяцев назад +1

    Clean Architecture was nice in its time when we were working on larger monolithic OOP applications. Not so much value today.

    • @amantinband
      @amantinband  10 месяцев назад

      it definitely depends both on the project and (more importantly IMO) the team

  • @stevenj8261
    @stevenj8261 10 месяцев назад

    Having infrastructure is debatable. I love to have each domain completely independent from each other. Having contracts only to interact with it. Inside domain in a namespace is infrastructure code. Likewise each domain does not rely on common table or infra. Goes into this modular monolith. Even endpoints could be out of API in a separate project to leave api just a dumb shell and bootstrap

  • @Suriprofz
    @Suriprofz 10 месяцев назад

    Mwahh prefer DDD, this seems so hackish

  • @alexwerf6084
    @alexwerf6084 10 месяцев назад

    I think sometimes that .Api and .Application levels must be named in some other manner.
    Because i had some cases when it was useful to code several applications sharing the same domain.
    For example, CRUD service (working with database as signgle replica), some business service (working with message brokers as several replicas) and may be can exist some desktop application like WPF- or Avalonia- based application.
    The exact structure of services can be re-organized after changing of actual production workload, but it`s definetely cannot be the reason to change domain - just re-structure applications that use this domain.
    So i think that top level project can be named not only as .Api, but also as .App. It would be very convenient. But in this case, it would be similarity between .App and .Application. So the idea is not completely good. I would hear some sample of such cases, because i think that Clean Arch is mos powerful exactly in sutuations with multiple Api or applications with shared domain, in this case some architecture levels becomes more justified.

    • @amantinband
      @amantinband  10 месяцев назад

      I agree. It's project dependent

  • @AmreshKumar-so7ri
    @AmreshKumar-so7ri 9 месяцев назад

    Hello sir, I was a member on patreon but due to some financial issue it will not be possible to continue membership and a also want to study Deep Dive: Clean Architecture in .NET course but i'm not able to pay you as course fee $89.99 could you provide me low fee for that course.

  • @hassejansson
    @hassejansson 10 месяцев назад

    "ultimate"? 😶