Task Manager API

A modern REST API service built with FastAPI and SQLite for task management and item resources.

Features

  • FastAPI-based REST API with automatic OpenAPI documentation
  • SQLAlchemy ORM with SQLite database
  • Alembic database migrations
  • CRUD operations for task and item resources
  • Task management with status, priority, and due dates
  • Health check endpoint
  • Async-ready with uvicorn

Project Structure

.
├── alembic.ini
├── app/
│   ├── api/
│   │   ├── api.py
│   │   └── endpoints/
│   │       ├── items.py
│   │       └── tasks.py
│   ├── core/
│   │   ├── config.py
│   │   └── database.py
│   ├── models/
│   │   ├── base.py
│   │   ├── item.py
│   │   └── task.py
│   └── schemas/
│       ├── item.py
│       └── task.py
├── main.py
├── migrations/
│   ├── env.py
│   ├── README
│   ├── script.py.mako
│   └── versions/
│       ├── 001_initial_migration.py
│       └── 002_add_task_table.py
└── requirements.txt

Prerequisites

  • Python 3.8+
  • virtualenv (recommended)

Installation

  1. Clone the repository:

    git clone <repository-url>
    cd <repository-directory>
    
  2. Create and activate a virtual environment (optional but recommended):

    python -m venv venv
    source venv/bin/activate  # On Windows: venv\Scripts\activate
    
  3. Install dependencies:

    pip install -r requirements.txt
    
  4. Initialize the database:

    alembic upgrade head
    

Running the API

Start the API server with:

uvicorn main:app --reload

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

API Documentation

FastAPI automatically generates interactive API documentation:

API Endpoints

Health

  • GET /health - Health check endpoint

Items

  • GET /api/v1/items/ - List all items
  • POST /api/v1/items/ - Create a new item
  • GET /api/v1/items/{item_id} - Get a specific item
  • PUT /api/v1/items/{item_id} - Update a specific item
  • DELETE /api/v1/items/{item_id} - Delete a specific item

Tasks

  • GET /api/v1/tasks/ - List all tasks (with optional status filtering)
  • 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
  • POST /api/v1/tasks/{task_id}/complete - Mark a task as completed

Development

Database Migrations

After modifying models, create a new migration:

alembic revision -m "description of changes"

Apply migrations:

alembic upgrade head

Revert migrations:

alembic downgrade -1  # Go back one migration

Code Quality

Run linting with Ruff:

ruff check .
ruff check --fix .  # Auto-fix issues
Description
Project: Generic REST API Service
Readme 42 KiB
Languages
Python 97.3%
Mako 2.7%