GithubHelp home page GithubHelp logo

chbasitgill / netcore-api-boilerplate Goto Github PK

View Code? Open in Web Editor NEW

This project forked from yanpitangui/dotnet-api-boilerplate

0.0 0.0 0.0 80 KB

A .net core 3.1 WebApi boilerplate / template project. Repositories, Swagger, Mapper, Serilog and more implemented.

License: MIT License

C# 97.00% Dockerfile 3.00%

netcore-api-boilerplate's Introduction

netcore-boilerplate-api

A .Net Core 3.1 WebApi boilerplate / template project. Repositories, Swagger, Mapper, Serilog and more implemented.

Build and Test License

The goal of this project is to be a kickstart to your .Netcore WebApi, implementing the most common used patterns and technologies for a restful API in .net core, making your work easier.

How to run

  • Use this template(github) or clone/download to your local workplace.
  • Download the latest .NetCore SDK and Visual Studio/Code.

Standalone

  1. You may need a running instance of MsSQL, with appropriate migrations initialized.
    • If you want, you can change the DatabaseExtension to use UseInMemoryDatabase, instead of Mssql.
  2. Go to the src/Boilerplate.Api folder and run dotnet run, or, in visual studio set the api project as startup and run as console or docker (not IIS).
  3. Visit http://localhost:5000/api-docs or https://localhost:5001/api-docs to access the application's swagger.

Docker

  1. Run docker-compose up -d in the root directory, or, in visual studio, set the docker-compose project as startup and run. This should start the application, DB. and Redis cache (optional)
  2. Visit http://localhost:5000/api-docs or https://localhost:5001/api-docs to access the application's swagger.

Running tests

In the root folder, run dotnet test. This command will try to find all test projects associated with the sln file.

This project contains:

  • SwaggerUI
  • EntityFramework Core
  • Code quality ruleset
  • AutoMapper
  • Generic repository (to easily bootstrap a CRUD repository)
  • Serilog with request logging and easily configurable sinks
  • .NetCore Dependency Injection
  • Resource filtering
  • Response compression
  • CI (Github Actions)
  • Unit tests
  • Integration tests
  • Container support with docker and docker-compose

Project Structure

  1. Services
    • This folder stores your apis and any project that sends data to your users.
    1. Boilerplate.Api
      • This is the main api project. Here are all the controllers and initialization for the api that will be used.
    2. docker-compose
      • This project exists to allow you to run docker-compose with Visual Studio. It contains a reference to the docker-compose file and will build all the projects dependencies and run it.
  2. Application
    • This folder stores all data transformations between your api and your domain layer. It also contains your business logic.
  3. Domain
    • This folder contains your business models, enums and common interfaces.
    1. Boilerplate.Domain.Core
      • Contains the base entity for all other domain entities, as well as the interface for the repository implementation.
    2. Boilerplate.Domain
      • Contains business models and enums.
  4. Infra
    • This folder contains all data access repositories, database contexts, anything that reaches for outside data.
    1. Boilerplate.Infrastructure
      • This project contains the dbcontext, an generic implementation of repository pattern and a Hero(domain class) repository.

Adopting to your project

  1. Remove/Rename all hero related stuff to your needs.
  2. Rename solution, projects, namespaces, and ruleset to your use.
  3. Change the dockerfile and docker-compose.yml to your new csproj/folder names.
  4. Give this repo a star!

TODO

  • Finish implementation of integration tests
  • Create an MSSQL DBcontext example
  • Implement redis cache

If you like it, give it a Star

If this template was useful for you, or if you learned something, please give it a Star! โญ

Thanks

This project has great influence of https://github.com/lkurzyniec/netcore-boilerplate and https://github.com/EduardoPires/EquinoxProject. If you have time, please visit these repos, and give them a star, too!

About

This boilerplate/template was developed by Yan Pitangui under MIT license.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.