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:

# 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:

curl -X POST "http://localhost:8000/api/v1/todos" \
  -H "Content-Type: application/json" \
  -d '{"title": "Learn FastAPI", "description": "Build awesome APIs"}'

List Todos:

curl "http://localhost:8000/api/v1/todos?skip=0&limit=10"

📚 Documentation

🏗️ 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

# Add your test command here when tests are implemented
pytest

Code Quality

# Lint and format code
ruff check --fix .

Database Management

# 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:

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

Description
Project: Todo App
Readme 42 KiB
Languages
Python 94.3%
Mako 5.7%