Simple Todo API
A deadass simple Todo API built with FastAPI and SQLite. This project provides a RESTful API for managing todo items with the basic CRUD operations.
Features
- RESTful API endpoints for Todo resource (Create, Read, Update, Delete)
- Advanced filtering, sorting, and pagination capabilities
- SQLite database with SQLAlchemy ORM
- Database migrations with Alembic
- Health check endpoint
- Interactive API documentation (Swagger & ReDoc)
Project Structure
simpletodoapi/
├── alembic.ini
├── app/
│ ├── api/
│ │ ├── endpoints/
│ │ │ ├── health.py
│ │ │ └── todo.py
│ │ └── __init__.py
│ ├── core/
│ │ └── __init__.py
│ ├── db/
│ │ ├── database.py
│ │ └── __init__.py
│ ├── models/
│ │ ├── todo.py
│ │ └── __init__.py
│ ├── schemas/
│ │ ├── todo.py
│ │ └── __init__.py
│ └── __init__.py
├── migrations/
│ ├── env.py
│ ├── script.py.mako
│ ├── versions/
│ │ ├── 20231111_initial_migration.py
│ │ └── __init__.py
│ └── __init__.py
├── main.py
└── requirements.txt
Installation
-
Clone the repository
-
Install dependencies:
pip install -r requirements.txt
- Run the application:
uvicorn main:app --reload
The API will be available at http://localhost:8000
API Endpoints
Health Check
GET /health
- Check API and database health
Todo Management
GET /api/v1/todos
- Get all todos (with advanced filtering, sorting, and pagination)- Filtering options:
completed
: Filter by completion status (true/false)created_after
: Filter todos created on or after date (YYYY-MM-DD)created_before
: Filter todos created on or before date (YYYY-MM-DD)
- Sorting options:
sort_by
: Field to sort by (id, title, created_at, updated_at)sort_order
: Sort direction (asc, desc)
- Pagination:
skip
: Number of items to skiplimit
: Maximum number of items to return
- Filtering options:
GET /api/v1/todos/{todo_id}
- Get a specific todo by IDPOST /api/v1/todos
- Create a new todoPUT /api/v1/todos/{todo_id}
- Update an existing todoDELETE /api/v1/todos/{todo_id}
- Delete a todo
API Documentation
Interactive API documentation is available at:
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
Database
The application uses SQLite as the database. The database file is stored at /app/storage/db/db.sqlite
.
Database migrations are managed with Alembic. The initial migration is already included to set up the todos table.
Development
To run the development server with hot-reload:
uvicorn main:app --reload
To lint the codebase:
ruff check .
To auto-fix linting issues:
ruff check --fix .
Description
Languages
Python
96.4%
Mako
3.6%