An open API service indexing awesome lists of open source software.

https://github.com/sayeed1999/aspnetcore.webapi.template

Build any small-large scale web api in ASP.NET Core which includes Clean Architecture, CQRS, Mediatr, Functional Testing, and many more using this template.
https://github.com/sayeed1999/aspnetcore.webapi.template

asp-net-core clean-architecture docker dotnet-core functional-testing hacktoberfest template-project unit-test webapi

Last synced: 3 months ago
JSON representation

Build any small-large scale web api in ASP.NET Core which includes Clean Architecture, CQRS, Mediatr, Functional Testing, and many more using this template.

Awesome Lists containing this project

README

        

# ASP.NET Core Web API Template

**AspNetCore.WebApi.Template** is an open-source project to speed up the API development process of any small-large scale application in ASP.NET Core. This comes with out-of-the box prebuilt setups including -

- **ASP.NET Core** Web API with **PostgreSQL** database
- **Docker** container support with hot reloading support for local development
- **Clean Architecture** with **FluentValidation**, **CQRS** and **Mediatr**
- **OData** integration support
- Sample code for **CRUD operation** on Products, Categories
- Sample code for **functional testing** of business usecases
- any many more..

## Table of Contents

- [Architecture](#architecture)
- [Set Up Environment Variables](#set-up-environment-variables)
- [Run with Docker](#run-with-docker)
- [Add a Migration](#add-a-migration)
- [Contribute to this Project](#contribute-to-this-project)
- [Special Thanks](#special-thanks)

## Architecture

This project is built on top of **Clean Architecture** with **CQRS** and **Mediator** pattern in **ASP.NET Core**.

To get a high-level overview of the responsibilites each of the layers in this project, please refer to -

- [Presentation Layer](src/Web/README.md)
- [Application Layer](src/Application/README.md)
- [Infrastructure Layer](src/Infrastructure/README.md)
- [Domain Layer](src/Domain/README.md)

## Set Up Environment Variables

- Clone the repository & navigate to project root directory.

- Set necessary environment variables in your machine by following the .env.example file e.g

```bash
export POSTGRES_USER=xxx
export POSTGRES_PASSWORD=xxx
export PGADMIN_EMAIL=xxx
export PGADMIN_PASSWORD=xxx
```

## Run with Docker

- Ensure Docker is installed on your system.

- Run the docker containers using the following command.

```bash
docker compose -f docker-compose.local.yml up -d
```

- Hit the healthcheck endpoint to see API is working on not.

```
URI: /GET localhost:5000/health
```

- Test hot reloading working or not inside Docker container.

Change any code (comment out a single endpoint) and save the code and see docker container has updated on real-tme.

- Stop the docker container using the following command.

```bash
docker compose -f docker-compose.local.yml down
```

## Add a Migration

Run the following command to add a migration

```bash
dotnet ef migrations add --project ./src/Infrastructure --startup-project ./src/Web --output-dir ./Data/Migrations
```

## Contribute to this Project

Please refer to contribution guide [page](./CONTRIBUTING.md).

## Special Thanks

I used the following two templates to start my own template:

- [jasontaylordev/CleanArchitecture](https://github.com/jasontaylordev/CleanArchitecture)
- [jasontaylordev/NorthwindTraders](https://github.com/jasontaylordev/NorthwindTraders)