{"id":27019165,"url":"https://github.com/fullstackcodingguy/dotnet-api-boilerplate","last_synced_at":"2025-04-04T17:19:23.853Z","repository":{"id":279963473,"uuid":"940585416","full_name":"FullstackCodingGuy/DotNet-API-Boilerplate","owner":"FullstackCodingGuy","description":"Boilerplate code for API application using .net 9, Batteries Included","archived":false,"fork":false,"pushed_at":"2025-03-17T11:15:32.000Z","size":52,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-17T12:24:12.675Z","etag":null,"topics":["api","authentication","boilerplate-application","cors-policy","dotnet","health","jwt-authorization","microservices-architecture","serilog"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/FullstackCodingGuy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-02-28T12:43:53.000Z","updated_at":"2025-03-17T11:15:35.000Z","dependencies_parsed_at":"2025-02-28T19:05:40.917Z","dependency_job_id":"bcb3828f-953d-4a99-a499-ec99dd1c8bd1","html_url":"https://github.com/FullstackCodingGuy/DotNet-API-Boilerplate","commit_stats":null,"previous_names":["fullstackcodingguy/netapi-boilerplate","fullstackcodingguy/dotnetapi-boilerplate","fullstackcodingguy/dotnet-api-boilerplate"],"tags_count":0,"template":true,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FullstackCodingGuy%2FDotNet-API-Boilerplate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FullstackCodingGuy%2FDotNet-API-Boilerplate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FullstackCodingGuy%2FDotNet-API-Boilerplate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FullstackCodingGuy%2FDotNet-API-Boilerplate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/FullstackCodingGuy","download_url":"https://codeload.github.com/FullstackCodingGuy/DotNet-API-Boilerplate/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247217214,"owners_count":20903009,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","authentication","boilerplate-application","cors-policy","dotnet","health","jwt-authorization","microservices-architecture","serilog"],"created_at":"2025-04-04T17:19:23.298Z","updated_at":"2025-04-04T17:19:23.847Z","avatar_url":"https://github.com/FullstackCodingGuy.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# DotNet API Boilerplate\n\n## Overview\n\nThis project is a boilerplate for building .NET API applications with various features such as authentication, rate limiting, CORS, and logging using Serilog.\n\n[![.NET](https://github.com/FullstackCodingGuy/DotNet-API-Boilerplate/actions/workflows/dotnet-build.yml/badge.svg)](https://github.com/FullstackCodingGuy/DotNet-API-Boilerplate/actions/workflows/dotnet-build.yml)\n\n## Features\n\n- [ ] [Vertical Slicing Architecture](https://github.com/FullstackCodingGuy/Developer-Fundamentals/wiki/Architecture-%E2%80%90-Vertical-Slicing-Architecture)\n- [x] Swagger\n- [x] Minimal API\n- [x] Authentication using JWT Bearer tokens\n- [ ] Authorization\n- [x] Rate limiting to prevent API abuse\n- [x] CORS policies for secure cross-origin requests\n- [x] Response caching and compression\n- [x] Logging with Serilog\n- [x] Health check endpoint\n- [x] [Middlewares](https://github.com/FullstackCodingGuy/dotnetapi-boilerplate/tree/main/src/Middlewares)\n- [ ] Entity Framework\n- [ ] Serilog\n- [ ] FluentValidation\n- [ ] Vault Integration\n- [ ] MQ Integration\n- [ ] Application Resiliency\n- [ ] Performance\n  - [ ] Response Compression\n  - [ ] Response Caching \n  - [ ] Metrics\n- [ ] Deployment\n  - [ ] Docker\n  - [ ] Podman\n  - [ ] CloudFormation\n- [ ] CI\n  - [ ] Github Action\n\n## Getting Started\n\n### Prerequisites\n\n- [.NET 9 SDK](https://dotnet.microsoft.com/download/dotnet/9.0)\n- [Keycloak](https://www.keycloak.org/) for authentication\n\n### Installation\n\n1. Clone the repository:\n    ```sh\n    git clone https://github.com/FullstackCodingGuy/netapi-boilerplate.git\n    cd netapi-boilerplate\n    ```\n\n2. Install the required NuGet packages:\n    ```sh\n    dotnet restore\n    ```\n\n3. Update the `appsettings.json` and `appsettings.Development.json` files with your configuration.\n\n### Running the Application\n\n1. Build and run the application:\n    ```sh\n    dotnet run\n\n    or\n\n    dotnet run --launch-profile \"https\"\n\n    ```\n\n1.1 Setting cert\n\n```\ndotnet dev-certs https -ep ${HOME}/.aspnet/https/dotnetapi-boilerplate.pfx -p mypassword234\ndotnet dev-certs https --trust\n\n```\n\nRunning with Docker\n\n```\n// To build the image\ndocker-compose build\n\n// To run the container\ndocker-compose up\n\n// To kill container\ndocker-compose down\n\n```\n\n2. The application will be available at `http://localhost:8000` and `https://localhost:8001` (or the configured URL).\n\n### Health Check Endpoint\n\nThe application includes a health check endpoint to verify that the API is running. You can access it at:\n\n\n```\nGET /health\n\nThis will return a simple \"Healthy\" message.\n```\n\n### Logging with Serilog\n\nSerilog is configured to log to the console and a file with daily rotation. You can customize the logging settings in the `serilog.json` file.\n\nExample configuration in [Program.cs](http://_vscodecontentref_/1):\n\n```csharp\nLog.Logger = new LoggerConfiguration()\n    .WriteTo.Console()   // Log to console\n    .WriteTo.File(\"logs/api-log.txt\", rollingInterval: RollingInterval.Day) // Log to a file (daily rotation)\n    .Enrich.FromLogContext()\n    .MinimumLevel.Information()\n    .CreateLogger();\n\nbuilder.Host.UseSerilog();\n```\n\n\nAdditional Configuration\n- Authentication: Configure the JWT Bearer options in Program.cs to match your Keycloak settings.\n- CORS: Update the CORS policies in Program.cs to match your frontend URLs.\n- Rate Limiting: Adjust the rate limiting settings in Program.cs as needed.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffullstackcodingguy%2Fdotnet-api-boilerplate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffullstackcodingguy%2Fdotnet-api-boilerplate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffullstackcodingguy%2Fdotnet-api-boilerplate/lists"}