Task Manager API

A RESTful API for managing tasks and to-do items, built with FastAPI and SQLite.

Features

  • Create, read, update, and delete tasks
  • Filter tasks by status, priority, and completion status
  • Pagination support for listing tasks
  • Data validation with Pydantic models
  • Database migrations with Alembic
  • Comprehensive error handling
  • API documentation with Swagger UI and ReDoc

Project Structure

taskmanagerapi/
├── alembic.ini                 # Alembic configuration
├── app/                        # Main application package
│   ├── api/                    # API endpoints
│   │   ├── v1/                 # API version 1
│   │   │   ├── endpoints/      # API endpoint modules
│   │   │   │   ├── health.py   # Health check endpoint
│   │   │   │   └── tasks.py    # Task CRUD endpoints
│   │   │   └── router.py       # API router
│   ├── core/                   # Core application modules
│   │   ├── config.py           # Application configuration
│   │   ├── error_handlers.py   # Error handling middleware
│   │   └── exceptions.py       # Custom exceptions
│   ├── db/                     # Database modules
│   │   └── session.py          # Database session
│   ├── models/                 # SQLAlchemy models
│   │   └── task.py             # Task model
│   ├── schemas/                # Pydantic schemas
│   │   ├── responses.py        # Response schemas
│   │   └── task.py             # Task schemas
│   ├── services/               # Business logic
│   │   └── task.py             # Task service
│   └── storage/                # Storage directory
│       └── db/                 # Database directory
├── migrations/                 # Alembic migrations
│   ├── versions/               # Migration versions
│   │   └── 0001_create_tasks_table.py
│   ├── env.py                  # Alembic environment
│   └── script.py.mako          # Alembic script template
├── main.py                     # Application entry point
├── pyproject.toml              # Project configuration
└── requirements.txt            # Project dependencies

API Endpoints

  • GET /api/v1/health - Health check endpoint
  • GET /api/v1/tasks - List 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 specific task
  • DELETE /api/v1/tasks/{task_id} - Delete a specific task

Task Model

  • id: Integer - Task ID
  • title: String - Task title
  • description: String (optional) - Task description
  • status: Enum - Task status (todo, in_progress, done)
  • priority: Enum - Task priority (low, medium, high)
  • due_date: DateTime (optional) - Task due date
  • completed: Boolean - Whether the task is completed
  • created_at: DateTime - Task creation timestamp
  • updated_at: DateTime - Task update timestamp

Requirements

  • Python 3.8+
  • FastAPI
  • SQLAlchemy
  • Alembic
  • Pydantic
  • Uvicorn

Getting Started

  1. Clone the repository
  2. Install dependencies:
    pip install -r requirements.txt
    
  3. Run database migrations:
    alembic upgrade head
    
  4. Start the application:
    uvicorn main:app --reload
    
  5. Access the API documentation:

Development

  • Linting:
    ruff check .
    
  • Auto-fix linting issues:
    ruff check --fix .
    
Description
Project: Task Manager API
Readme 44 KiB
Languages
Python 97.9%
Mako 2.1%