
- Create Todo model and schemas - Set up API endpoints for CRUD operations - Configure SQLAlchemy for database access - Set up Alembic for database migrations - Add Ruff for code linting - Update README with project documentation
Todo API
This is a FastAPI application for managing todo items.
Features
- RESTful API for todo management
- CRUD operations for todo items
- SQLite database with SQLAlchemy ORM
- Alembic for database migrations
- Automatic API documentation with Swagger UI
Project Structure
todoapi/
├── alembic.ini # Alembic configuration
├── app/ # Application package
│ ├── api/ # API routes
│ │ └── v1/ # API version 1
│ │ ├── api.py # Main API router
│ │ └── endpoints/ # API endpoints
│ │ └── todos.py # Todo endpoints
│ ├── core/ # Core modules
│ │ └── config.py # Application configuration
│ ├── crud/ # CRUD operations
│ │ └── todo.py # Todo CRUD operations
│ ├── db/ # Database modules
│ │ ├── base.py # Base models module
│ │ ├── base_class.py # Base model class
│ │ └── session.py # Database session
│ ├── models/ # SQLAlchemy models
│ │ └── todo.py # Todo model
│ └── schemas/ # Pydantic schemas
│ └── todo.py # Todo schemas
├── main.py # Main application entry point
├── migrations/ # Alembic migrations
│ ├── env.py # Migrations environment
│ ├── README # Migrations README
│ ├── script.py.mako # Migrations script template
│ └── versions/ # Migration versions
│ └── initial_migration.py # Initial migration
├── pyproject.toml # Project configuration
├── README.md # This file
└── requirements.txt # Project dependencies
Installation
- Clone the repository:
git clone <repository-url>
cd todoapi
- 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
- OpenAPI JSON: http://localhost:8000/openapi.json
API Endpoints
Todo Endpoints
GET /api/v1/todos
- List all todosPOST /api/v1/todos
- Create a new todoGET /api/v1/todos/{todo_id}
- Get a specific todoPUT /api/v1/todos/{todo_id}
- Update a todoDELETE /api/v1/todos/{todo_id}
- Delete a todo
Health Check
GET /health
- Check if the API is running
Database Migrations
Apply migrations:
alembic upgrade head
Create a new migration:
alembic revision --autogenerate -m "description"
Development
Linting
This project uses Ruff for linting:
ruff check .
To automatically fix issues:
ruff check --fix .
Description
Languages
Python
96.1%
Mako
3.9%