This project has been successfully refactored from a monolithic structure to follow Clean Architecture principles with clear separation of concerns and proper dependency direction.
/Taskify
├── src/
│ ├── Taskify.Domain/ → Core business models and entities
│ ├── Taskify.Application/ → Use cases, commands, queries, and interfaces
│ ├── Taskify.Infrastructure/ → Data access, external services, implementations
│ └── Taskify.Web/ → API controllers and presentation layer
└── tests/
└── Taskify.Tests/ → Unit and integration tests
- ✅ Web → Application → Domain
- ✅ Infrastructure → Application
- ✅ Domain has no dependencies on other layers
- ✅ Application depends only on Domain
- ✅ Infrastructure implements Application interfaces
- Clean domain entities without EF attributes
- Proper enums with meaningful names
- Business logic separated from data concerns
- No external dependencies
- CQRS pattern with MediatR
- Feature-based folder organization
- Clear interfaces for external dependencies
- DTOs for data transfer
- Vertical slicing by features (Users, Tasks, Projects, etc.)
- EF Core DbContext with proper mappings
- Service implementations (AuthService, EmailService)
- External API integrations (Google Auth, BCrypt)
- Dependency injection configuration
- Thin controllers that delegate to Application layer
- Proper dependency injection setup
- CORS configuration
- Swagger/OpenAPI documentation
- .NET 9.0 - Latest framework version
- Entity Framework Core - Data access with PostgreSQL
- MediatR - CQRS and Mediator pattern implementation
- BCrypt.Net - Password hashing
- JWT - Authentication tokens
- Google APIs - OAuth integration
- Clean Architecture - Separation of concerns with proper dependencies
- CQRS - Command Query Responsibility Segregation
- Mediator Pattern - Decoupled request/response handling
- Repository Pattern - Data access abstraction
- Dependency Injection - Loose coupling and testability
❌ Mixed responsibilities in controllers
❌ EF attributes polluting domain models
❌ Tight coupling between layers
❌ Business logic in infrastructure
❌ Hard to test and maintain
✅ Single Responsibility Principle
✅ Clean domain models
✅ Loose coupling with interfaces
✅ Business logic in Application layer
✅ Easily testable and maintainable
✅ Scalable architecture
- .NET 9.0 SDK
- PostgreSQL database
- Your favorite IDE (Visual Studio, VS Code, Rider)
Update appsettings.json in the Web project:
{
"ConnectionStrings": {
"DefaultConnection": "Host=localhost;Database=taskify_clean;Username=postgres;Password=your_password"
},
"Jwt": {
"Key": "your-secret-key-here-make-it-long-enough-for-security",
"Issuer": "TaskifyAPI"
}
}# Build the solution
dotnet build Taskify.sln
# Run the API
cd src/Taskify.Web
dotnet run
# Access Swagger UI
# Navigate to: https://localhost:5001/swagger- Add more CQRS features - Complete Commands for Create/Update/Delete operations
- Implement validation - FluentValidation for request validation
- Add authentication middleware - JWT authentication setup
- Create more controllers - Tasks, Projects, Comments, etc.
- Add logging - Structured logging with Serilog
- Unit tests - Comprehensive test coverage
- Integration tests - API endpoint testing
- Event sourcing - For audit trails
- Background services - Email notifications, file processing
- API versioning - Support multiple API versions
- Rate limiting - Protect against abuse
- Caching - Redis for performance
- Clear boundaries - Each layer has specific responsibilities
- Easy testing - Interfaces allow easy mocking
- Parallel development - Teams can work on different layers independently
- Code reuse - Business logic is centralized and reusable
- Easier debugging - Clear flow of dependencies
- Flexible technology changes - Swap implementations without affecting business logic
- Scalability - Easy to add new features following established patterns
- Documentation - Self-documenting architecture
- Faster time to market - Well-structured code means faster development
- Lower maintenance costs - Clean code is easier to maintain
- Better quality - Separation of concerns reduces bugs
- Future-proof - Architecture supports growth and changes
This refactoring sets a solid foundation for building a scalable, maintainable, and testable task management application.