# FastAPI Todo Application A modern, high-performance todo management API built with FastAPI, featuring a clean architecture and comprehensive functionality for task management. ## ๐Ÿš€ Quick Start Get up and running in minutes: ```bash # Install dependencies pip install -r requirements.txt # Initialize database alembic upgrade head # Launch the application uvicorn main:app --reload ``` Access your API at `http://localhost:8000` ## ๐Ÿ“‹ Features ### Core Functionality - โœ… Complete CRUD operations for todos - ๐Ÿ” Pagination support for large datasets - ๐Ÿ“ Rich todo metadata (title, description, completion status, timestamps) - ๐Ÿฅ Health monitoring endpoint ### Technical Features - ๐ŸŒ CORS-enabled for cross-origin requests - ๐Ÿ“š Auto-generated interactive documentation - ๐Ÿ—„๏ธ SQLite database with SQLAlchemy ORM - ๐Ÿ”„ Database migrations with Alembic - ๐Ÿงน Code quality with Ruff linting ## ๐Ÿ› ๏ธ Technology Stack - **Framework**: FastAPI 0.104.1 - **Database**: SQLite with SQLAlchemy 2.0.23 - **Migrations**: Alembic 1.13.0 - **Server**: Uvicorn 0.24.0 - **Code Quality**: Ruff 0.1.6 ## ๐Ÿ“– API Reference ### Base Endpoints | Method | Endpoint | Description | |--------|----------|-------------| | GET | `/` | Application information and links | | GET | `/health` | Service health status | ### Todo Management | Method | Endpoint | Description | Parameters | |--------|----------|-------------|-----------| | GET | `/api/v1/todos` | List todos | `skip`, `limit` | | POST | `/api/v1/todos` | Create todo | `title`, `description?` | | GET | `/api/v1/todos/{id}` | Get specific todo | `id` | | PUT | `/api/v1/todos/{id}` | Update todo | `id`, fields | | DELETE | `/api/v1/todos/{id}` | Delete todo | `id` | ### Example Requests **Create a Todo:** ```bash curl -X POST "http://localhost:8000/api/v1/todos" \ -H "Content-Type: application/json" \ -d '{"title": "Learn FastAPI", "description": "Build awesome APIs"}' ``` **List Todos:** ```bash curl "http://localhost:8000/api/v1/todos?skip=0&limit=10" ``` ## ๐Ÿ“š Documentation - **Interactive Docs**: [http://localhost:8000/docs](http://localhost:8000/docs) - **ReDoc**: [http://localhost:8000/redoc](http://localhost:8000/redoc) - **OpenAPI Schema**: [http://localhost:8000/openapi.json](http://localhost:8000/openapi.json) ## ๐Ÿ—๏ธ Architecture ``` todoapp/ โ”œโ”€โ”€ main.py # Application entry point โ”œโ”€โ”€ requirements.txt # Python dependencies โ”œโ”€โ”€ alembic.ini # Migration configuration โ”œโ”€โ”€ alembic/ # Database migrations โ”‚ โ”œโ”€โ”€ env.py # Migration environment โ”‚ โ”œโ”€โ”€ script.py.mako # Migration template โ”‚ โ””โ”€โ”€ versions/ # Migration files โ”‚ โ””โ”€โ”€ 0001_create_todos_table.py โ””โ”€โ”€ app/ # Application package โ”œโ”€โ”€ db/ โ”‚ โ”œโ”€โ”€ base.py # SQLAlchemy declarative base โ”‚ โ””โ”€โ”€ session.py # Database session management โ”œโ”€โ”€ models/ โ”‚ โ””โ”€โ”€ todo.py # Todo data model โ””โ”€โ”€ routes/ โ”œโ”€โ”€ todos.py # Todo API endpoints โ””โ”€โ”€ health.py # Health check endpoint ``` ## ๐Ÿ’พ Database **Storage Location**: `/app/storage/db/db.sqlite` The application uses SQLite for simplicity and portability. The database is automatically created on first run, with tables managed through Alembic migrations. **Todo Schema:** - `id`: Primary key (auto-increment) - `title`: Todo title (required) - `description`: Optional description - `completed`: Completion status (default: false) - `created_at`: Creation timestamp - `updated_at`: Last modification timestamp ## ๐Ÿ”ง Development ### Running Tests ```bash # Add your test command here when tests are implemented pytest ``` ### Code Quality ```bash # Lint and format code ruff check --fix . ``` ### Database Management ```bash # Create new migration alembic revision --autogenerate -m "description" # Apply migrations alembic upgrade head # Rollback migration alembic downgrade -1 ``` ## ๐Ÿ“ฆ Deployment For production deployment, consider: 1. **Environment Variables**: Configure database URL and secrets 2. **Process Manager**: Use Gunicorn with Uvicorn workers 3. **Reverse Proxy**: Place behind Nginx or similar 4. **Database**: Migrate to PostgreSQL for production workloads Example production command: ```bash gunicorn main:app -w 4 -k uvicorn.workers.UvicornWorker ``` ## ๐Ÿค Contributing 1. Fork the repository 2. Create a feature branch 3. Make your changes 4. Run tests and linting 5. Submit a pull request ## ๐Ÿ“„ License This project is open source and available under the MIT License. ## ๐Ÿ‘จโ€๐Ÿ’ป Author **BackendIM** - AI Backend Code Generation Agent --- *Built with โค๏ธ using FastAPI and modern Python practices*