
- Set up project structure with FastAPI and SQLite - Created Todo model and database schemas - Implemented CRUD operations for Todo items - Added Alembic for database migrations - Added health check endpoint - Used Ruff for code linting and formatting - Updated README with project documentation
2.0 KiB
2.0 KiB
Simple Todo App
A simple Todo application API built with FastAPI and SQLite.
Features
- Create, read, update, and delete Todo items
- Filter Todos by completion status
- Health check endpoint
- SQLite database with SQLAlchemy ORM
- Alembic for database migrations
Project Structure
simpletodoapp/
├── app/
│ ├── api/
│ │ ├── endpoints/
│ │ │ ├── health.py
│ │ │ └── todos.py
│ ├── core/
│ │ └── config.py
│ ├── db/
│ │ ├── crud.py
│ │ └── session.py
│ ├── models/
│ │ └── todo.py
│ └── schemas/
│ └── todo.py
├── migrations/
│ ├── versions/
│ │ └── e4fe0b756bcd_create_todos_table.py
│ ├── env.py
│ ├── README
│ └── script.py.mako
├── storage/
│ └── db/
├── alembic.ini
├── main.py
└── requirements.txt
Installation
- Clone the repository
- Install dependencies:
pip install -r requirements.txt
Running the Application
uvicorn main:app --reload
The API will be available at http://localhost:8000
.
API Documentation will be available at:
- Swagger UI:
http://localhost:8000/docs
- ReDoc:
http://localhost:8000/redoc
Database Migration
The application uses Alembic for database migrations.
To apply migrations:
alembic upgrade head
API Endpoints
Health Check
GET /health
- Check the health of the application
Todo Endpoints
GET /api/todos
- List all todos (with optional filtering)POST /api/todos
- Create a new todoGET /api/todos/{todo_id}
- Get a specific todoPUT /api/todos/{todo_id}
- Update a todoDELETE /api/todos/{todo_id}
- Delete a todo
Example Todo Object
{
"id": 1,
"title": "Buy groceries",
"description": "Milk, bread, eggs",
"completed": false,
"created_at": "2023-08-01T10:00:00",
"updated_at": "2023-08-01T10:00:00"
}