|
1 |
| -# dotnet-foundation-v2 |
| 1 | +# DotnetFoundation |
| 2 | + |
| 3 | +> A powerful, scalable boilerplate for building robust **.NET 8** server applications. |
| 4 | +
|
| 5 | +DotnetFoundation provides a production-ready foundation with clean architecture, authentication, logging, API documentation, and health monitoring — all pre-configured to help you build enterprise-grade backend services faster. |
| 6 | + |
| 7 | +--- |
| 8 | + |
| 9 | +## Features |
| 10 | + |
| 11 | +- **.NET 8** based modern architecture |
| 12 | +- **JWT Authentication** with secure token handling |
| 13 | +- **Entity Framework Core** integration |
| 14 | +- **Swagger/OpenAPI** for API documentation |
| 15 | +- **Serilog**-based structured **Logging** |
| 16 | +- **Health Checks** and Health Checks UI |
| 17 | +- **AutoMapper** for object mapping |
| 18 | +- **Secure Password Hashing** (BCrypt) |
| 19 | +- **MySQL** (Pomelo) database support |
| 20 | +- **Soft Deletion**, **Global Exception Handling**, and **Pagination** utilities |
| 21 | +- Clean, extendable **Repository Pattern** |
| 22 | + |
| 23 | +--- |
| 24 | + |
| 25 | +## Technologies & Packages |
| 26 | + |
| 27 | +- **ASP.NET Core 8** |
| 28 | +- **Entity Framework Core (EF Core 8)** with **Pomelo.EntityFrameworkCore.MySql** |
| 29 | +- **JWT Authentication** (`Microsoft.AspNetCore.Authentication.JwtBearer`) |
| 30 | +- **Swagger & OpenAPI** (`Swashbuckle.AspNetCore`) |
| 31 | +- **Serilog Logging** (Console, File, Filters) |
| 32 | +- **AutoMapper** |
| 33 | +- **BCrypt.Net** (for password hashing) |
| 34 | +- **Configuration Management** (`appsettings.json` with environment-specific overrides) |
| 35 | +- **Health Checks** (with UI monitoring) |
| 36 | + |
| 37 | +--- |
| 38 | + |
| 39 | +## Getting Started |
| 40 | + |
| 41 | +### Prerequisites |
| 42 | + |
| 43 | +- [.NET 8 SDK](https://dotnet.microsoft.com/en-us/download/dotnet/8.0) installed |
| 44 | +- [MySQL Server](https://dev.mysql.com/downloads/mysql/) running (or compatible MariaDB server) |
| 45 | + |
| 46 | +### Installation Steps |
| 47 | + |
| 48 | +1. **Clone the Repository** |
| 49 | + |
| 50 | +```bash |
| 51 | + git clone https://github.com/OsmosysSoftware/dotnet-foundation-v2.git |
| 52 | + cd dotnet-foundation-v2 |
| 53 | +``` |
| 54 | + |
| 55 | +2. **Navigate to the API Project** |
| 56 | + |
| 57 | +```bash |
| 58 | + cd src/Api |
| 59 | +``` |
| 60 | + |
| 61 | +3. **Restore Dependencies** |
| 62 | + |
| 63 | +```bash |
| 64 | + dotnet restore |
| 65 | +``` |
| 66 | + |
| 67 | +4. **Apply Database Migrations** |
| 68 | + |
| 69 | +```bash |
| 70 | + dotnet ef database update --context DatabaseContext |
| 71 | +``` |
| 72 | + |
| 73 | +5. **Run the Project** |
| 74 | + |
| 75 | +```bash |
| 76 | + dotnet run |
| 77 | +``` |
| 78 | + |
| 79 | +The API will be available at: `https://localhost:5000` (Swagger UI will be available at `/swagger`). |
| 80 | + |
| 81 | +--- |
| 82 | + |
| 83 | +## Project Structure |
| 84 | + |
| 85 | +```bash |
| 86 | +src/ |
| 87 | +├── Api/ # ASP.NET Core Web API |
| 88 | +├── Core/ # Domain Models, DTOs, Interfaces, Exceptions |
| 89 | +``` |
| 90 | + |
| 91 | +- **Api** |
| 92 | + - Configures authentication, logging, exception handling, Swagger, and dependency injection. |
| 93 | +- **Core** |
| 94 | + - Contains Entities, Repository Interfaces, DTOs, Enums, and Custom Exceptions. |
| 95 | + |
| 96 | + |
| 97 | +--- |
| 98 | + |
| 99 | +## Configuration |
| 100 | + |
| 101 | +The project relies on **appsettings.json** for hierarchical configuration settings (override values per-environment with `appsettings.json` files). |
| 102 | +> Make sure to configure your **database** and **JWT settings** before running. |
| 103 | +
|
| 104 | + |
| 105 | +--- |
| 106 | + |
| 107 | +## API Documentation |
| 108 | + |
| 109 | +Once you run the project, visit: |
| 110 | + |
| 111 | +- Swagger UI: `https://localhost:5000/swagger` |
| 112 | + |
| 113 | +You can **test all APIs directly** from Swagger. |
| 114 | + |
| 115 | + |
| 116 | +--- |
| 117 | + |
| 118 | +## Logging |
| 119 | + |
| 120 | +The project uses **Serilog** for structured logging: |
| 121 | + |
| 122 | +- Logs are written to console and also to a **file** (`Logs/log-.txt`) |
| 123 | +- Logs include enriched information for easier debugging. |
| 124 | + |
| 125 | + |
| 126 | +--- |
| 127 | + |
| 128 | +## Health Checks |
| 129 | + |
| 130 | +Health checks are integrated with: |
| 131 | + |
| 132 | +- Database Connectivity Check |
| 133 | +- Health Check UI available at: `https://localhost:5000/health` |
| 134 | + |
| 135 | + |
| 136 | +--- |
| 137 | + |
| 138 | +## Contributing |
| 139 | + |
| 140 | +Contributions, issues, and feature requests are welcome! |
| 141 | + |
| 142 | +1. Fork the repository |
| 143 | +2. Create your feature branch (`git checkout -b feature/yourFeature`) |
| 144 | +3. Commit your changes (`git commit -m 'Add some feature'`) |
| 145 | +4. Push to the branch (`git push origin feature/yourFeature`) |
| 146 | +5. Open a Pull Request |
| 147 | + |
| 148 | + |
| 149 | +--- |
| 150 | + |
| 151 | +## License |
| 152 | + |
| 153 | +This project is licensed under the **MIT License**. |
| 154 | + |
| 155 | + |
| 156 | +--- |
0 commit comments