Skip to content

PedroVentura235/BasicWebApi

Repository files navigation

Clean Architecture Template with .NET

Overview

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.

Features

  • 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.

Installation

Follow these steps to set up the Clean Architecture Template:

  1. Clone or download the template repository to your local machine.

  2. Open a terminal and navigate to the folder where the .sln file is located.

  3. Run the following command to install the template:

    dotnet new install ./
  4. Navigate to the directory where you want to create your new project.

  5. Run the following command to create a new project based on the template:

    dotnet new basic-web-api -n YourProjectName

Usage

After installation, you can start building your application using the provided structure. Here’s a brief overview of the main components:

Authentication with Keycloak

  • Configure your Keycloak instance and client.
  • Update the appsettings.json with your Keycloak settings.
  • Use the provided authentication middleware to protect your endpoints.

Authorization with Permissions and Roles

  • 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.

Source Code Generation

  • 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.

Exception Handler

  • Centralized exception handling middleware is included.
  • Customize the exception handling logic in ExceptionMiddleware.cs.

Excel Import

  • Utilize the provided services to read and process Excel files.
  • Example usage can be found in the Services/ExcelImportService.cs.

Logger

  • Integrated with a logging framework (e.g., Serilog).
  • Configure logging settings in appsettings.json.
  • Use the ILogger interface for logging throughout your application.

DBAccess

  • Set up your database context and entities.
  • Use the provided repository pattern for database operations.
  • Configure connection strings in appsettings.json.

Contributing

We welcome contributions to improve this template! Please submit issues or pull requests on our GitHub repository.

License

This project is licensed under the MIT License. See the LICENSE file for more information.

Contact

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!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages