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
- Clone the repository:
git clone <repository-url>
cd <repository-directory>
- 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
- Swagger UI documentation: http://localhost:8000/docs
- ReDoc documentation: http://localhost:8000/redoc
API Endpoints
Health Check
GET /health
- Check if the application is running properly
Todo Items
GET /api/v1/todos
- List all todo itemsPOST /api/v1/todos
- Create a new todo itemGET /api/v1/todos/{todo_id}
- Get a specific todo itemPUT /api/v1/todos/{todo_id}
- Update a todo itemDELETE /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
Languages
Python
93.5%
Mako
6.5%