Skip to content

Skiper29/ToDoApp-Back

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ToDoApp API

A robust and well-structured RESTful API for managing ToDo tasks, built with .NET 9 and following Clean Architecture principles.

🚀 Overview

This project is a backend solution for a ToDo application. It provides a set of endpoints to perform CRUD operations on tasks. The application is designed with a focus on separation of concerns, testability, and maintainability by implementing a Clean Architecture with CQRS and Repository patterns.

✨ Features

  • Create, Read, Update, and Delete (CRUD) operations for tasks.
  • Update task status (ToDo, InProgress, Done).
  • Validation for all incoming requests.
  • Structured and consistent error handling.
  • Interactive API documentation with Scalar.

🛠️ Tech Stack

  • .NET 9 - The latest version of the .NET framework for building modern, cloud-based, and internet-connected applications.
  • ASP.NET Core - For building the RESTful API.
  • Entity Framework Core - For data access and object-relational mapping (ORM).
  • SQL Server - As the database provider for EF Core.
  • MediatR - For implementing the CQRS (Command Query Responsibility Segregation) pattern, which helps in separating read and write operations.
  • AutoMapper - A convention-based object-object mapper.
  • FluentValidation - For building strongly-typed validation rules.
  • FluentResults - A lightweight .NET library for handling success and error states.
  • xUnit & Moq - For unit and integration testing.
  • Scalar - For beautiful and interactive API documentation.

🏗️ Architecture

The application is structured following the principles of Clean Architecture. This divides the project into three main layers:

  • ToDoApp.DAL (Data Access Layer): This layer is responsible for all data access logic. It contains the Entity Framework Core DbContext, entity configurations, migrations, and the implementation of the Repository and Unit of Work patterns.
  • ToDoApp.BLL (Business Logic Layer): This is the core of the application. It contains the business logic, MediatR handlers (Commands and Queries), DTOs, mappers, and validators. It is completely independent of the presentation and data access layers.
  • ToDoApp.WebApi (Presentation Layer): This is the entry point of the application. It's an ASP.NET Core project that exposes the API endpoints. It handles HTTP requests and responses and delegates the execution to the BLL using MediatR.
  • ToDoApp.UnitTests: This project contains unit tests for the BLL, ensuring the business logic is working as expected.

This layered architecture ensures a clear separation of concerns, making the application easier to maintain, test, and scale.

🏁 Getting Started

Prerequisites

Installation & Setup

  1. Clone the repository:
    git clone https://github.com/Skiper29/ToDoApp-Back
  2. Navigate to the project directory:
    cd ToDoApp-Back
  3. Configure the database connection: Open the appsettings.json file in the ToDoApp.WebApi project and update the DefaultConnection string with your database credentials.
    {
      "ConnectionStrings": {
        "DefaultConnection": "Server=your_server;Database=ToDoAppDb;User Id=your_user;Password=your_password;"
      }
    }
  4. Apply database migrations: Open a terminal in the root of the ToDoApp.DAL project or use the Package Manager Console in Visual Studio and run the following command to create the database and apply the migrations:
    dotnet ef database update
  5. Run the application: You can run the application from your IDE or by using the following command in the root of the ToDoApp.WebApi project:
    dotnet run

The API will be available at https://localhost:7156 and http://localhost:5133.

📖 API Endpoints

The API provides the following endpoints for managing tasks:

Method Endpoint Description
GET /api/TodoTask Get all tasks
GET /api/TodoTask/{id} Get a task by its ID
POST /api/TodoTask Create a new task
PUT /api/TodoTask Update an existing task
PATCH /api/TodoTask/{id} Update the status of a task
DELETE /api/TodoTask/{id} Delete a task

You can explore and test the API endpoints using the interactive Scalar documentation, which is available at the root URL of the application when running in a development environment.

🧪 Testing

The project includes a comprehensive suite of unit tests in the ToDoApp.UnitTests project. To run the tests, you can use the Test Explorer in Visual Studio or run the following command from the root of the solution:

dotnet test

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages