Skip to content

Repository files navigation

TaskFlow API

A RESTful API for task and project management built with ASP.NET Core 8, featuring JWT authentication, Entity Framework Core, and comprehensive CRUD operations.

Features

  • User Authentication: Register and login with JWT token-based authentication
  • Task Management: Complete CRUD operations for tasks
  • Task Assignment: Assign tasks to specific users
  • Status Filtering: Filter tasks by status (Pending, InProgress, Completed)
  • Pagination: Efficient data retrieval with pagination support
  • Swagger Documentation: Interactive API documentation with built-in authorization testing

Technologies

  • ASP.NET Core 8 - Web API framework
  • Entity Framework Core - ORM for database operations
  • SQL Server - Database (LocalDB for development)
  • JWT Authentication - Secure token-based authentication
  • ASP.NET Core Identity - User management
  • Swagger/OpenAPI - API documentation

Project Structure

TaskFlow.API/
├── Controllers/        # API endpoints
│   ├── AuthController.cs
│   └── TasksController.cs
├── Models/            # Data models
│   ├── ApplicationUser.cs
│   └── TaskItem.cs
├── DTOs/              # Data transfer objects
│   ├── AuthResponseDto.cs
│   ├── LoginDto.cs
│   ├── RegisterDto.cs
│   └── TaskItemDto.cs
├── Services/          # Business logic
│   ├── AuthService.cs
│   └── IAuthService.cs
├── Repositories/      # Data access layer
│   ├── TaskRepository.cs
│   └── ITaskRepository.cs
├── Data/              # Database context
│   └── ApplicationDbContext.cs
└── Migrations/        # EF Core migrations

Getting Started

Prerequisites

Installation

  1. Clone the repository

    git clone https://github.com/guidcoimbratt/TaskFlow.API.git
    cd TaskFlow.API
  2. Update the database connection string (optional)

    Edit appsettings.json if you need to change the connection string:

    "ConnectionStrings": {
      "DefaultConnection": "Server=(localdb)\\mssqllocaldb;Database=TaskFlowDb;Trusted_Connection=True;MultipleActiveResultSets=true"
    }
  3. Apply database migrations

    dotnet ef database update
  4. Run the application

    dotnet run
  5. Access Swagger UI

    Open your browser and navigate to: https://localhost:7XXX/swagger (port will be displayed in terminal)

API Endpoints

Authentication

Register a new user

POST /api/Auth/register
Content-Type: application/json

{
  "email": "user@example.com",
  "password": "Password123",
  "firstName": "John",
  "lastName": "Doe"
}

Login

POST /api/Auth/login
Content-Type: application/json

{
  "email": "user@example.com",
  "password": "Password123"
}

Response:

{
  "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
  "email": "user@example.com",
  "firstName": "John",
  "lastName": "Doe",
  "expiresAt": "2026-08-04T13:00:00Z"
}

Tasks (Requires Authentication)

Add the JWT token to your requests:

Authorization: Bearer {your-token-here}

Get all tasks (with pagination and filters)

GET /api/Tasks?pageNumber=1&pageSize=10&status=0&assignedToId={userId}

Query Parameters:

  • pageNumber (optional): Page number (default: 1)
  • pageSize (optional): Items per page (default: 10, max: 100)
  • status (optional): Filter by status (0=Pending, 1=InProgress, 2=Completed)
  • assignedToId (optional): Filter by assigned user ID

Get a specific task

GET /api/Tasks/{id}

Create a new task

POST /api/Tasks
Content-Type: application/json
Authorization: Bearer {token}

{
  "title": "Implement user authentication",
  "description": "Add JWT authentication to the API",
  "dueDate": "2026-08-15T00:00:00Z",
  "assignedToId": "user-id-here"
}

Update a task

PUT /api/Tasks/{id}
Content-Type: application/json
Authorization: Bearer {token}

{
  "title": "Updated title",
  "description": "Updated description",
  "status": 1,
  "dueDate": "2026-08-20T00:00:00Z"
}

Delete a task

DELETE /api/Tasks/{id}
Authorization: Bearer {token}

Task Status Values

  • 0 - Pending
  • 1 - InProgress
  • 2 - Completed

Using Swagger UI

  1. Run the application
  2. Navigate to the Swagger UI (https://localhost:7XXX/swagger)
  3. Click "Authorize" button (top right)
  4. Register a new user via /api/Auth/register
  5. Login via /api/Auth/login to get your JWT token
  6. Copy the token from the response
  7. Click "Authorize" again and enter: Bearer {your-token}
  8. Now you can test all authenticated endpoints!

Configuration

JWT Settings

Edit appsettings.json to customize JWT settings:

"Jwt": {
  "Key": "YourSuperSecretKeyThatShouldBeAtLeast32CharactersLong!",
  "Issuer": "TaskFlowAPI",
  "Audience": "TaskFlowClient"
}

Important: Never commit sensitive keys to GitHub. Use environment variables or Azure Key Vault in production.

Password Requirements

Default password requirements (configured in Program.cs):

  • Minimum 6 characters
  • At least one digit
  • At least one lowercase letter
  • At least one uppercase letter

Database Schema

ApplicationUser (extends IdentityUser)

  • Id (string, PK)
  • Email (string)
  • FirstName (string)
  • LastName (string)
  • CreatedAt (DateTime)

TaskItem

  • Id (int, PK)
  • Title (string, required, max 200 chars)
  • Description (string, max 1000 chars)
  • Status (enum: Pending, InProgress, Completed)
  • CreatedAt (DateTime)
  • UpdatedAt (DateTime, nullable)
  • DueDate (DateTime, nullable)
  • AssignedToId (string, FK to ApplicationUser)

Development

Run in Development Mode

dotnet run --environment Development

Create a new migration

dotnet ef migrations add MigrationName

Update database

dotnet ef database update

Remove last migration

dotnet ef migrations remove

Future Enhancements

  • Task priority levels
  • Task categories/tags
  • File attachments
  • Task comments
  • Email notifications
  • Task history/audit log
  • Advanced search functionality
  • Role-based authorization

Author

Guilherme Coimbra

License

This project is open source and available for educational and portfolio purposes.

About

RESTful API for task and project management with JWT authentication

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages