# Simple TODO Application A simple TODO application built with FastAPI and SQLite. ## Features - Create, read, update, and delete TODO items - Filter TODO items by completion status - Health check endpoint ## Tech Stack - FastAPI: Web framework for building APIs - SQLAlchemy: ORM for database interactions - Pydantic: Data validation and settings management - Alembic: Database migration tool - SQLite: Lightweight relational database - Uvicorn: ASGI server for running the application ## Project Structure ``` . ├── alembic.ini # Alembic configuration ├── main.py # FastAPI application entry point ├── migrations/ # Database migrations │ ├── env.py │ ├── script.py.mako │ └── versions/ │ └── 001_create_todos_table.py ├── app/ │ ├── api/ # API endpoints │ │ └── routes/ │ │ ├── health.py # Health check endpoint │ │ └── todos.py # Todo endpoints │ ├── core/ # Core application code │ │ └── config.py # Application configuration │ ├── db/ # Database setup │ │ ├── base.py │ │ ├── deps.py # Database dependencies │ │ └── session.py # Database session setup │ ├── models/ # SQLAlchemy models │ │ └── todo.py # Todo model │ └── schemas/ # Pydantic schemas │ └── todo.py # Todo schemas └── requirements.txt # Project dependencies ``` ## Running the Application 1. Install dependencies: ```bash pip install -r requirements.txt ``` 2. Run database migrations: ```bash alembic upgrade head ``` 3. Start the application: ```bash uvicorn main:app --host 0.0.0.0 --port 8000 --reload ``` 4. Visit the API documentation: - Swagger UI: http://localhost:8000/docs - ReDoc: http://localhost:8000/redoc ## API Endpoints ### Health Check - `GET /health` - Check API and database status ### Todo Operations - `GET /api/todos` - List all todos (can filter by completion status) - `POST /api/todos` - Create a new todo - `GET /api/todos/{todo_id}` - Get a specific todo - `PUT /api/todos/{todo_id}` - Update a todo - `DELETE /api/todos/{todo_id}` - Delete a todo ## Example Usage ### Create a Todo ```bash curl -X POST http://localhost:8000/api/todos \ -H "Content-Type: application/json" \ -d '{"title": "Learn FastAPI", "description": "Complete FastAPI tutorial", "completed": false}' ``` ### Get All Todos ```bash curl http://localhost:8000/api/todos ``` ### Get Completed Todos ```bash curl http://localhost:8000/api/todos?completed=true ``` ### Update a Todo ```bash curl -X PUT http://localhost:8000/api/todos/1 \ -H "Content-Type: application/json" \ -d '{"completed": true}' ``` ### Delete a Todo ```bash curl -X DELETE http://localhost:8000/api/todos/1 ```