Todo Application API

This is a FastAPI-based Todo Application API that allows you to manage todo items. It's built with FastAPI and SQLite for data persistence.

Features

Hii

Hullooo

Heyaa

  • Create, read, update, and delete todo items
  • Filter todos by completion status
  • Health check endpoint
  • Swagger/OpenAPI documentation
  • SQLite database with Alembic migrations

Tech Stack

  • FastAPI: Modern, fast web framework for building APIs
  • SQLAlchemy: SQL toolkit and Object-Relational Mapping
  • Alembic: Database migration tool
  • SQLite: Lightweight disk-based database
  • Pydantic: Data validation and settings management
  • Uvicorn: ASGI server for FastAPI

Setup

  1. Clone the repository:

    git clone [your-repository-url]
    cd todoapplication-omxawp
    
  2. Install dependencies:

    pip install -r requirements.txt
    
  3. Run the application:

    uvicorn main:app --reload
    
  4. Access the API:

API Endpoints

Health Check

  • GET /health - Check if the API is running

Todo Operations

  • POST /api/todos/ - Create a new todo
  • GET /api/todos/ - List all todos (with optional filters)
  • GET /api/todos/{todo_id} - Get a specific todo
  • PUT /api/todos/{todo_id} - Update a todo
  • DELETE /api/todos/{todo_id} - Delete a todo

Example API Usage

Create a Todo Item

curl -X 'POST' \
  'http://127.0.0.1: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://127.0.0.1:8000/api/todos/'

Get a Specific Todo

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

Update a Todo

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

Delete a Todo

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

Database

The application uses SQLite with the database file stored at /app/storage/db/db.sqlite.

Migrations

Migrations are handled with Alembic:

# Apply migrations
alembic upgrade head

# Create a new migration
alembic revision --autogenerate -m "Description of changes"
Description
Project: Todo Application
Readme 42 KiB
Languages
Python 95.2%
Mako 4.8%