
- Add priority field to Todo model - Update Pydantic schemas with priority field - Create Alembic migration for priority column - Add filter by priority to GET /todos endpoint - Update README with new feature details generated with BackendIM... (backend.im)
Simple Todo Application
A simple Todo API application built with FastAPI and SQLite.
Features
- RESTful API for managing todo items
- SQLite database with SQLAlchemy ORM
- Alembic migrations for database versioning
- Priority levels for todo items (Low, Medium, High)
- Filter todos by priority
- Health check endpoint
- Swagger UI documentation
Project Structure
.
├── alembic.ini
├── app
│ ├── api
│ │ └── routes
│ │ ├── health.py
│ │ └── todos.py
│ ├── db
│ │ ├── database.py
│ │ └── init_db.py
│ ├── models
│ │ └── todo.py
│ └── schemas
│ └── todo.py
├── main.py
├── migrations
│ ├── README
│ ├── env.py
│ ├── script.py.mako
│ └── versions
│ └── initial_migration.py
└── requirements.txt
Installation
- Clone the repository
- Install the dependencies:
pip install -r requirements.txt
Running the Application
uvicorn main:app --reload
The application will be available at http://localhost:8000.
API Documentation is available at:
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
API Endpoints
Health Check
GET /health
- Check API health
Todo Operations
GET /todos
- List all todos- Optional query parameter:
priority
(1=Low, 2=Medium, 3=High) to filter by priority
- Optional query parameter:
POST /todos
- Create a new todo (with optional priority field: 1=Low, 2=Medium, 3=High)GET /todos/{todo_id}
- Get a specific todoPUT /todos/{todo_id}
- Update a todo (including priority)DELETE /todos/{todo_id}
- Delete a todo
Database
The application uses SQLite with SQLAlchemy ORM. The database file is stored at /app/storage/db/db.sqlite
.
Migrations
This project uses Alembic for database migrations. To run migrations:
alembic upgrade head
Description
Languages
Python
94.9%
Mako
5.1%