A comprehensive .NET solution demonstrating N-Tier/Clean Architecture with Domain-Driven Design (DDD) principles for file upload and management operations.
This solution implements a layered N-tier architecture with clear separation of concerns, following SOLID principles and dependency inversion. The architecture consists of 8 distinct projects, each with specific responsibilities:
βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Presentation Layer β
β β’ FN.Web (Razor Pages) β
β β’ FN.WebApi (REST API) β
β β’ FN.WinForm (Desktop Client) β
ββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββ
β
ββββββββββββββββββββΌβββββββββββββββββββββββββββββββββββ
β Application Layer β
β β’ FN.Application (Use Cases, Services, DTOs) β
ββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββ
β
ββββββββββββββββββββΌβββββββββββββββββββββββββββββββββββ
β Business Logic Layer β
β β’ FN.Business (Domain Services, Business Rules) β
ββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββ
β
ββββββββββββββββββββΌβββββββββββββββββββββββββββββββββββ
β Data Access Layer β
β β’ FN.DataLayer (Repositories, EF Core Context) β
ββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββ
β
ββββββββββββββββββββΌβββββββββββββββββββββββββββββββββββ
β Cross-Cutting Concerns β
β β’ FN.Entities (Domain Models, DTOs) β
β β’ FN.Common (Utilities, Extensions, Validators) β
β β’ FN.Functions (Shared Helper Functions) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
- FN.Web - ASP.NET Core Razor Pages web application for browser-based UI
- FN.WebApi - RESTful API with Swagger/OpenAPI documentation
- FN.WinForm - Windows Forms desktop application for file uploads
- FN.Application - Application services implementing use cases
- Services:
UploadService - Interfaces:
IUploadService - Validators: FluentValidation implementations
- Services:
- FN.Business - Core business logic and domain services
- Services:
UploadDataService - Abstractions:
IUploadDataService - Coordinates between application and data layers
- Services:
- FN.DataLayer - Entity Framework Core implementation
- Repositories (Generic Repository Pattern)
- DbContext with in-memory database support
- Data initialization and seeding
- FN.Entities - Domain models, DTOs, and data transfer objects
UploadModel,UploadEntity,UploadedModel,UploadedEntity
- FN.Common - Shared utilities, extensions, and validators
- FluentValidation configurations
- Custom validation extensions
- String extensions and regex patterns
- FN.Functions - Utility functions for file operations
- File upload/download handlers
- Image resizing with ImageSharp
- Content type detection
- β N-Tier Architecture - Clear separation of layers
- β Repository Pattern - Abstraction over data access
- β Dependency Injection - Built-in ASP.NET Core DI container
- β Interface Segregation - Small, focused interfaces
- β Domain-Driven Design - Rich domain models and services
- β FluentValidation - Model validation across layers
- β Entity Framework Core 10.0 - ORM with in-memory database
- β AutoMapper/Custom Mappers - Object-to-object mapping
- β RESTful API - Standard HTTP methods (GET, POST, DELETE)
- β Image Processing - SixLabors.ImageSharp for image manipulation
- β Swagger/OpenAPI - API documentation
- β Async/Await - Asynchronous operations with CancellationToken support
- .NET 10.0 - Target framework
- ASP.NET Core - Web framework
- Entity Framework Core 10.0 - ORM
- FluentValidation 12.1.1 - Validation library
- SixLabors.ImageSharp - Image processing
- Newtonsoft.Json - JSON serialization
- Swagger/OpenAPI - API documentation
- Windows Forms - Desktop UI
GET /api/uploads- Retrieve all uploadsGET /api/uploads/{id}- Get upload by IDGET /api/uploads/{id}/{fileName}- View file detailsPOST /api/uploads- Upload a new fileDELETE /api/uploads/{id}- Delete an uploadGET /api/uploads/download/{fileName}- Download file
- .NET 10.0 SDK
- Visual Studio 2022 or later / VS Code
-
Clone the repository
git clone <repository-url>
-
Restore dependencies
dotnet restore
-
Run the Web API
cd FN.WebApi dotnet runAPI will be available at:
https://localhost:5001orhttp://localhost:5000 -
Run the Web Application
cd FN.Web dotnet run -
Run the WinForms Application
cd FN.WinForm dotnet run
The solution uses appsettings.json for configuration:
- UseInMemoryDatabase: Toggle between in-memory and persistent database
- UploadPath: Configure file upload directory
- Connection strings: Configure database connections
The solution includes:
- FluentValidation for input validation
- In-memory database for testing scenarios
- Proper exception handling and error responses
- Presentation β Application β Business β Data
- Each layer only depends on layers below it
- Common/Entities can be referenced from any layer
- No upward dependencies
- Define domain models in
FN.Entities - Create repository interface in
FN.DataLayer.Abstractions - Implement repository in
FN.DataLayer.Repositories - Create business service in
FN.Business.Services - Create application service in
FN.Application.Services - Add API endpoints in
FN.WebApi.Controllers
Frontend Example: Angular.Test.Web - Angular web application consuming this API
This is a template/example project for demonstrating multitier architecture patterns.
This is a template project. Feel free to use it as a starting point for your own applications.
Note: This solution serves as an educational template demonstrating best practices in .NET application architecture, including proper separation of concerns, dependency management, and scalable design patterns.