Todo App API
A simple Todo app API built with FastAPI and SQLite.
Features
- CRUD operations for todo items
- SQLAlchemy ORM for database interactions
- Alembic for database migrations
- Pydantic for data validation
- Health check endpoint
- FastAPI automatic documentation with Swagger UI and ReDoc
Project Structure
/
├── app/ # Application package
│ ├── api/ # API endpoints
│ │ ├── deps.py # Dependencies
│ │ └── endpoints/ # API routes
│ ├── core/ # Core modules
│ │ └── config.py # Configuration
│ ├── crud/ # CRUD operations
│ ├── db/ # Database setup
│ ├── models/ # SQLAlchemy models
│ └── schemas/ # Pydantic schemas
├── migrations/ # Alembic migrations
├── alembic.ini # Alembic config
├── main.py # Application entry point
└── requirements.txt # Dependencies
Getting Started
Prerequisites
- Python 3.8 or higher
Installation
- Clone the repository:
git clone <repository-url>
cd todoapp
- Install dependencies:
pip install -r requirements.txt
- Run database migrations:
alembic upgrade head
- Start the application:
uvicorn main:app --reload
The API will be available at http://localhost:8000
API Documentation
Once the application is running, you can access:
- Swagger UI documentation: http://localhost:8000/docs
- ReDoc documentation: http://localhost:8000/redoc
API Endpoints
GET /health
- Health check endpointGET /api/v1/todos
- List all todosPOST /api/v1/todos
- Create a new todoGET /api/v1/todos/{todo_id}
- Get a specific todoPUT /api/v1/todos/{todo_id}
- Update a todoDELETE /api/v1/todos/{todo_id}
- Delete a todo
Data Models
Todo
id
: Integer (auto-generated)title
: String (required)description
: String (optional)completed
: Boolean (default: false)priority
: Integer (0=low, 1=medium, 2=high)created_at
: DateTime (auto-generated)updated_at
: DateTime (auto-updated)
Description
Languages
Python
96%
Mako
4%