Code Monkey home page Code Monkey logo

netcore-boilerplate's Introduction

netcore-boilerplate

Boilerplate of API in .NET Core 3.1 .NET 8

GitHub Codecov Docker Hub
Build & Test Build docker image codecov Docker Image Version

Boilerplate is a piece of code that helps you to quickly kick-off a project or start writing your source code. It is kind of a template - instead of starting an empty project and adding the same snippets each time, you can use the boilerplate that already contains such code.

Intention - The intention behind this project is to mix a variety of different approaches to show different available paths. That's why you can find here the Service approach mixed-up with Repository approach, or old-fashioned controllers mixed-up with brand new minimal API in a separate module (modular approach). As well as, it's a kind of playground for exploring frameworks, packages, tooling. At the end, You are in charge, so it's your decision to which path you would like to follow.

Table of content

Source code contains

  1. Central Package Management (CPM)
  2. [Autofac](https://autofac.org/) (Removed in PR19)
  3. Swagger + Swashbuckle
  4. FeatureManagement (Feature Flags, Feature Toggles)
  5. HealthChecks
  6. EF Core
  7. Dapper
  8. Tests
  9. Code quality
  10. Docker
  11. Serilog
  12. DbUp as a db migration tool
  13. Continuous integration

Run the solution

To run the solution, use one of the options:

After successful start of the solution in any of above option, check useful endpoints:

Standalone

When running standalone, features like cars and employees might be disabled.

Execute dotnet run --project src/HappyCode.NetCoreBoilerplate.Api in the root directory.

In docker

When running in docker, features like cars and employees are disabled.

Download form registry

Simply execute docker run --rm -p 5000:8080 --name netcore-boilerplate lkurzyniec/netcore-boilerplate to download and spin up a container.

Build your own image

To run in docker with your own image, execute docker build . -t netcore-boilerplate:local in the root directory to build an image, and then docker run --rm -p 5000:8080 --name netcore-boilerplate netcore-boilerplate:local to spin up a container with it.

Docker compose

When running on Linux (i.e. WSL), make sure that all docker files (dockerfile, docker-compose and all mssql files) have line endings LF.

Just execute docker-compose up command in the root directory.

Migrations

When the entire environment is up and running, you can additionally run a migration tool to add some new schema objects into MsSQL DB. To do that, go to src/HappyCode.NetCoreBoilerplate.Db directory and execute dotnet run command.

How to adapt

Generally it is totally up to you! But in case you do not have any plan, You can follow below simple steps:

  1. Download/clone/fork repository โคต๏ธ
  2. Remove components and/or classes that you do not need to ๐Ÿ”ฅ
  3. Rename files (e.g. sln or csproj), folders, namespaces etc ๐Ÿ“
  4. Appreciate the work โญ

Architecture

Api

HappyCode.NetCoreBoilerplate.Api

HappyCode.NetCoreBoilerplate.Api

Core

HappyCode.NetCoreBoilerplate.Core

HappyCode.NetCoreBoilerplate.Core

DB Migrations

HappyCode.NetCoreBoilerplate.Db

HappyCode.NetCoreBoilerplate.Db

Tests

Integration tests

HappyCode.NetCoreBoilerplate.Api.IntegrationTests

HappyCode.NetCoreBoilerplate.Api.IntegrationTests

Unit tests

HappyCode.NetCoreBoilerplate.Api.UnitTests

HappyCode.NetCoreBoilerplate.Core.UnitTests

HappyCode.NetCoreBoilerplate.Core.UnitTests

Architectural tests

HappyCode.NetCoreBoilerplate.ArchitecturalTests

HappyCode.NetCoreBoilerplate.ArchitecturalTests

Books module

Totally separate module, developed with a modular monolith approach.

Module

The code organized around features (vertical slices).

HappyCode.NetCoreBoilerplate.BooksModule

HappyCode.NetCoreBoilerplate.BooksModule

Integration Tests

HappyCode.NetCoreBoilerplate.BooksModule.IntegrationTests

HappyCode.NetCoreBoilerplate.BooksModule.IntegrationTests

To Do

Be like a star, give me a star! โญ

If:

  • you like this repo/code,
  • you learn something,
  • you are using it in your project/application,

then please give me a star, appreciate my work. Thanks!

Buy me a coffee! โ˜•

You are also very welcome to acknowledge my time by buying me a small coffee.

Buy me a coffee

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.