# FastAPI Todo Application This is a simple Todo application API built with FastAPI and SQLite. It provides endpoints for creating, reading, updating, and deleting todo items. ## Features - RESTful API for todo management - CRUD operations for todo items - SQLite database with SQLAlchemy ORM - Database migrations with Alembic - API documentation with Swagger UI and ReDoc - Health check endpoint ## Project Structure ``` todoapp/ ├── alembic.ini # Alembic configuration ├── app/ # Application package │ ├── api/ # API routes │ │ ├── api.py # API router │ │ └── routes/ # API route modules │ │ ├── health.py # Health check endpoint │ │ └── todos.py # Todo endpoints │ ├── core/ # Core application modules │ │ └── config.py # Application configuration │ ├── db/ # Database modules │ │ ├── deps.py # Database dependencies │ │ └── session.py # Database session │ ├── models/ # SQLAlchemy models │ │ └── todo.py # Todo model │ ├── schemas/ # Pydantic schemas │ │ └── todo.py # Todo schemas │ └── services/ # Business logic services │ └── todo.py # Todo service ├── main.py # Application entry point ├── migrations/ # Alembic migrations │ ├── env.py # Alembic environment │ ├── script.py.mako # Migration script template │ └── versions/ # Migration scripts │ └── 001_create_todos_table.py # Initial migration ├── README.md # Project documentation ├── requirements.txt # Project dependencies └── storage/ # Data storage directory └── db/ # Database files ``` ## Getting Started ### Prerequisites - Python 3.8 or higher - pip (Python package installer) ### Installation 1. Clone the repository: ```bash git clone cd todoapp ``` 2. Install the dependencies: ```bash pip install -r requirements.txt ``` 3. Run the migrations to create the database: ```bash alembic upgrade head ``` 4. Start the application: ```bash uvicorn main:app --reload ``` The API will be available at http://localhost:8000. ## API Documentation Once the application is running, you can access the API documentation at: - Swagger UI: http://localhost:8000/docs - ReDoc: http://localhost:8000/redoc ## API Endpoints - `GET /api/v1/todos`: Get all todos - `POST /api/v1/todos`: Create a new todo - `GET /api/v1/todos/{todo_id}`: Get a specific todo - `PUT /api/v1/todos/{todo_id}`: Update a todo - `DELETE /api/v1/todos/{todo_id}`: Delete a todo - `GET /api/v1/health`: API health check - `GET /health`: Alternative health check endpoint ## Database The application uses SQLite as the database. The database file is stored in `storage/db/db.sqlite`. ## Development ### Code Style This project uses Ruff for linting and formatting. To lint the code: ```bash ruff check . ``` To format the code: ```bash ruff format . ```