This repository demonstrates a systematic modernization of a legacy .NET application into a clean, maintainable, and extensible solution. The project highlights Clean Architecture, Domain-Driven Design (DDD), CQRS, and MediatR, with GitHub Copilot in agent mode assisting the process.
/
— Original codebase (preserved for reference and comparison)src/
— Modernized solution following Clean Architecture:Domain/
— Core business logic, entities, value objects, domain eventsApplication/
— Use cases, CQRS handlers, DTOs, validationInfrastructure/
— EF Core persistence, external services, repositoriesWebUI/
— Razor Pages presentation layer
- .NET 8
- MediatR for CQRS
- Entity Framework Core for persistence
- Mapster for DTO mapping
- FluentValidation for input validation
- xUnit for testing
- Demonstrate a step-by-step migration process using AI with human-in-the-loop approvals
- Apply Clean Architecture and DDD principles to a legacy project
- Showcase the benefits of the new architecture compared to the original
docs/domain-overview.md
— Business domain concepts, entities, and workflowsdocs/migration-process.md
— Migration strategy and execution plandocs/architecture-comparison.md
— Benefits of the new architecture
Before running the application, ensure you have the following installed:
- .NET 8 SDK (8.0 or later)
- SQL Server or SQL Server Express (Download here)
- Alternative: SQL Server LocalDB (included with Visual Studio)
- Visual Studio 2022 (recommended) or Visual Studio Code
- Git for cloning the repository
-
Clone the repository
git clone https://github.com/akhmelevtsov/DemoRentalRepairsWebAPI.git cd DemoRentalRepairsWebAPI
-
Navigate to the modernized solution
cd src
-
Restore NuGet packages
dotnet restore
-
Update database connection string (if needed)
Edit
src/WebUI/appsettings.json
:{ "ConnectionStrings": { "DefaultConnection": "Server=(localdb)\\mssqllocaldb;Database=RentalRepairsDb;Trusted_Connection=true;MultipleActiveResultSets=true;" } }
For SQL Server Express, use:
"DefaultConnection": "Server=.\\SQLEXPRESS;Database=RentalRepairsDb;Trusted_Connection=true;MultipleActiveResultSets=true;"
-
Run the application
cd WebUI dotnet run
-
Open your browser
Navigate to:
https://localhost:5001
orhttp://localhost:5000
The application will automatically:
- ✅ Create the database if it doesn't exist
- ✅ Apply any pending migrations
- ✅ Log initialization status to console
To get started quickly, you can register test users:
-
Property Manager (Superintendent)
- Click "Register" and create an account
- Register a property with sample data:
- Property Code:
test-property
- Units:
101, 102, 103, 201, 202, 203
- Property Code:
-
Tenant
- Register as a tenant for unit
101
intest-property
- Submit repair requests to test the workflow
- Register as a tenant for unit
-
Worker
- Register as a worker to receive work assignments
To compare with the original legacy implementation:
-
Navigate to legacy WebMVC
cd Demo.RentalRepairs.WebMvc dotnet run
-
Navigate to legacy WebAPI
cd Demo.RentalRepairs.WebApi dotnet run
Run all tests:
cd src
dotnet test
Run specific test projects:
# Domain tests
dotnet test Domain.Tests/
# Application tests
dotnet test Application.Tests/
# Integration tests
dotnet test WebUI.Tests/
Generate test coverage report:
dotnet test --collect:"XPlat Code Coverage"
Reset database:
cd src/WebUI
dotnet ef database drop --force
dotnet run # Will recreate on startup
Apply migrations manually:
cd src/Infrastructure
dotnet ef database update --startup-project ../WebUI
1. Database Connection Errors
- Verify SQL Server is running
- Check connection string in
appsettings.json
- Ensure database permissions are correct
2. Port Already in Use
# Check what's using the port
netstat -ano | findstr :5001
# Kill the process (replace PID)
taskkill /PID <process_id> /F
3. SSL Certificate Issues
# Trust the development certificate
dotnet dev-certs https --trust
4. Build Errors
# Clean and rebuild
dotnet clean
dotnet restore
dotnet build
Add to appsettings.Development.json
:
{
"Logging": {
"LogLevel": {
"Default": "Debug",
"Microsoft.EntityFrameworkCore": "Information"
}
}
}
The application supports various configuration options in appsettings.json
:
- Caching: Enable/disable in-memory caching
- Email Notifications: Configure SMTP or mock email provider
- Logging: Serilog configuration for file and console output
- Security: Authentication and authorization settings
✅ Complete Clean Architecture Implementation
- Domain layer with DDD patterns
- Application layer with CQRS and MediatR
- Infrastructure layer with EF Core
- Presentation layer with Razor Pages
✅ Core Business Functionality
- Property registration and management
- Tenant request submission and tracking
- Worker assignment and task completion
- User authentication and authorization
✅ Comprehensive Testing
- 50+ unit and integration tests
- Domain logic validation
- End-to-end workflow testing
✅ Production-Ready Features
- Security headers and authentication
- Logging and health checks
- Error handling and validation
- Performance optimizations