
- Setup project structure with FastAPI - Create Todo model and database schemas - Implement CRUD operations for Todo items - Create API endpoints for Todo operations - Add health check endpoint - Configure Alembic for database migrations - Add detailed documentation in README.md
Todo App API
A simple Todo app API built with FastAPI and SQLite. This project provides a RESTful API for managing todo items.
Features
- CRUD operations for todo items (Create, Read, Update, Delete)
- Filter todos by priority (low, medium, high) and completion status
- SQLite database with SQLAlchemy ORM
- Database migrations with Alembic
- API documentation with Swagger UI and ReDoc
Project Structure
├── app/
│ ├── api/ # API endpoints
│ │ └── v1/ # API version 1
│ │ └── endpoints/
│ │ └── todos.py
│ ├── core/ # Core application settings
│ │ └── config.py
│ ├── crud/ # Database CRUD operations
│ │ ├── base.py
│ │ └── crud_todo.py
│ ├── db/ # Database setup
│ │ ├── base.py
│ │ ├── base_class.py
│ │ └── session.py
│ ├── models/ # SQLAlchemy models
│ │ └── todo.py
│ └── schemas/ # Pydantic schemas
│ └── todo.py
├── migrations/ # Alembic migrations
│ └── versions/
│ └── 0001_create_todo_table.py
├── .env # Environment variables
├── alembic.ini # Alembic configuration
├── main.py # Application entry point
└── requirements.txt # Python dependencies
Getting Started
Prerequisites
- Python 3.8+
Installation
- Clone the repository
- Install dependencies:
pip install -r requirements.txt
- Run the application:
uvicorn main:app --reload
API Endpoints
GET /api/v1/todos
: List all todos (with optional filtering)POST /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 todoGET /health
: Health check endpointGET /docs
: API documentation (Swagger UI)GET /redoc
: API documentation (ReDoc)
Database Migrations
To apply migrations:
alembic upgrade head
Environment Variables
Configuration via environment variables in .env
file:
PROJECT_NAME
: Name of the projectPROJECT_DESCRIPTION
: Description of the projectPROJECT_VERSION
: Version of the projectBACKEND_CORS_ORIGINS
: List of allowed CORS origins
Description
Languages
Python
96.8%
Mako
3.2%