Automated Action 10172c55ca Implement comprehensive Task Manager API with FastAPI
Added complete task management functionality including:
- CRUD operations for tasks (create, read, update, delete)
- Task model with status (pending/in_progress/completed) and priority (low/medium/high)
- SQLite database with SQLAlchemy ORM
- Alembic migrations for database schema
- Pydantic schemas for request/response validation
- FastAPI routers with proper error handling
- Filtering and pagination support
- Health check endpoint
- CORS configuration
- Comprehensive API documentation
- Proper project structure following FastAPI best practices
2025-06-20 19:34:58 +00:00

3.2 KiB

Task Manager API

A comprehensive task management API built with FastAPI, SQLAlchemy, and SQLite. This API provides full CRUD operations for managing tasks with status tracking, priority levels, and timestamps.

Features

  • Create, read, update, and delete tasks
  • Task status management (pending, in_progress, completed)
  • Priority levels (low, medium, high)
  • Automatic timestamps (created_at, updated_at)
  • Filtering by status and priority
  • Pagination support
  • FastAPI automatic documentation
  • SQLite database with SQLAlchemy ORM
  • Database migrations with Alembic
  • CORS enabled for cross-origin requests
  • Health check endpoint

API Endpoints

Base URL

  • GET / - API information and links
  • GET /health - Health check endpoint

Tasks

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

Query Parameters for GET /api/v1/tasks/

  • skip (int): Number of tasks to skip (default: 0)
  • limit (int): Maximum number of tasks to return (default: 100, max: 1000)
  • status (string): Filter by status (pending, in_progress, completed)
  • priority (string): Filter by priority (low, medium, high)

Task Schema

{
  "id": 1,
  "title": "Example Task",
  "description": "This is an example task description",
  "status": "pending",
  "priority": "medium",
  "created_at": "2025-06-20T12:00:00",
  "updated_at": "2025-06-20T12:00:00"
}

Status Values

  • pending - Task is not yet started
  • in_progress - Task is currently being worked on
  • completed - Task has been finished

Priority Values

  • low - Low priority task
  • medium - Medium priority task (default)
  • high - High priority task

Installation and Setup

  1. Install dependencies:
pip install -r requirements.txt
  1. Run database migrations:
alembic upgrade head
  1. Start the development server:
uvicorn main:app --reload

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

Documentation

Environment Variables

No environment variables are required for basic operation. The application uses SQLite with a local database file stored in /app/storage/db/db.sqlite.

Development

The application uses the following structure:

  • main.py - FastAPI application entry point
  • app/models/ - SQLAlchemy database models
  • app/schemas/ - Pydantic request/response schemas
  • app/crud/ - Database operations
  • app/routers/ - API route handlers
  • app/db/ - Database configuration and session management
  • alembic/ - Database migration files

Testing

Run the linter and formatter:

ruff check .
ruff format .

Production Deployment

For production deployment, ensure proper database configuration and consider using PostgreSQL instead of SQLite for better performance and concurrent access.