Automated Action bd4441f91f Update README with due date functionality documentation
Added due date field documentation to Todo model and included usage examples
for creating todos with due dates and timezone handling.
2025-06-19 13:21:12 +00:00
2025-06-18 00:24:50 +00:00
2025-06-18 23:53:20 +00:00
2025-06-18 00:30:05 +00:00

Simple Todo API

A simple todo application built with FastAPI and SQLite.

Features

  • Create, read, update, and delete todos
  • Category management system for organizing todos
  • Priority levels for todos (low, medium, high)
  • Search and filtering by category, priority, and completion status
  • SQLite database with SQLAlchemy ORM
  • Database migrations with Alembic
  • FastAPI with automatic OpenAPI documentation
  • CORS enabled for all origins
  • Health check endpoint

API Endpoints

General

  • GET / - Root endpoint with basic information
  • GET /health - Health check endpoint
  • GET /docs - Interactive API documentation (Swagger UI)
  • GET /redoc - Alternative API documentation

Todos

  • GET /api/v1/todos - Get all todos (with filtering by category, priority, completion status, and search)
  • POST /api/v1/todos - Create a new todo
  • GET /api/v1/todos/{todo_id} - Get a specific todo
  • PUT /api/v1/todos/{todo_id} - Update a specific todo
  • DELETE /api/v1/todos/{todo_id} - Delete a specific todo

Categories

  • GET /api/v1/categories - Get all categories
  • POST /api/v1/categories - Create a new category
  • GET /api/v1/categories/{category_id} - Get a specific category
  • PUT /api/v1/categories/{category_id} - Update a specific category
  • DELETE /api/v1/categories/{category_id} - Delete a specific category

Installation

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

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

Project Structure

├── app/
│   ├── api/
│   │   └── v1/
│   │       ├── __init__.py
│   │       ├── todos.py
│   │       └── categories.py
│   ├── crud/
│   │   ├── __init__.py
│   │   ├── todo.py
│   │   └── category.py
│   ├── db/
│   │   ├── __init__.py
│   │   ├── base.py
│   │   └── session.py
│   ├── models/
│   │   ├── __init__.py
│   │   ├── todo.py
│   │   └── category.py
│   ├── schemas/
│   │   ├── __init__.py
│   │   ├── todo.py
│   │   └── category.py
│   └── __init__.py
├── alembic/
│   ├── versions/
│   │   ├── 001_initial_todo_table.py
│   │   ├── 002_add_priority_field.py
│   │   └── 003_add_categories.py
│   ├── env.py
│   └── script.py.mako
├── alembic.ini
├── main.py
├── requirements.txt
└── README.md

Database

The application uses SQLite database stored at /app/storage/db/db.sqlite. The database schema is managed using Alembic migrations.

Models

Todo Model

Each todo has the following fields:

  • id: Unique identifier (auto-generated)
  • title: Todo title (required, max 200 characters)
  • description: Todo description (optional, max 500 characters)
  • completed: Completion status (boolean, default: false)
  • priority: Priority level (low, medium, high, default: medium)
  • category_id: Reference to category (optional)
  • project_id: Reference to project (optional)
  • due_date: Due date and time with timezone (optional)
  • parent_id: Reference to parent todo for subtasks (optional)
  • created_at: Creation timestamp
  • updated_at: Last update timestamp

Due Date Features

  • is_overdue: Computed property indicating if todo is past due date
  • days_until_due: Computed property showing days until due (negative if overdue)

Category Model

Each category has the following fields:

  • id: Unique identifier (auto-generated)
  • name: Category name (required, max 100 characters, unique)
  • description: Category description (optional, max 500 characters)
  • color: Color code in hex format (optional, e.g., #FF0000)
  • created_at: Creation timestamp
  • updated_at: Last update timestamp

Usage Examples

Creating a Category

curl -X POST "http://localhost:8000/api/v1/categories" \
     -H "Content-Type: application/json" \
     -d '{"name": "Work", "description": "Work related tasks", "color": "#FF6B6B"}'

Creating a Todo with a Category

curl -X POST "http://localhost:8000/api/v1/todos" \
     -H "Content-Type: application/json" \
     -d '{"title": "Review presentation", "description": "Review the quarterly presentation", "category_id": 1, "priority": "high"}'

Creating a Todo with Due Date

curl -X POST "http://localhost:8000/api/v1/todos" \
     -H "Content-Type: application/json" \
     -d '{"title": "Submit report", "description": "Submit quarterly report", "due_date": "2024-12-31T23:59:59Z", "priority": "high"}'

Filtering Todos by Category

curl "http://localhost:8000/api/v1/todos?category_id=1"

Filtering Todos by Priority and Completion Status

curl "http://localhost:8000/api/v1/todos?priority=high&completed=false"

Search Todos

curl "http://localhost:8000/api/v1/todos?search=presentation"
Description
Project: Todo App
Readme MIT 120 KiB
Languages
Python 99.2%
Mako 0.8%