todoapp-pbq0j1/README.md
2025-06-17 06:48:54 +00:00

2.2 KiB

Todo API

A simple Todo application API built with FastAPI and SQLite.

Features

  • Create, read, update, and delete todos
  • RESTful API endpoints
  • SQLite database with SQLAlchemy ORM
  • Database migrations with Alembic
  • Health check endpoint
  • CORS enabled for all origins
  • Interactive API documentation

Requirements

  • Python 3.7+
  • FastAPI
  • SQLAlchemy
  • Alembic
  • Uvicorn

Installation

  1. Install dependencies:
pip install -r requirements.txt
  1. Run database migrations:
alembic upgrade head
  1. Start the application:
uvicorn main:app --reload

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

API Endpoints

Base

  • GET / - API information and links to documentation

Health Check

  • GET /health - Health check endpoint

Todos

  • GET /api/v1/todos - Get all todos (with pagination)
  • 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

Documentation

  • Interactive API docs: http://localhost:8000/docs
  • ReDoc documentation: http://localhost:8000/redoc
  • OpenAPI JSON: http://localhost:8000/openapi.json

Project Structure

.
├── main.py                 # FastAPI application entry point
├── requirements.txt        # Python dependencies
├── alembic.ini            # Alembic configuration
├── alembic/               # Database migrations
│   ├── env.py
│   ├── script.py.mako
│   └── versions/
│       └── 0001_create_todos_table.py
└── app/
    ├── __init__.py
    ├── db/
    │   ├── __init__.py
    │   ├── base.py        # SQLAlchemy declarative base
    │   └── session.py     # Database session configuration
    ├── models/
    │   ├── __init__.py
    │   └── todo.py        # Todo model
    └── routes/
        ├── __init__.py
        ├── todos.py       # Todo CRUD endpoints
        └── health.py      # Health check endpoint

Database

The application uses SQLite database stored at /app/storage/db/db.sqlite. The database is automatically created when the application starts.

Author

BackendIM