
- Fix Python path in migrations/env.py for proper imports - Update database path to use relative project paths instead of /app - Update alembic.ini to use relative database path - Update README with correct database location and migration instructions generated with BackendIM... (backend.im)
Simple Todo Application
A simple Todo application API built with FastAPI, SQLAlchemy, and SQLite.
Features
- Create, read, update, and delete todo items
- Filter todos by completion status
- Pagination support
- Health check endpoint
Project Structure
simpletodoapplication/
├── app/
│ ├── __init__.py
│ ├── crud.py # CRUD operations
│ ├── database.py # Database configuration
│ ├── models.py # SQLAlchemy models
│ └── schemas.py # Pydantic schemas
├── migrations/ # Alembic migrations
├── alembic.ini # Alembic configuration
├── main.py # FastAPI application
└── requirements.txt # Project dependencies
Installation
- Clone the repository
- Install dependencies:
pip install -r requirements.txt
Database Setup
The application uses SQLite, and the database will be created automatically at ./storage/db/db.sqlite
relative to the project root when the application starts.
Migrations
To run database migrations:
# Set the Python path to include the project root
export PYTHONPATH=/path/to/project
# Run migrations
alembic upgrade head
Running the Application
uvicorn main:app --reload
The API will be available at http://localhost:8000
API Documentation
Once the application is running, you can access the API documentation at:
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
API Endpoints
Health Check
GET /health
- Check if the API is running
Todo Operations
GET /todos/
- List all todos (supports pagination and filtering by completion status)POST /todos/
- Create a new todoGET /todos/{todo_id}
- Get a specific todoPUT /todos/{todo_id}
- Update a todoDELETE /todos/{todo_id}
- Delete a todo
Example Usage
Create a Todo
curl -X 'POST' \
'http://localhost:8000/todos/' \
-H 'Content-Type: application/json' \
-d '{
"title": "Buy groceries",
"description": "Milk, bread, eggs"
}'
List All Todos
curl -X 'GET' 'http://localhost:8000/todos/'
Get Completed Todos
curl -X 'GET' 'http://localhost:8000/todos/?completed=true'
Update a Todo
curl -X 'PUT' \
'http://localhost:8000/todos/1' \
-H 'Content-Type: application/json' \
-d '{
"completed": true
}'
Delete a Todo
curl -X 'DELETE' 'http://localhost:8000/todos/1'
Description
Languages
Python
94.6%
Mako
5.4%