A robust, scalable, and testable RESTful Web API built with .NET 10, implementing Clean Architecture principles. This project demonstrates best practices in software design, separating concerns into distinct layers to avoid the "Fat Controller" anti-pattern.
This project serves as a practical example of how to build enterprise-level applications using modern .NET technologies. It enforces strict separation of concerns:
- Controllers manage HTTP requests only.
- Services handle all business logic and validations.
- Repositories abstract the data access layer.
The solution follows the Clean Architecture (Onion Architecture) approach, ensuring that the core business logic depends on nothing but itself.
TodoApp
├── 📂 Domain # 🏠 Core Entities (No dependencies)
│ └── 📂 Entities # Database models (TodoItem)
│
├── 📂 Application # 🧠 Business Logic & Rules
│ ├── 📂 DTOs # Data Transfer Objects
│ ├── 📂 Interfaces # Contracts (ITodoService, ITodoRepository)
│ ├── 📂 Services # Business implementation
│ └── 📂 Validators # FluentValidation rules
│
├── 📂 Infrastructure # 🏗 Database & External Concerns
│ ├── 📂 Data # EF Core DbContext
│ └── 📂 Repositories # Data access implementation
│
└── 📂 Controllers # 🌐 API Entry Points
└── TodosController.cs # Handles HTTP requests
- Framework: .NET 10 (ASP.NET Core Web API)
- Database: SQLite
- ORM: Entity Framework Core (Code-First Migrations)
- Validation: FluentValidation
- Documentation: Swagger UI (Swashbuckle)
- Dependency Injection: Built-in ASP.NET Core DI
- Design Patterns: Clean Architecture, Repository Pattern, N-Tier Architecture
Follow these instructions to get a copy of the project up and running on your local machine.
- .NET 10 SDK installed
- An IDE such as Visual Studio, Rider, or VS Code
- Git installed
git clone https://github.com/bydoctor/TodoApp-CleanArchitecture.git
cd TodoApp-CleanArchitectureThis command downloads all required NuGet packages.
dotnet restoreThe project uses SQLite. This command will generate the Todos.db file based on the entities.
dotnet ef database updatedotnet run --project TodoApiOr simply press the Run button in your IDE.
Once running, open your browser to view the Swagger documentation:
http://localhost:5xxx/swagger
(Check your terminal for the exact port.)
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/todos | Get all tasks |
| GET | /api/todos/{id} | Get task by ID |
| POST | /api/todos | Create a new task |
| PUT | /api/todos/{id} | Update task |
| DELETE | /api/todos/{id} | Delete task |
Create
{ "title": "Buy Milk" }Update
{ "title": "Buy Milk", "isCompleted": true }Data integrity is ensured using FluentValidation.
Validations are intentionally handled in the Service Layer to keep business rules independent from transport concerns (HTTP).
-
Title:
- Cannot be empty
- Must be at least 1 character long
If a request fails validation, the API returns a 400 Bad Request response with detailed error messages.
Contributions, issues, and feature requests are welcome!
- Fork the project
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License.
Happy Coding! 💙