Task Manager API

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

Features

  • Task CRUD operations
  • Task status and priority management
  • Task completion tracking
  • API documentation with Swagger UI and ReDoc
  • Health endpoint for monitoring

Tech Stack

  • FastAPI: Modern, high-performance web framework for building APIs
  • SQLAlchemy: SQL toolkit and Object-Relational Mapping (ORM)
  • Alembic: Database migration tool
  • SQLite: Lightweight relational database
  • Pydantic: Data validation and settings management
  • Uvicorn: ASGI server for FastAPI applications

API Endpoints

Task Management

  • GET /api/v1/tasks: Get all tasks
  • 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
  • POST /api/v1/tasks/{task_id}/complete: Mark a task as completed

Health Check

  • GET /health: Application health check
  • GET /db-test: Database connection diagnostic endpoint

Example Curl Commands

Create a new task

curl -X 'POST' \
  'https://your-domain.com/api/v1/tasks/' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/json' \
  -d '{
  "title": "Complete project documentation",
  "description": "Write comprehensive documentation for the project",
  "priority": "high",
  "status": "todo",
  "due_date": "2023-06-30T18:00:00.000Z",
  "completed": false
}'

Get all tasks

curl -X 'GET' \
  'https://your-domain.com/api/v1/tasks/' \
  -H 'accept: application/json'

Get a specific task

curl -X 'GET' \
  'https://your-domain.com/api/v1/tasks/1' \
  -H 'accept: application/json'

Update a task

curl -X 'PUT' \
  'https://your-domain.com/api/v1/tasks/1' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/json' \
  -d '{
  "title": "Updated title",
  "description": "Updated description",
  "status": "in_progress"
}'

Delete a task

curl -X 'DELETE' \
  'https://your-domain.com/api/v1/tasks/1' \
  -H 'accept: application/json'

Mark a task as completed

curl -X 'POST' \
  'https://your-domain.com/api/v1/tasks/1/complete' \
  -H 'accept: application/json'

Project Structure

taskmanagerapi/
├── alembic/               # Database migrations
│   └── versions/          # Migration scripts
├── app/
│   ├── api/               # API endpoints
│   │   └── routers/       # API route definitions
│   ├── core/              # Core application code
│   ├── crud/              # CRUD operations
│   ├── db/                # Database setup and models
│   ├── models/            # SQLAlchemy models
│   └── schemas/           # Pydantic schemas/models
├── main.py                # Application entry point
└── requirements.txt       # Project dependencies

Getting Started

Installation

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

Running Migrations

alembic upgrade head

Starting the Application

uvicorn main:app --reload

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

API Documentation

Description
Project: Task Manager API
Readme 250 KiB
Languages
Python 99.5%
Mako 0.5%