Automated Action 2f75e43b7f Implement Todo API application with FastAPI and SQLite
- Created project structure with FastAPI setup
- Added SQLite database connection with SQLAlchemy ORM
- Implemented Todo model and schemas
- Added CRUD operations for Todo items
- Created API endpoints for Todo management
- Added health check endpoint
- Configured Alembic for database migrations
- Updated project documentation in README.md
2025-05-24 22:41:36 +00:00

2.2 KiB

Todo API

A simple Todo application API built with FastAPI and SQLite.

Features

  • RESTful API using FastAPI
  • SQLite database with SQLAlchemy ORM
  • Database migrations using Alembic
  • CRUD operations for Todo items
  • Health check endpoint
  • OpenAPI documentation

Project Structure

/
├── app/
│   ├── api/
│   │   ├── v1/
│   │   │   ├── health.py
│   │   │   └── todos.py
│   │   ├── deps.py
│   │   └── routers.py
│   ├── core/
│   │   └── config.py
│   ├── crud/
│   │   ├── base.py
│   │   └── todo.py
│   ├── db/
│   │   ├── base.py
│   │   ├── base_class.py
│   │   └── session.py
│   ├── models/
│   │   └── todo.py
│   └── schemas/
│       └── todo.py
├── migrations/
│   ├── versions/
│   │   └── 01_initial_todo_table.py
│   ├── env.py
│   └── script.py.mako
├── alembic.ini
├── main.py
└── requirements.txt

Installation

  1. Clone the repository
  2. Install dependencies:
pip install -r requirements.txt

Database Setup

The application uses SQLite as its database. The database will be created at /app/storage/db/db.sqlite when the application starts.

To run the migrations:

alembic upgrade head

Running the Application

To run the application locally:

uvicorn main:app --reload

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

API Documentation

API documentation is available at:

API Endpoints

Health Check

  • GET /api/v1/health - Check API health

Todo Endpoints

  • GET /api/v1/todos - List all todos
  • POST /api/v1/todos - Create a new todo
  • GET /api/v1/todos/{id} - Get a specific todo
  • PUT /api/v1/todos/{id} - Update a todo
  • DELETE /api/v1/todos/{id} - Delete a todo

Query Parameters

List todos

  • skip - Number of records to skip (default: 0)
  • limit - Maximum number of records to return (default: 100)
  • completed - Filter by completion status (optional, boolean)