Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…dation into docker-setup
  • Loading branch information
Harish-osmosys committed Feb 15, 2024
2 parents d9e94ed + 0121277 commit 63882e0
Show file tree
Hide file tree
Showing 5 changed files with 133 additions and 0 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@

Dotnet Foundation is a boilerplate project for ASP.NET WebAPI projects. This boilerplate can be used in any .NET project for Osmosys. This project contains common files that can be reused. Objective of building this project is to make it so that people can copy the project and build on top of it.

## Features

This project uses modern features of dotnet such as Clean Architecture and AspNetCore.Identity. To learn more about them, please go through the following documents:

1. [Clean Architecture](./docs/CLEAN_ARCHITECTURE.md)
2. [AspNetCore.Identity](./docs/ASPNETCORE_IDENTITY.md)

## Development Setup

1. Install [VS Code](https://code.visualstudio.com/)
Expand Down
35 changes: 35 additions & 0 deletions docs/ASPNETCORE_IDENTITY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Identity in AspNetCore

## Introduction

ASP.NET Core Identity is an API that supports user interface (UI) login functionality. It helps in managing users, passwords, profile data, roles, claims, tokens, email confirmation, and more.

It is a versatile and powerful tool that empowers developers to implement robust authentication and authorization mechanisms in their ASP.NET Core applications with minimal effort. Its modular and extensible nature makes it suitable for a wide range of web development scenarios.

## Key features

Key features of ASP.NET Core Identity include:

**1. User Management:** It provides APIs and UI components to handle user registration, login, password recovery, and account management.

**2. Authentication and Authorization:** ASP.NET Core Identity supports various authentication mechanisms, including cookie-based authentication and external login providers (such as Google, Facebook, and Microsoft). It also enables role-based authorization, allowing developers to control access to specific parts of the application based on user roles.

**3. Data Storage Abstraction:** It is designed with flexibility in mind and can be configured to use different storage providers for user data, such as SQL Server, MySQL, SQLite, or in-memory storage. This abstraction makes it easy to switch between different databases without changing the application code.

**4. Security Features:** ASP.NET Core Identity incorporates security best practices, such as password hashing and salting, to protect user credentials. It also supports multi-factor authentication for an added layer of security.

**5. Extensibility:** Developers can extend ASP.NET Core Identity by customizing user models, adding additional properties, or integrating with other identity systems.

**6. Integration with ASP.NET Core:** It seamlessly integrates with other ASP.NET Core features and middleware, making it straightforward to incorporate identity management into web applications.

**7. ASP.NET Identity Core UI:** It provides default UI pages for common identity-related tasks, but developers can customize these pages to align with the application's design and branding.

## Conclusion

ASP.NET Core Identity is a membership system that adds authentication and authorization functionalities to ASP.NET Core applications. It simplifies the process of managing user authentication, identity, and access control in web applications.

For more information on AspNetCore.Identity, please check the following links:

1. [Identity in AspNetCore for Dotnet 7](https://learn.microsoft.com/en-us/aspnet/core/security/authentication/identity?view=aspnetcore-7.0&tabs=visual-studio)

2. [ASP.NET Core Identity source code](https://github.com/dotnet/aspnetcore/tree/main/src/Identity)
91 changes: 91 additions & 0 deletions docs/CLEAN_ARCHITECTURE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# Clean Architecture

## Introduction

Clean Architecture is a software design philosophy that prioritizes the separation of concerns, making systems more modular, adaptable, and testable. It advocates for a clear distinction between business rules, application logic, and infrastructure details.

- The primary objective of clean architecture is to ensure that the code/logic remains resistant to change.
- It means that core of the system should be written without direct dependencies.
- So that any future alterations to the development framework or User Interface (UI) can be implemented without modifying the core.
- This means that outer modules depend on the inner core
- It also means that our external dependencies are completely replaceable.

## Architecture Components and Layers

Clean architecture philosophy is that innermost core is independent and surrounding outer layers are depending on inner layers.

![Clean Architecture Diagram Onion View](ca_diagram1.png)
Fig. 1: Clean Architecture Diagram

It is divided into the following parts, going from the innermost layer to the outer parts.

**Core Components**
#### 1. The Domain Layer (Inner Core)

* This layer contains definition of all the objects which represent the business model.
* It also contains the business rules, validations, and domain-specific logic.
* As the innermost layer, it remains independent of infrastructure details.

#### 2. The Application Layer (Outer Core)

* This layer manages application specific business logic and application-specific rules.
* All the application "features" are kept here. It is also responsible for calling all the domain objects and methods.
* It consists of Data Transfer Objects (DTOs), interfaces, and services.
* Interfaces define contracts for interacting with the domain and infrastructure layers.
* Services implement application logic, ensuring separation from infrastructure concerns.

**Components outside the Core**
#### 3. The Infrastrusture Layer

* Infrastructure layer contains the data access logic. It is responsible for modules pertaining to data storage, external integrations, and identity.
* UserRepository serves as the bridge between the application and the data storage mechanism.
* It includes Identity Models, extending the ASP.NET Identity framework.
* It is also used to configure dependency injection for infrastructure services.


#### 4. The Presentation (API) Layer

* This layer is responsible for containing modules which facilitate interaction with the user.
* It is responsible for handling HTTP requests.
* It follows the RESTful API design principles.
* It contains controllers for user management, authentication, and authorization.

> Clean architecture pattern puts the focus on domain (inner circle) and contains various logical components that have well defined interactions with one another.
![Dotnet Foundation Architecture for Project Components](ca_components2.png)
Fig. 2: Components in DotnetFoundation with Clean Architecture

## Advantages of Clean Architecture

**Improved Maintainability**

* By separating the codebase in various logical components and enforcing the dependency rules between them, it becomes much easier to understand and modify the code.
* Abstractions allow you to design your business logic in a flexible way, without having to know the implementation details.

**Modularity and Separation of Concerns**

* Each layer has a specific purpose and is decoupled from the others, making it easier to understand and modify individual components without affecting the rest of the system.
* The modular design enables the user to extend the code easily.
* This modularity also makes it easier to reuse components in other projects.

**Testability**

* As clean architecture poromtes clear seperation of concerns, it facilitates unit testing for individual components
* Clean architecture also makes it easier to test and debug the code.
* The business logic can be extensively tested as the inner core is independent of the architecture of outer layers.

**Scalability**

* The architecture is adaptable to evolving project requirements and scalable for future feature enhancements.
* New features, upgrades, replacements or changes can be introduced without major disruptions to the existing system.

**Increased Flexibility**

* Independence from specific frameworks or technologies allows flexibility in choosing the most suitable tools for each layer.
* Dividing the concerns of different components simplifies updating the code to meet changing requirements.

## Conclusion

Clean Architecture is designed to prioritize maintainability, flexibility, and scalability by enforcing a clear separation between the core business logic and external dependencies, such as frameworks, databases, and user interfaces. It promotes the use of well-defined boundaries between these layers, with each layer having a specific responsibility and the ability to evolve independently. Clean Architecture aims to create systems that are easy to understand, test, and modify over time.

For more information please check the official **Microsoft Documentation** on [Clean Architecture](https://learn.microsoft.com/en-us/dotnet/architecture/modern-web-apps-azure/common-web-application-architectures#clean-architecture)
Binary file added docs/ca_components2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/ca_diagram1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 63882e0

Please sign in to comment.