2025-05-12 04:17:58 +01:00

2.4 KiB

Todo API Application

This is a FastAPI Todo API application with SQLite database that provides a complete CRUD functionality for managing todo items. Dave is testing edits. Another edit here

Features

  • Create, read, update, and delete todo items
  • RESTful API with proper HTTP status codes
  • SQLite database for storage
  • API documentation with Swagger and ReDoc
  • Alembic for database migrations

Project Structure

todoapiapplication/
├── alembic/                  # Database migrations
│   └── versions/             # Migration scripts
├── api/                      # API implementation
│   └── routes/               # API route handlers
├── db/                       # Database configuration
├── models/                   # SQLAlchemy ORM models
├── schemas/                  # Pydantic schemas/models
├── services/                 # Business logic layer
├── tests/                    # Test files
├── alembic.ini               # Alembic configuration
├── main.py                   # Application entry point
└── requirements.txt          # Project dependencies

API Endpoints

Method Endpoint Description Request Body Response
GET /api/todos/ Get all todos - List of todos
POST /api/todos/ Create a new todo Todo object Created todo
GET /api/todos/id Get a todo by ID - Todo object
PUT /api/todos/id Update a todo by ID Todo object Updated todo
DELETE /api/todos/id Delete a todo by ID - No content (204)

Setup and Installation

  1. Clone the repository
  2. Install the dependencies: pip install -r requirements.txt
  3. Run the application: uvicorn main:app --reload
  4. The API will be available at: http://localhost:8000
  5. API documentation: http://localhost:8000/docs or http://localhost:8000/redoc

Database Migrations

Migrations are handled by Alembic:

# Apply migrations
alembic upgrade head

# Create a new migration
alembic revision -m "description"

Todo Model

  • id: Integer (Primary Key)
  • title: String (Required)
  • description: String (Optional)
  • completed: Boolean (Default: False)
  • created_at: DateTime
  • updated_at: DateTime