A robust RESTful API solution demonstrating industry best practices and advanced architectural patterns using .NET 8. This project implements a comprehensive employee management system with enterprise-level features and clean architecture principles.
This solution strictly adheres to the Onion Architecture pattern, providing clear separation of concerns:
- Contracts: Interface definitions enforcing business rules
- Entities: Domain models and business objects
- Shared: Common DTOs and shared resources
- Service.Contracts: Service interfaces
- Service: Business logic implementation
- Repository: Data access implementation and database context
- LoggerService: Logging mechanism
- CompanyEmployees: Main application entry point and configuration
- CompanyEmployees.Presentation: API controllers and presentation logic
- Complete RESTful API implementation (GET, POST, PUT, PATCH, DELETE, OPTIONS, HEAD)
- Authentication & Authorization with JWT and refresh token mechanism
- API versioning with support for multiple versioning strategies
- HATEOAS (Hypermedia as the Engine of Application State) implementation
- Comprehensive API documentation with OpenAPI/Swagger
- Output caching for optimized response times
- Rate limiting to protect against abuse
- Asynchronous code execution throughout the application
- Advanced data retrieval options (Paging, Filtering, Searching, Sorting)
- Data shaping capabilities for efficient data transfer
- Entity Framework Core with code-first approach
- Repository pattern for data access abstraction
- Global exception handling with custom error responses
- Input validation using attributes and model validation
- Docker containerization support
- .NET 8 SDK
- SQL Server (or SQL Server Express)
# Create JWT secret key (run as Administrator)
setx WEB_API_SECRET "YourTopSecretKeyHasGreater256Bytes113211162023!!!!" /M
Secret management via environment variables in docker-compose.yml:
services:
companyemployees:
environment:
- WEB_API_SECRET=YourTopSecretKeyHasGreater256Bytes113211162023!!!!
- Configure your SQL Server connection string in
CompanyEmployees\appsettings.json
- Initialize the database:
dotnet ef database update
# Restore dependencies
dotnet restore
# Start the API
dotnet run --project CompanyEmployees
Explore the complete API using Swagger UI: https://localhost:5001/swagger/index.html or if you're running in docker environment: https://localhost:8081/swagger/index.html