KAHIBARO
Discord Login Register

Project Requirements

Understanding the Project

You are going to build a Task Management API. This is a backend-only project, so there is no user interface. Other applications, such as a web frontend, mobile app, or CLI tool, will talk to your API using HTTP.

The goal of this chapter is to define what the system should do, not how you will implement it. Think of this as the contract between you and anyone who wants to use your API.

Throughout this chapter, imagine you are building something similar to a simple version of Trello or Todoist, but focused on learning backend concepts, not on every real-world feature.


High-Level Overview

At a high level, the Task Management API will let users:

The API will be RESTful and will use JSON for requests and responses.

Most endpoints will be authenticated. Each user will only be able to manage their own tasks.


Core Entities and Data Model

You will focus mainly on two entities:

You might later add more (for example projects or labels), but they are not required for this first project.

User

A user represents a person using the application.

Typical fields:

FieldTypeExampleNotes
idinteger / UUID1 or "67e..."Unique identifier
emailstring"alice@example.com"Unique, used for login
password_hashstring"$2b$12$..."Hashed password, not plain text
created_atdatetime"2026-01-01T10:23:45Z"When the user registered
updated_atdatetime"2026-01-05T08:30:01Z"Last profile update

The API will never return the raw password or password hash to the client.

Task

A task is an item that the user wants to track and complete.

Typical fields:

FieldTypeExampleNotes
idinteger / UUID42Unique per task
user_idinteger / UUID1Owner of the task
titlestring"Buy groceries"Short name, required
descriptionstring / null"Milk, eggs, bread"Optional details
statusenum/string"todo", "in_progress", "done"Controls state of task
priorityenum/string"low", "medium", "high"Simple priority system
due_datedate / null"2026-02-01"Deadline if any
created_atdatetime"2026-01-10T14:21:30Z"When the task was created
updated_atdatetime"2026-01-11T09:00:00Z"Last time the task changed

You will define allowed values for status and priority explicitly. For example:

Status values: todo, in_progress, done
Priority values: low, medium, high

Example task in JSON:

json
{
  "id": 42,
  "title": "Buy groceries",
  "description": "Milk, eggs, bread",
  "status": "todo",
  "priority": "medium",
  "due_date": "2026-02-01",
  "created_at": "2026-01-10T14:21:30Z",
  "updated_at": "2026-01-10T14:21:30Z"
}

Functional Requirements

Functional requirements describe what the API must do.

User Registration

Users must be able to create an account.

json
{
  "email": "alice@example.com",
  "password": "StrongPassword123"
}

Example success response:

json
{
  "id": 1,
  "email": "alice@example.com",
  "created_at": "2026-01-01T10:23:45Z"
}

User Login

Users must be able to log in and receive an access token.

json
{
  "email": "alice@example.com",
  "password": "StrongPassword123"
}

Example response:

json
{
  "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI...",
  "token_type": "bearer"
}

Create Task

Authenticated users can create new tasks.

json
{
  "title": "Buy groceries",
  "description": "Milk, eggs, bread",
  "status": "todo",
  "priority": "medium",
  "due_date": "2026-02-01"
}

Example success response:

json
{
  "id": 42,
  "title": "Buy groceries",
  "description": "Milk, eggs, bread",
  "status": "todo",
  "priority": "medium",
  "due_date": "2026-02-01",
  "created_at": "2026-01-10T14:21:30Z",
  "updated_at": "2026-01-10T14:21:30Z"
}

List Tasks

Users can list their own tasks.

Basic behavior:

Example response:

json
{
  "items": [
    {
      "id": 42,
      "title": "Buy groceries",
      "status": "todo",
      "priority": "medium",
      "due_date": "2026-02-01",
      "created_at": "2026-01-10T14:21:30Z",
      "updated_at": "2026-01-10T14:21:30Z"
    },
    {
      "id": 43,
      "title": "Finish report",
      "status": "in_progress",
      "priority": "high",
      "due_date": "2026-01-15",
      "created_at": "2026-01-10T16:00:00Z",
      "updated_at": "2026-01-11T09:00:00Z"
    }
  ],
  "total": 2,
  "page": 1,
  "page_size": 20
}

Get Single Task

Users can retrieve details of a single task that they own.

Example successful response:

json
{
  "id": 43,
  "title": "Finish report",
  "description": "Finish the financial report for Q1",
  "status": "in_progress",
  "priority": "high",
  "due_date": "2026-01-15",
  "created_at": "2026-01-10T16:00:00Z",
  "updated_at": "2026-01-11T09:00:00Z"
}

If the task does not exist or belongs to another user, return an appropriate error (for example 404).

Update Task

Users can update their tasks.

You will support:

Example PATCH /tasks/43 request:

json
{
  "status": "done",
  "priority": "medium"
}

Rules:

Example response:

json
{
  "id": 43,
  "title": "Finish report",
  "description": "Finish the financial report for Q1",
  "status": "done",
  "priority": "medium",
  "due_date": "2026-01-15",
  "created_at": "2026-01-10T16:00:00Z",
  "updated_at": "2026-01-12T12:30:00Z"
}

Delete Task

Users can delete tasks that they own.

Behavior:

Non-Functional Requirements

Non-functional requirements describe how well the system should perform its functions.

Reliability and Consistency

Security (High Level)

Performance

This is a learning project, so performance is not the main goal, but:

Maintainability

API Design Overview

Here is a possible overview of the main endpoints. You will refine these in later chapters.

MethodPathDescriptionAuth required
POST/auth/registerRegister a new userNo
POST/auth/loginLog in and get access tokenNo
GET/tasksList current user's tasksYes
POST/tasksCreate a new taskYes
GET/tasks/{id}Get a specific taskYes
PUT/tasks/{id}Fully update a taskYes
PATCH/tasks/{id}Partially update a taskYes
DELETE/tasks/{id}Delete a taskYes

You may later add endpoints for user profile, health checks, or admin tasks, but they are optional for this project.


Authentication and Authorization Requirements

You will implement a simple token-based authentication flow.

  Authorization: Bearer <access_token>

Important: Every data access for tasks must be restricted to the authenticated user. Never let a user read, update, or delete tasks that do not belong to them.

You do not need extremely advanced security features for this first project, but you should:

Validation and Error Handling Requirements

Requests must be validated so that the server never writes invalid data to the database.

Input Validation

Examples of validation rules:

If validation fails, the API must return:

Example error response:

json
{
  "detail": [
    {
      "field": "title",
      "message": "Title must not be empty"
    },
    {
      "field": "priority",
      "message": "Invalid priority, allowed: low, medium, high"
    }
  ]
}

Authentication and Authorization Errors

Example 401 response:

json
{
  "detail": "Not authenticated"
}

Example 403/404 response:

json
{
  "detail": "Task not found"
}

Other Errors

Pagination, Filtering, and Sorting

The list endpoint for tasks must support basic pagination. Filtering and sorting are strongly recommended to make the API more practical.

Pagination

Use query parameters, for example:

Rules:

Response should contain:

Example:

json
{
  "items": [ /* tasks */ ],
  "total": 57,
  "page": 2,
  "page_size": 20
}

Filtering

Allow users to filter tasks by attributes using query parameters, for example:

You might also allow filtering by due date, for example:

Sorting

Allow sorting by some fields, for example:

Rules:

Example:

http
GET /tasks?status=todo&sort_by=due_date&sort_order=asc&page=1&page_size=10

Example Usage Scenario

To make all requirements concrete, imagine the following scenario and how your API would be used.

  1. Alice registers

Request:

http
   POST /auth/register
   Content-Type: application/json
   {
     "email": "alice@example.com",
     "password": "StrongPassword123"
   }

Response: user info.

  1. Alice logs in
http
   POST /auth/login
   Content-Type: application/json
   {
     "email": "alice@example.com",
     "password": "StrongPassword123"
   }

Response:

json
   {
     "access_token": "eyJhbGciOiJIUzI1NiIs...",
     "token_type": "bearer"
   }
  1. Alice creates a task
http
   POST /tasks
   Authorization: Bearer eyJhbGciOiJIUzI1NiIs...
   Content-Type: application/json
   {
     "title": "Buy groceries",
     "description": "Milk, eggs, bread",
     "priority": "medium",
     "due_date": "2026-02-01"
   }
  1. Alice lists her tasks
http
   GET /tasks?status=todo&sort_by=due_date&sort_order=asc
   Authorization: Bearer eyJhbGciOiJIUzI1NiIs...
  1. Alice marks the task as done
http
   PATCH /tasks/42
   Authorization: Bearer eyJhbGciOiJIUzI1NiIs...
   Content-Type: application/json
   {
     "status": "done"
   }
  1. Alice deletes the task
http
   DELETE /tasks/42
   Authorization: Bearer eyJhbGciOiJIUzI1NiIs...

If Bob tries to access task 42 that belongs to Alice, he must receive an error and never see the task data.


Acceptance Criteria Checklist

Use this checklist to verify that your implementation meets the requirements:

Functional checklist

  • [ ] Users can register with a unique email and password.
  • [ ] Users can log in and receive an access token.
  • [ ] Authenticated users can create tasks.
  • [ ] Authenticated users can list only their tasks.
  • [ ] Authenticated users can get, update, and delete their own tasks.
  • [ ] Users cannot access other users' tasks.
  • [ ] Task list endpoint supports pagination.
  • [ ] Task list endpoint supports basic filtering and sorting.
  • [ ] All input is validated and invalid data is rejected with clear errors.

You will implement these requirements step by step in the following chapters, where you will design the project structure, the database, and the actual CRUD operations.

Views: 6

Comments

Please login to add a comment.

Don't have an account? Register now!