A comprehensive, production-ready template for building scalable web APIs using Clean Architecture principles and SOLID design patterns. This template serves as a foundation for enterprise-grade applications with built-in best practices, comprehensive documentation, and real-world examples.
βββ Domain/ # ποΈ Core business logic and entities
βββ Application/ # π― Use cases and business rules
βββ Infrastructure/ # π§ Data access and external services
βββ Presentation/ # π API controllers and endpoints
βββ docs/ # π Comprehensive documentation
- .NET 8.0 SDK
- SQL Server (optional - uses In-Memory database by default)
- Visual Studio 2022 or VS Code
# Clone the template
git clone <repository-url>
cd SOLID_Template
# Restore dependencies
dotnet restore
# Run the application
dotnet run
# Access the API
# - Base URL: https://localhost:7299
# - Swagger UI: https://localhost:7299/swagger
# - Health Checks: https://localhost:7299/health- Getting Started - Complete setup and first steps
- Developer Guide - Complete development workflow with tips, tricks, and resources
- Clean Architecture - Architecture principles and structure
- Adding Features - Step-by-step feature development
- SOLID Principles - SOLID principles and design patterns
- Testing Guide - Comprehensive testing strategies
- Complete CRUD Example - Full Task management implementation
- API Documentation - Endpoint specifications and usage
- Best Practices - Development guidelines
- Project Structure - Detailed folder organization
- Dependencies - Package information
- Configuration - Environment setup
- β Clean Architecture - Separation of concerns with dependency inversion
- β SOLID Principles - Maintainable and extensible code design
- β Entity Framework Core 8.0 - Code-first with migrations
- β AutoMapper - Object-to-object mapping
- β FluentValidation - Declarative validation rules
- β Swagger/OpenAPI - Interactive API documentation
- β Global Exception Handling - Centralized error management with ProblemDetails
- β Structured Logging - Comprehensive logging with Serilog
- β Health Checks - Application and database health monitoring
- β CORS Configuration - Cross-origin resource sharing
- β Response Compression - Performance optimization
- β Memory Caching - In-memory caching foundation
- β Environment Configuration - Development/Production settings
- β Unit Testing - Comprehensive test coverage
- β Integration Testing - End-to-end API testing
- β Validation Testing - Input validation testing
- β Repository Testing - Data access testing
Complete CRUD operations demonstrating:
GET /api/persons # Get all persons
GET /api/persons/{id} # Get person by ID
POST /api/persons # Create new person
PUT /api/persons/{id} # Update person
DELETE /api/persons/{id} # Delete person (soft delete)# Create a new person
curl -X POST "https://localhost:7299/api/persons" \
-H "Content-Type: application/json" \
-d '{
"firstName": "John",
"lastName": "Doe",
"email": "john.doe@example.com",
"dateOfBirth": "1990-01-15"
}'{
"success": true,
"message": "Person created successfully",
"data": {
"id": 1,
"firstName": "John",
"lastName": "Doe",
"email": "john.doe@example.com",
"fullName": "John Doe",
"age": 34,
"createdDate": "2024-01-15T10:30:00Z"
}
}{
"ConnectionStrings": {
"DefaultConnection": "Server=(localdb)\\mssqllocaldb;Database=SOLIDTemplateDB;Trusted_Connection=true;"
},
"UseInMemoryDatabase": false
}{
"Serilog": {
"MinimumLevel": {
"Default": "Information",
"Override": {
"Microsoft.AspNetCore": "Warning"
}
},
"WriteTo": [
{ "Name": "Console" },
{ "Name": "File", "Args": { "path": "logs/app-.txt", "rollingInterval": "Day" } }
]
}
}- π Plan - Define requirements and design
- ποΈ Domain - Create entities and business logic
- π§ Infrastructure - Implement data access
- π― Application - Add services and DTOs
- π Presentation - Create API endpoints
- π§ͺ Test - Write comprehensive tests
- π Document - Update documentation
See Adding Features Guide for detailed steps.
# Add new migration
dotnet ef migrations add MigrationName
# Update database
dotnet ef database update
# Remove last migration
dotnet ef migrations remove# Run all tests
dotnet test
# Run with coverage
dotnet test --collect:"XPlat Code Coverage"
# Run specific category
dotnet test --filter Category=Unit- Application Health:
/health - Database Health: Automatic EF Core integration
- Custom Health Checks: Extensible health monitoring
- Structured Logging: JSON-formatted logs with Serilog
- Request Logging: HTTP request/response logging
- Error Tracking: Centralized error handling and logging
- Performance Metrics: Built-in ASP.NET Core metrics
- Clear Separation of business logic, data access, and presentation
- SOLID Principles ensure code is easy to modify and extend
- Dependency Injection makes components loosely coupled and testable
- Clean Architecture allows independent scaling of layers
- Repository Pattern enables easy data store changes
- Service Layer provides centralized business logic
- Dependency Injection enables easy mocking
- Interface-based Design allows test doubles
- Separated Concerns enable focused unit tests
- Plugin Architecture through dependency injection
- Strategy Patterns for algorithmic flexibility
- Open/Closed Principle for safe extensions
- .NET 8.0 - Latest LTS framework with performance improvements
- ASP.NET Core - High-performance web API framework
- Entity Framework Core 8.0 - Modern ORM with advanced features
- AutoMapper 12.0 - Object-to-object mapping
- FluentValidation 11.8 - Fluent validation rules
- Serilog - Structured logging framework
- Swashbuckle - OpenAPI/Swagger documentation
- xUnit - Unit testing framework
- FluentAssertions - Fluent assertion library
- Visual Studio 2022 - Full IDE support
- VS Code - Lightweight development
- SQL Server - Production database
- In-Memory Database - Development/testing
We welcome contributions! Please see our Contributing Guide for details.
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Make your changes and add tests
- Ensure all tests pass:
dotnet test - Commit your changes:
git commit -m 'Add amazing feature' - Push to the branch:
git push origin feature/amazing-feature - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Clean Architecture concepts by Robert C. Martin
- SOLID Principles by Robert C. Martin
- .NET Community for excellent libraries and frameworks
- Contributors who help improve this template
Ready to build amazing APIs? Start with our Getting Started Guide π