Skip to content

The Project Name is a .NET Core 6.x based template that follows a n-layered architecture and includes pre-configured libraries such as Swagger, JWT, AutoMapper, and more. It provides developers with a solid foundation for building robust and scalable applications.

License

Notifications You must be signed in to change notification settings

mak-thevar/core-webapi-boilerplate

Repository files navigation

Build Status Contributors Issues LinkedIn

CoreWebApi-BoilerPlate

Built on .NET Core 6.x, this template follows a n-layered architecture and includes pre-configured libraries like Swagger, JWT, and AutoMapper, among others. It's a reliable starting point for developers seeking to create strong and adaptable applications, offering a simplified development experience.

👩‍💻Are you in need of a frontend solution?

You can access the frontend for this repository at the following link: core-webapi-boilerplate-frontend

📋 Table of Contents

🏁 Getting Started

Prerequisites

🗃️ File Structure

│   appsettings.Development.json
│   appsettings.json
│   CoreWebApiBoilerPlate.csproj
│   CoreWebApiBoilerPlate.csproj.user
│   Program.cs
│
├───BusinessLogicLayer
│   │   PredicateBuilder.cs
│   │
│   ├───DTO
│   │       ApiResponseModel.cs
│   │       CommentRequestModel.cs
│   │       CommentResponseModel.cs
│   │       Constants.cs
│   │       RoleRequestModel.cs
│   │       RoleResponseModel.cs
│   │       TodoRequestModel.cs
│   │       TodoResponseModel.cs
│   │       UserRequestModel.cs
│   │       UserResponseModel.cs
│   │
│   └───Exceptions
│           AppException.cs
│
├───Controllers
│       ApiBaseController.cs
│       AuthController.cs
│       TodosController.cs
│       UsersController.cs
│
├───DataAccessLayer
│   ├───Context
│   │       DefaultDBContext.cs
│   │       SeedingData.cs
│   │
│   ├───Entities
│   │   │   Comment.cs
│   │   │   Role.cs
│   │   │   Todo.cs
│   │   │   TodoStatus.cs
│   │   │   User.cs
│   │   │
│   │   └───Base
│   │           EntityBase.cs
│   │           IAuditedEntity.cs
│   │           IStatusEntity.cs
│   │
│   └───Repository
│       ├───Impl
│       │       RepositoryBase.cs
│       │       RepositoryWrapper.cs
│       │       TodoRepository.cs
│       │       UserRepository.cs
│       │
│       └───Interfaces
│               IRepository.cs
│               IRepositoryWrapper.cs
│               ITodoRepository.cs
│               IUserRepository.cs
│
├───Infrastructure
│   │   AutoMapperProfile.cs
│   │   Configuration.cs
│   │   IdentityClientConfiguration.cs
│   │   JWT.cs
│   │   RegisterDBDependency.cs
│   │   SwaggerGen.cs
│   │
│   └───Middlewares
│           ExceptionHandlerMiddleWare.cs
│
├───Migrations
│       20220716122039_Initial.cs
│       20220716122039_Initial.Designer.cs
│       20220804091809_AddingRole.cs
│       20220804091809_AddingRole.Designer.cs
│       DefaultDBContextModelSnapshot.cs

Installation

  • Clone the repository
git clone https://github.com/mak-thevar/core-webapi-boilerplate.git
  • Open the solution file 'CoreWebApiBoilerPlate.sln' directly in Visual Studio

  • The database is cofigured to use sqllite you can change it to appropriate sql like MSSQL or mysql, the settings can be found on the RegisterSqliteDatabaseContext method in DataLayer\RegisterDBDependency.cs file

        services.AddDbContext<DefaultDBContext>(options =>
        {
            options.UseSqlite(connectionString, options =>
            {
                options.MigrationsAssembly(typeof(DefaultDBContext).Assembly.FullName);
            });
            options.EnableDetailedErrors();
            options.EnableSensitiveDataLogging();
        });
  • The initial seeding data can be found on *DataLayer\Context\SeedingData.cs file

    Show Code

    public static List GetTodoStatus()
        {
            return new List
            {
                new TodoStatus{ Id =1 , Description = "Todo", IsDefault = true},
                new TodoStatus{ Id =2 , Description = "In Progress", IsDefault = true},
                new TodoStatus {Id =3, Description = "Completed" , IsDefault  = true},
            };
        }
    
    public static List<Role> GetRoles()
    {
        return new List<Role>
         {
             new Role{ Id =1 , Description = "Admin", IsActive = true, CreatedOn = DateTime.UtcNow}
         };
    }
    
    public static List<User> GetUsers()
    {
        return new List<User>
        {
            new User{ Id =1 , CreatedOn = DateTime.UtcNow, EmailId = "mak.thevar@outlook.com", IsActive = true, Name = "mak thevar", RoleId =1, Username = "mak-thevar", Password = EasyEncryption.MD5.ComputeMD5Hash("12345678")},
        };
    }
    
  • Now Build the project and run, Initially for the very first time it will create the database and will execute the migration scripts automatically.

✅ Features

  • Uses Serilog for stuctured logging.
  • JWT has been configured for authentication and authorization.
  • Custom request, response and error handling has been configured for maintaning a detailed log of errors and requests.
  • Swagger for API documentation has been added.
  • Entityframework Core has been configured for database communication. (Currently have added SQLLite for sample DB)
  • Follows Repository pattern for the database operations.
  • A Sample controller to Add Todos with Register user and Login User has been added.

🔘 Contributing

Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

📸 Screenshots

login_screen
Login Using Insomnia/PostMan
swagger_doc
Swagger Documentation
RegisterUser
Register User API
swagger_login
Login Using Swagger

🎫 License

Distributed under the MIT License. See LICENSE for more information.

📱 Contact

Name - Muthukumar Thevar - mak.thevar@outlook.com

Project Link: https://github.com/mak-thevar/core-webapi-boilerplate

About

The Project Name is a .NET Core 6.x based template that follows a n-layered architecture and includes pre-configured libraries such as Swagger, JWT, AutoMapper, and more. It provides developers with a solid foundation for building robust and scalable applications.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages