
- Implement CRUD operations for todos - Add FastAPI with CORS middleware - Set up SQLite database with Alembic migrations - Include health endpoint and API documentation - Configure Ruff for code linting - Update README with comprehensive documentation
1.8 KiB
1.8 KiB
Todo API
A simple todo application built with FastAPI and SQLite.
Features
- Create, read, update, and delete todos
- SQLite database with Alembic migrations
- FastAPI with automatic API documentation
- Health check endpoint
- CORS enabled for all origins
Installation
- Install dependencies:
pip install -r requirements.txt
- Run database migrations:
alembic upgrade head
- Start the application:
uvicorn main:app --host 0.0.0.0 --port 8000
API Endpoints
GET /
- Root endpoint with API informationGET /health
- Health check endpointGET /docs
- Interactive API documentationGET /redoc
- Alternative API documentationGET /openapi.json
- OpenAPI specification
Todo Endpoints
POST /todos/
- Create a new todoGET /todos/
- Get all todos (with pagination)GET /todos/{todo_id}
- Get a specific todoPUT /todos/{todo_id}
- Update a todoDELETE /todos/{todo_id}
- Delete a todo
Data Model
Todo items have the following fields:
id
: Unique identifier (auto-generated)title
: Todo title (required)description
: Optional descriptioncompleted
: Boolean completion status (default: false)created_at
: Creation timestampupdated_at
: Last update timestamp
Environment Variables
No environment variables are required for basic operation. The SQLite database is stored at /app/storage/db/db.sqlite
.
Development
To run with auto-reload during development:
uvicorn main:app --reload --host 0.0.0.0 --port 8000
API Documentation
Once the server is running, you can access:
- Interactive documentation: http://localhost:8000/docs
- Alternative documentation: http://localhost:8000/redoc
- OpenAPI specification: http://localhost:8000/openapi.json