Skip to content

yuyamm/debug_app

Repository files navigation

Task Manager API

A simple RESTful API built with FastAPI for managing tasks. This application is designed for testing debugging capabilities with LLMs.

Features

  • Create, read, update, and delete tasks
  • Filter tasks by completion status
  • Filter tasks by priority level (1-5)
  • Get task statistics
  • Pagination support
  • Input validation

Installation

  1. Clone this repository
  2. Install dependencies:
pip install -r requirements.txt

Running the Application

python main.py

Or using uvicorn directly:

uvicorn main:app --reload

The API will be available at http://localhost:8000

API Documentation

Once the application is running, you can access:

  • Interactive API docs: http://localhost:8000/docs
  • Alternative API docs: http://localhost:8000/redoc

API Endpoints

1. Root Endpoint

curl http://localhost:8000/

2. Create a Task

curl -X POST http://localhost:8000/tasks \
  -H "Content-Type: application/json" \
  -d '{
    "title": "Complete project documentation",
    "description": "Write comprehensive docs for the API",
    "priority": 3
  }'

3. List All Tasks

# Get all tasks
curl http://localhost:8000/tasks

# Get completed tasks only
curl http://localhost:8000/tasks?completed=true

# Get pending tasks only
curl http://localhost:8000/tasks?completed=false

# Pagination
curl http://localhost:8000/tasks?skip=0&limit=10

4. Get a Specific Task

# Replace {task_id} with actual task ID
curl http://localhost:8000/tasks/{task_id}

5. Update a Task

# Partial update (only update specified fields)
curl -X PUT http://localhost:8000/tasks/{task_id} \
  -H "Content-Type: application/json" \
  -d '{
    "completed": true,
    "priority": 5
  }'

# Update title
curl -X PUT http://localhost:8000/tasks/{task_id} \
  -H "Content-Type: application/json" \
  -d '{
    "title": "Updated task title"
  }'

6. Delete a Task

curl -X DELETE http://localhost:8000/tasks/{task_id}

7. Get Tasks by Priority

# Get all priority 5 tasks
curl http://localhost:8000/tasks/priority/5

# Get all priority 1 tasks
curl http://localhost:8000/tasks/priority/1

8. Get Task Statistics

curl http://localhost:8000/stats

Example Workflow

Here's a complete example workflow:

# 1. Create a high-priority task
TASK_ID=$(curl -s -X POST http://localhost:8000/tasks \
  -H "Content-Type: application/json" \
  -d '{
    "title": "Fix critical bug",
    "description": "Memory leak in production",
    "priority": 5
  }' | python3 -c "import sys, json; print(json.load(sys.stdin)['id'])")

echo "Created task with ID: $TASK_ID"

# 2. Create a normal priority task
curl -X POST http://localhost:8000/tasks \
  -H "Content-Type: application/json" \
  -d '{
    "title": "Update documentation",
    "description": "Add API examples",
    "priority": 2
  }'

# 3. List all tasks
curl http://localhost:8000/tasks | python3 -m json.tool

# 4. Mark the critical task as completed
curl -X PUT http://localhost:8000/tasks/$TASK_ID \
  -H "Content-Type: application/json" \
  -d '{
    "completed": true
  }'

# 5. Get statistics
curl http://localhost:8000/stats | python3 -m json.tool

# 6. Get only high-priority tasks
curl http://localhost:8000/tasks/priority/5 | python3 -m json.tool

Task Model

{
  "id": "string (UUID)",
  "title": "string (required, 1-100 chars)",
  "description": "string (optional, max 500 chars)",
  "completed": "boolean (default: false)",
  "priority": "integer (1-5, default: 1)",
  "created_at": "datetime",
  "updated_at": "datetime"
}

Priority Levels

  • 1: Very Low
  • 2: Low
  • 3: Medium
  • 4: High
  • 5: Critical

Response Examples

Successful Task Creation (201)

{
  "id": "123e4567-e89b-12d3-a456-426614174000",
  "title": "Complete project documentation",
  "description": "Write comprehensive docs for the API",
  "completed": false,
  "priority": 3,
  "created_at": "2024-01-14T10:30:00",
  "updated_at": "2024-01-14T10:30:00"
}

Task Not Found (404)

{
  "detail": "Task with id '123e4567-e89b-12d3-a456-426614174000' not found"
}

Invalid Priority (400)

{
  "detail": "Priority must be between 1 and 5"
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages