Automated Action 6d123e4b89 Create simple todo app with FastAPI and SQLite
- Set up project structure
- Create database models with SQLAlchemy
- Add Alembic migrations
- Implement CRUD API endpoints
- Update README with documentation

generated with BackendIM... (backend.im)
2025-05-14 01:42:06 +00:00

2.3 KiB

SimpleTodoApp

A simple Todo application API built with FastAPI and SQLite.

Features

  • Create, read, update, and delete todo items
  • SQLite database with SQLAlchemy ORM
  • Alembic migrations for database versioning
  • RESTful API with proper HTTP methods and status codes
  • Health check endpoint
  • Documentation with Swagger UI and ReDoc

Project Structure

simpletodoapp/
├── alembic.ini
├── app/
│   ├── __init__.py
│   ├── api/
│   │   ├── __init__.py
│   │   └── todos.py
│   ├── crud/
│   │   ├── __init__.py
│   │   └── todo.py
│   ├── db/
│   │   ├── __init__.py
│   │   └── database.py
│   ├── models/
│   │   ├── __init__.py
│   │   └── todo.py
│   └── schemas/
│       ├── __init__.py
│       └── todo.py
├── main.py
├── migrations/
│   ├── README
│   ├── env.py
│   ├── script.py.mako
│   └── versions/
│       └── a7d956f83192_create_todos_table.py
└── requirements.txt

Installation

  1. Clone the repository
  2. 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

API Endpoints

  • GET /health - Health check endpoint
  • GET /api/todos - Get all todos (with pagination)
  • GET /api/todos/{todo_id} - Get a specific todo
  • POST /api/todos - Create a new todo
  • PUT /api/todos/{todo_id} - Update a todo
  • DELETE /api/todos/{todo_id} - Delete a todo

Example Requests

Create a Todo

curl -X 'POST' \
  'http://localhost:8000/api/todos/' \
  -H 'Content-Type: application/json' \
  -d '{
  "title": "Buy groceries",
  "description": "Milk, eggs, bread",
  "completed": false
}'

Get All Todos

curl -X 'GET' 'http://localhost:8000/api/todos/'

Update a Todo

curl -X 'PUT' \
  'http://localhost:8000/api/todos/1' \
  -H 'Content-Type: application/json' \
  -d '{
  "completed": true
}'

Delete a Todo

curl -X 'DELETE' 'http://localhost:8000/api/todos/1'