Simple Todo App

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

Features

  • Create, read, update, and delete todo items
  • SQLite database with SQLAlchemy ORM
  • Alembic for database migrations
  • Health check endpoint
  • API documentation

Requirements

  • Python 3.8+
  • FastAPI
  • SQLAlchemy
  • Alembic
  • Uvicorn
  • SQLite

Setup

  1. Clone the repository:
git clone https://github.com/yourusername/simpletodoapp.git
cd simpletodoapp
  1. Install dependencies:
pip install -r requirements.txt
  1. Run database migrations:
alembic upgrade head
  1. Start the server:
uvicorn main:app --reload

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

API Documentation

API documentation is available at:

API Endpoints

Root

  • GET / - Returns basic app information

Health Check

  • GET /health - Returns the health status of the API

Todo Operations

  • 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 todo
  • DELETE /api/v1/todos/{todo_id} - Delete a todo

Example Usage

Create a Todo

curl -X 'POST' \
  'http://localhost:8000/api/v1/todos/' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/json' \
  -d '{
  "title": "Buy groceries",
  "description": "Milk, eggs, bread",
  "completed": false
}'

Get All Todos

curl -X 'GET' \
  'http://localhost:8000/api/v1/todos/' \
  -H 'accept: application/json'

Mark Todo as Completed

curl -X 'PUT' \
  'http://localhost:8000/api/v1/todos/1' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/json' \
  -d '{
  "completed": true
}'

Project Structure

simpletodoapp/
├── app/
│   ├── api/
│   │   └── api_v1/
│   │       ├── endpoints/
│   │       │   └── todos.py
│   │       └── api.py
│   ├── core/
│   │   └── config.py
│   ├── crud/
│   │   ├── base.py
│   │   └── todo.py
│   ├── db/
│   │   ├── base.py
│   │   ├── base_class.py
│   │   └── session.py
│   ├── models/
│   │   └── todo.py
│   └── schemas/
│       └── todo.py
├── migrations/
│   └── versions/
│       └── 001_create_todos_table.py
├── storage/
│   └── db/
│       └── db.sqlite
├── alembic.ini
├── main.py
└── requirements.txt
Description
Project: Simple Todo App
Readme 40 KiB
Languages
Python 96.4%
Mako 3.6%