Barebones Todo API

A simple, lightweight RESTful API for managing todo items built with FastAPI and SQLite.

Features

  • Create, read, update, and delete todo items
  • Filter todos by completion status
  • SQLite database for data persistence
  • FastAPI for high performance and automatic API documentation
  • Alembic for database migrations

Project Structure

├── app/
│   ├── api/              # API routes
│   │   └── v1/           # API version 1
│   │       └── endpoints/
│   │           └── todos.py
│   ├── core/             # Core application code
│   │   └── config.py     # Configuration settings
│   ├── db/               # Database setup
│   │   ├── base.py
│   │   ├── base_class.py
│   │   └── session.py
│   ├── models/           # SQLAlchemy models
│   │   └── todo.py
│   └── schemas/          # Pydantic schemas
│       └── todo.py
├── migrations/           # Alembic migrations
├── storage/              # Storage directory
│   └── db/               # Database storage
├── alembic.ini           # Alembic configuration
├── main.py               # Application entry point
└── requirements.txt      # Project dependencies

Installation

  1. Clone the repository

  2. Install dependencies

pip install -r requirements.txt
  1. Apply database migrations
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

API Endpoints

Base URL

  • GET / - Returns basic API information
  • GET /health - Health check endpoint

Todo Endpoints

  • GET /api/v1/todos - List all todos (with optional filters)
  • POST /api/v1/todos - Create a new todo
  • GET /api/v1/todos/{todo_id} - Retrieve a specific todo
  • PUT /api/v1/todos/{todo_id} - Update a todo
  • DELETE /api/v1/todos/{todo_id} - Delete a todo

Database Migrations

This project uses Alembic for database migrations. To create a new migration after model changes:

alembic revision --autogenerate -m "Description of changes"

To apply migrations:

alembic upgrade head
Description
Project: Barebones Todo App
Readme 40 KiB
Languages
Python 95.3%
Mako 4.7%