Automated Action e01f3a4d57 Create FastAPI Todo App
Create a simple Todo API with FastAPI and SQLite with CRUD functionality,
health check, error handling, and API documentation.
2025-05-31 21:13:37 +00:00
2025-05-31 21:13:37 +00:00
2025-05-31 21:13:37 +00:00
2025-05-31 21:04:09 +00:00
2025-05-31 21:13:37 +00:00
2025-05-31 21:13:37 +00:00
2025-05-31 21:13:37 +00:00
2025-05-31 21:13:37 +00:00
2025-05-31 21:13:37 +00:00

FastAPI Todo App

A simple Todo API built with FastAPI and SQLite.

Features

  • 📝 Todo Management: Create, read, update, and delete todo items
  • 🔍 Filtering & Pagination: Filter todos by completion status and paginate results
  • 📊 Health Monitoring: Endpoint to check application and database health
  • 🛡️ Error Handling: Comprehensive error handling with meaningful messages
  • 📚 API Documentation: Auto-generated Swagger/OpenAPI documentation

Tech Stack

  • FastAPI: Modern, fast (high-performance) web framework for building APIs
  • SQLAlchemy: SQL toolkit and Object-Relational Mapping (ORM)
  • Alembic: Database migration tool
  • SQLite: Lightweight, file-based database
  • Pydantic: Data validation and settings management
  • Uvicorn: ASGI server for running the application

Project Structure

├── app/
│   ├── api/
│   │   └── v1/
│   │       ├── health.py          # Health check endpoint
│   │       ├── router.py          # API router
│   │       └── todos.py           # Todo CRUD endpoints
│   ├── core/
│   │   ├── config.py              # Application configuration
│   │   └── exceptions.py          # Custom exception handlers
│   ├── database/
│   │   └── session.py             # Database session setup
│   ├── models/
│   │   └── todo.py                # SQLAlchemy models
│   └── schemas/
│       └── todo.py                # Pydantic schemas
├── migrations/                    # Alembic migration files
├── alembic.ini                    # Alembic configuration
├── main.py                        # Application entry point
└── requirements.txt               # Project dependencies

Setup Instructions

Prerequisites

  • Python 3.8+
  • pip (Python package installer)

Installation

  1. Clone the repository:

    git clone <repository-url>
    cd todoapp-us6a2a
    
  2. Install dependencies:

    pip install -r requirements.txt
    
  3. Create the database and run migrations:

    alembic upgrade head
    

Running the Application

Start the application with:

uvicorn main:app --host 0.0.0.0 --port 8000 --reload

The API will be available at: http://localhost:8000

API Documentation

Interactive API documentation is available at:

API Endpoints

Health Check

  • GET /health - Check application health

Todo Endpoints

  • GET /api/v1/todos - List all todos (with optional filtering and pagination)
  • POST /api/v1/todos - Create a new todo
  • GET /api/v1/todos/{todo_id} - Get a specific todo
  • PATCH /api/v1/todos/{todo_id} - Update a todo
  • DELETE /api/v1/todos/{todo_id} - Delete a todo

Example Usage

Create a Todo

curl -X 'POST' \
  'http://localhost:8000/api/v1/todos/' \
  -H 'Content-Type: application/json' \
  -d '{
  "title": "Learn FastAPI",
  "description": "Build a sample todo app",
  "completed": false
}'

List All Todos

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

Get a Specific Todo

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

Update a Todo

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

Delete a Todo

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

License

This project is licensed under the MIT License.

Description
Project: Todo App
Readme 55 KiB
Languages
Python 97.3%
Mako 2.7%