Simple Todo API

A simple todo application built with FastAPI and SQLite.

Features

  • Create, read, update, and delete todos
  • SQLite database with SQLAlchemy ORM
  • Database migrations with Alembic
  • FastAPI with automatic OpenAPI documentation
  • CORS enabled for all origins
  • Health check endpoint

API Endpoints

  • GET / - Root endpoint with basic information
  • GET /health - Health check endpoint
  • GET /docs - Interactive API documentation (Swagger UI)
  • GET /redoc - Alternative API documentation
  • GET /api/v1/todos - Get all todos
  • 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

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
│   ├── crud/
│   │   ├── __init__.py
│   │   └── todo.py
│   ├── db/
│   │   ├── __init__.py
│   │   ├── base.py
│   │   └── session.py
│   ├── models/
│   │   ├── __init__.py
│   │   └── todo.py
│   ├── schemas/
│   │   ├── __init__.py
│   │   └── todo.py
│   └── __init__.py
├── alembic/
│   ├── versions/
│   │   └── 001_initial_todo_table.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.

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)
  • created_at: Creation timestamp
  • updated_at: Last update timestamp
Description
Project: Todo App
Readme MIT 120 KiB
Languages
Python 99.2%
Mako 0.8%