
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
-
Clone the repository
-
Install dependencies
pip install -r requirements.txt
- 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
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
- OpenAPI JSON: http://localhost:8000/openapi.json
API Endpoints
Base URL
GET /
- Returns basic API informationGET /health
- Health check endpoint
Todo Endpoints
GET /api/v1/todos
- List all todos (with optional filters)POST /api/v1/todos
- Create a new todoGET /api/v1/todos/{todo_id}
- Retrieve a specific todoPUT /api/v1/todos/{todo_id}
- Update a todoDELETE /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
Languages
Python
95.3%
Mako
4.7%