Simple Todo App

This is a simple Todo application API built with FastAPI and SQLite. It allows you to create, read, update, and delete todo items through a RESTful API.

Features

  • RESTful API for Todo items
  • SQLite database for persistence
  • Alembic migrations for database versioning
  • Data validation with Pydantic
  • Health check endpoint
  • API documentation with Swagger UI

Project Structure

.
├── app/                    # Application package
│   ├── api/                # API endpoints
│   │   ├── health.py       # Health check endpoint
│   │   └── todos.py        # Todo CRUD endpoints
│   ├── database/           # Database configuration
│   │   └── database.py     # SQLAlchemy setup
│   ├── models/             # SQLAlchemy models
│   │   └── todo.py         # Todo model
│   └── schemas/            # Pydantic schemas
│       └── todo.py         # Todo schemas for validation
├── migrations/             # Alembic migrations
│   └── versions/           # Migration scripts
│       └── 001_create_todos_table.py # Initial migration
├── alembic.ini             # Alembic configuration
├── main.py                 # FastAPI application entry point
└── requirements.txt        # Project dependencies

Requirements

  • Python 3.8 or higher

Installation

  1. Clone the repository:
git clone <repository-url>
cd <repository-directory>
  1. Install dependencies:
pip install -r requirements.txt

Running the Application

To run the application in development mode:

uvicorn main:app --reload

The application will be available at http://localhost:8000.

API Documentation

API Endpoints

Health Check

  • GET /health - Check if the application is running properly

Todo Items

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

Database Migrations

The application uses Alembic for database migrations. The initial migration to create the todos table is already included.

To apply migrations:

alembic upgrade head

Development

This project uses Ruff for linting. To run the linter:

ruff check .

To automatically fix issues:

ruff check --fix .
Description
Project: Simple Todo App
Readme 37 KiB
Languages
Python 93.5%
Mako 6.5%