FastAPI Todo App
A simple Todo API built with FastAPI and SQLite.
Features
- Create, read, update, and delete Todo items
- RESTful API endpoints
- SQLite database with SQLAlchemy ORM
- Alembic migrations
- API documentation with Swagger UI and ReDoc
Project Structure
simpletodoapp/
├── alembic/ # Database migrations
│ ├── versions/ # Migration scripts
│ ├── env.py # Migration environment
│ └── script.py.mako # Migration script template
├── app/ # Application package
│ ├── api/ # API endpoints
│ │ └── routers/ # API routers
│ │ ├── health.py # Health check endpoints
│ │ └── todos.py # Todo endpoints
│ ├── core/ # Core functionality
│ │ └── database.py # Database configuration
│ ├── models/ # SQLAlchemy models
│ │ └── todo.py # Todo model
│ ├── schemas/ # Pydantic schemas
│ │ └── todo.py # Todo schemas
│ └── services/ # Business logic
│ └── todo.py # Todo services
├── storage/ # Data storage directory
│ └── db/ # Database files
├── alembic.ini # Alembic configuration
├── main.py # Application entry point
├── pyproject.toml # Project configuration (Ruff)
└── requirements.txt # Python dependencies
Getting Started
Prerequisites
- Python 3.8 or higher
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 Documentation
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
API Endpoints
Health Check
GET /health
- Check API health
Todo Operations
GET /api/todos
- List all todosGET /api/todos/{todo_id}
- Get a single todoPOST /api/todos
- Create a new todoPUT /api/todos/{todo_id}
- Update a todoDELETE /api/todos/{todo_id}
- Delete a todo
Database Migrations
The application uses Alembic for database migrations. The initial migration is included to create the todos
table.
To apply migrations:
alembic upgrade head
Development
Linting
The project uses Ruff for linting:
ruff check .
To automatically fix linting issues:
ruff check --fix .
Description
Languages
Python
97.6%
Mako
2.4%