Task Manager API

A RESTful API for managing tasks built with FastAPI and SQLite.

Features

  • CRUD operations for tasks
  • Task filtering by status
  • Task pagination
  • Automatic API documentation
  • Health check endpoint
  • Root endpoint with API information
  • Task status and priority validation using Enums

Project Structure

taskmanagerapi-daenmk/
├── alembic.ini
├── app/
│   ├── api/
│   │   └── v1/
│   │       ├── endpoints/
│   │       │   └── tasks.py
│   │       └── router.py
│   ├── core/
│   │   └── config.py
│   ├── database/
│   │   ├── base.py
│   │   ├── base_class.py
│   │   ├── deps.py
│   │   └── session.py
│   ├── models/
│   │   └── task.py
│   └── schemas/
│       └── task.py
├── migrations/
│   ├── env.py
│   ├── README
│   ├── script.py.mako
│   └── versions/
│       └── 6e1b8a0e43c1_create_task_table.py
├── main.py
└── requirements.txt

Requirements

  • Python 3.8+
  • Dependencies listed in requirements.txt

Installation

  1. Clone the repository:
git clone https://github.com/yourusername/taskmanagerapi-daenmk.git
cd taskmanagerapi-daenmk
  1. Create a virtual environment (optional but recommended):
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
  1. Install dependencies:
pip install -r requirements.txt
  1. Run database migrations:
alembic upgrade head

Running the Application

Start the FastAPI server:

uvicorn main:app --reload

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

API Documentation

FastAPI generates interactive API documentation:

API Endpoints

Root Endpoint

  • GET / - Returns information about the API including the title, documentation links, and health check endpoint

Health Check

  • GET /health - Check if the API is running

Tasks

  • GET /api/v1/tasks - List all tasks (with optional filtering and pagination)
  • POST /api/v1/tasks - Create a new task
  • GET /api/v1/tasks/{task_id} - Get a specific task
  • PUT /api/v1/tasks/{task_id} - Update a task
  • DELETE /api/v1/tasks/{task_id} - Delete a task

Task Schema

{
  "title": "string",
  "description": "string",
  "status": "string",  // One of: "pending", "in_progress", "completed", "cancelled"
  "priority": "string",  // One of: "low", "medium", "high", "urgent"
  "due_date": "datetime",
  "completed": false
}

Query Parameters

For the GET /api/v1/tasks endpoint:

  • skip (int, default=0): Number of records to skip for pagination
  • limit (int, default=100): Maximum number of records to return
  • status (string, optional): Filter tasks by status (e.g., "pending", "completed")

Development

Linting

Lint your code using Ruff:

ruff check .

Fix linting issues automatically:

ruff check --fix .

Database Migrations

Create a new migration after model changes:

alembic revision --autogenerate -m "description of changes"

Apply migrations:

alembic upgrade head

License

MIT

Description
Project: Task Manager API
Readme 42 KiB
Languages
Python 95.9%
Mako 4.1%