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.
You can access the frontend for this repository at the following link: core-webapi-boilerplate-frontend
│ 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
- 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
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 = "[email protected]", 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.
- 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.
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.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Login Using Insomnia/PostMan |
Swagger Documentation |
Register User API |
Login Using Swagger |
Distributed under the MIT License. See LICENSE
for more information.
Name - Muthukumar Thevar - [email protected]
Project Link: https://github.com/mak-thevar/core-webapi-boilerplate