Layers in Clean Architecture Asp.net Core 5

Mahdi Elahi 26 Reputation points
2021-11-27T16:38:05.397+00:00

Hi,
this my layers in clean architecture , see the photo

153064-capture.png

1.Is this clean architecture observed?
2. i want add identity to project , Which layer should I add identity (authentication) to?

ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,192 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Bruce Barker 801 Reputation points
    2021-11-27T20:15:35.337+00:00

    There should be multiple layers for identity. The actual ui will be in the UI layer, but you will have adapters to convert to poco entities that can be passed to business rule layer, which will implement the access rules.


  2. Bruce (SqlWork.com) 56,771 Reputation points
    2021-11-30T17:32:30.873+00:00

    you appear to be using DI with repository pattern, this is slightly different than clean. in clean,

    entity (domain) layer: poco objects with with localized validation rules (formatting etc)
    use cases (business) layer: business logic that performs actions on entities
    controllers layer: adapters to access services like a database databases,
    external layer: ui, rest api, etc

    the logic for a use case is:

    • map request data to entity
    • call adapters get an external data
    • call use case logic
    • map use case response to external data

    an external layer action may require multiple use cases. for example update name in a user record:

    validate access

    • map request to security request
    • call adapter to get user record security object
    • call business rule to valid access

    do name change

    • map request to name change object
    • call adapter to read user entity
    • call business rule apply name change to user entity
    • call adapter to save user entity

    return result

    • map to response