Welcome to the Clean Architecture Template for .NET! This template is designed to provide a robust starting point for your .NET applications, incorporating several essential features to streamline development and ensure best practices. Key features include authentication with Keycloak, role-based authorization, source code generation, exception handling, Excel import capabilities, logging, and database access.
- Authentication with Keycloak: Seamlessly integrate with Keycloak for authentication.
- Authorization with Permissions and Roles: Manage user access with a flexible role and permissions system.
- Source Code Generation: Automatically generate boilerplate code to speed up development.
- Exception Handler: Centralized exception handling for more maintainable and readable code.
- Excel Import: Easily import data from Excel files into your application.
- Logger: Integrated logging framework for tracking and debugging.
- DBAccess: Efficient database access layer to interact with your database.
Follow these steps to set up the Clean Architecture Template:
-
Clone or download the template repository to your local machine.
-
Open a terminal and navigate to the folder where the
.sln
file is located. -
Run the following command to install the template:
dotnet new install ./
-
Navigate to the directory where you want to create your new project.
-
Run the following command to create a new project based on the template:
dotnet new basic-web-api -n YourProjectName
After installation, you can start building your application using the provided structure. Here’s a brief overview of the main components:
- Configure your Keycloak instance and client.
- Update the
appsettings.json
with your Keycloak settings. - Use the provided authentication middleware to protect your endpoints.
- Define roles and permissions in your application.
- Apply
[Authorize]
attributes to controllers or actions to restrict access. - Manage roles and permissions in your database or configuration.
- Use the provided scripts or tools to generate boilerplate code for controllers, services, and repositories.
- Customize the generated code as needed to fit your specific requirements.
- Centralized exception handling middleware is included.
- Customize the exception handling logic in
ExceptionMiddleware.cs
.
- Utilize the provided services to read and process Excel files.
- Example usage can be found in the
Services/ExcelImportService.cs
.
- Integrated with a logging framework (e.g., Serilog).
- Configure logging settings in
appsettings.json
. - Use the
ILogger
interface for logging throughout your application.
- Set up your database context and entities.
- Use the provided repository pattern for database operations.
- Configure connection strings in
appsettings.json
.
We welcome contributions to improve this template! Please submit issues or pull requests on our GitHub repository.
This project is licensed under the MIT License. See the LICENSE file for more information.
For any questions or support, please contact [email protected].
Thank you for using the Clean Architecture Template for .NET! We hope it helps you build robust and maintainable applications. Happy coding!